BRINOVS blocks: Control, state and statistics (38 to 44)

Plain guide to the BRINOVS blocks that remember numbers, stop or pause a bot, wait for a candle, check readiness and read your trading statistics.

BRINOVS blocks: Control, state and statistics (38 to 44)

This part of the guide covers two menus of the BRINOVS blocks in the Bot Builder: Control and state (blocks 38 to 41) and Statistics (blocks 42 to 44). The first menu helps a bot remember things, stop or pause itself, wait, and check that it is safe to buy. The second menu reads back how your trades went. Both menus sit inside the BRINOVS menu of the Blocks list.

A few words used below. A tick is one new price from the market. A stake is the money you put on one trade. A trade (or contract) is one purchase. A trade is settled when it has finished and its result is known. The Journal is the log panel of the Bot Builder, where the bot writes messages to you. Like all Deriv blocks, a BRINOVS block only works when it sits inside one of the four main blocks: 1. Trade parameters, 2. Purchase conditions, 3. Sell conditions or 4. Restart trading conditions. A block put anywhere else is switched off (greyed out).

Nothing here promises profit. These blocks give you control and information. They do not make a strategy win.

Control and state (blocks 38 to 41)

These blocks look after the bot itself. Persistent variable and Persistent value give the bot a memory that survives a page refresh. Stop or pause the bot ends the run, or holds it, with a reason you can read. Wait until candle close makes the bot wait for the next candle (one bar on a price chart). Bot is ready tells you if the bot is allowed to buy right now. Clear saved rules is a small helper at the end of this section. In a bot they usually run in this order: set-up blocks in Run once at start, then the checks in Purchase conditions, then the stop or pause rules in Sell or Restart conditions.

Persistent variable

  • Kind: BRINOVS custom, block #38
  • Type id: bnv_persistent_variable
  • Shape: Action block
  • Where it goes: inside any of the four main blocks, in the middle of a stack of action blocks (in Trade parameters, use the Run once at start part). It can be used many times, with different names.
  • What it does: Keeps a named number, text or true/false value that is still there after you refresh the page or restart the bot. Use it as a counter or a flag, for example "how many rounds today". Read the value back with the Persistent value block.
  • Inputs:
    • Name: a text box, default counter. Letters, digits, _ and -, up to 40 characters, no spaces.
    • Action: set to or change by (default set to).
    • Value socket: a number, text or true/false (the toolbox gives 0). For change by it must be a number.
    • reset: never, after a win, after a loss or every UTC day (default never).
  • How it works: The first time a name is set, its first value is remembered as its starting value. set to replaces the value. change by adds a number to it (a new counter starts at 0). The reset rule sends the value back to its starting value after a settled winning trade, after a settled losing trade, or when a new UTC day begins (UTC is the world time standard; a new UTC day starts at 00:00 UTC). A trade that ends at exactly 0 resets neither. Pretend (dry run) trades never trigger a reset. The value is kept for the logged-in account.
  • Example:
┌─ 4. Restart trading conditions ────────────────────────────┐
│ Persistent variable [ rounds ] [ change by ▾ ] ( 1 )       │
│     reset [ every UTC day ▾ ]                              │
│ Trade again                                                │
└────────────────────────────────────────────────────────────┘

This counts one more round each time the bot gets here, and puts the counter back to 0 at the start of every UTC day. The real block is one long row on screen.

  • Good to know:
    • The bot stops with a message if the name is wrong, the value socket is empty, a text is longer than 500 characters, or change by is given something that is not a number.
    • A name keeps its type: a number variable cannot later be set to a text (the bot stops with a message).
    • If the saved data is damaged, it is ignored and the Persistent value block gives its fallback.

Persistent value

  • Kind: BRINOVS custom, block #38 (the reading half of Persistent variable)
  • Type id: bnv_persistent_variable_value
  • Shape: Value block (gives a number, text or true/false)
  • Where it goes: anywhere a value is wanted, inside the four main blocks. It can be used many times.
  • What it does: Reads a Persistent variable by its name. If that name does not exist yet, it gives the fallback value you put in the second box.
  • Inputs:
    • Name: a text box, default counter. It must match the name used in Persistent variable.
    • if none yet: a value socket for the fallback (the toolbox gives 0).
  • Gives back: the saved number, text or true/false. If the name is new or its saved data is damaged, the fallback.
  • How it works: It looks up the saved value. A variable with the every UTC day rule shows its starting value once a new UTC day has begun. Reading never changes the variable.
  • Example:
┌─ 2. Purchase conditions ───────────────────────────────────┐
│ if  < ( Persistent value [ rounds ] if none yet ( 0 ) )    │
│        ≥ ( 50 ) >                                          │
│ then  Stop the bot ...                                     │
└────────────────────────────────────────────────────────────┘

The bot stops once the saved counter reaches 50 or more.

  • Good to know:
    • The name must follow the same rules as in Persistent variable, or the bot stops with a message.
    • Put a sensible fallback, so the first run gives a number you expect.

Stop or pause the bot

  • Kind: BRINOVS custom, block #39
  • Type id: bnv_stop_pause
  • Shape: Action block
  • Where it goes: only inside 2. Purchase conditions, 3. Sell conditions or 4. Restart trading conditions, in the middle of a stack. It can be used more than once. A disabled copy comes ready in Restart trading conditions in a fresh Bot Builder.
  • What it does: On the block it reads "Stop the bot" or "Pause the bot". Stop ends the run now and shows your reason. Pause holds the bot for some seconds, or until you raise a number called the Resume ticket.
  • Inputs:
    • Action: Stop or Pause (default Stop).
    • reason: a text socket, shown in the Journal (the toolbox gives Stopped by my rule; at most 200 letters are kept).
    • pause seconds: a number socket (toolbox 60). 0 means "until the Resume ticket is raised".
    • Resume ticket: a number socket (toolbox 0), used for a pause of 0 seconds.
    • sell open contracts first: a tick box, off by default.
  • How it works: Stop ends the bot at once. A Pause with seconds above 0 waits that long and then carries on. A Pause with 0 seconds stops the bot and saves the pause: no purchase is allowed until you raise the Resume ticket above the saved one and run the bot again. With the tick box on, the bot first tries to sell every open contract. If selling fails, it still stops or pauses.
  • Example:
┌─ 4. Restart trading conditions ────────────────────────────┐
│ [ Pause ▾ ] the bot                                        │
│ reason ( "Cooling off" )                                   │
│ pause seconds ( 300 ) (0 = until Resume ticket)            │
│ Resume ticket ( 0 )                                        │
│ sell open contracts first ☐                                │
│ Trade again                                                │
└────────────────────────────────────────────────────────────┘

The bot waits five minutes and then trades again. With seconds set to 0 it would stop instead and stay paused until the ticket is raised to 1 or more.

  • Good to know:
    • Stopping never depends on a licence or any server, so Stop always works.
    • The two number boxes must hold numbers even for Stop. For a pause of 0 seconds the ticket must be a whole number of 0 or more. A pause needs seconds of 0 or more. Otherwise the bot stops with a message.
    • A saved manual pause stays in force even if you delete the block (every purchase is refused with a message). Raise the ticket, or use Clear saved rules, to get out of it.
    • This block does not protect your money by itself: it only acts where you place it and when it is reached.

Wait until candle close

  • Kind: BRINOVS custom, block #40
  • Type id: bnv_wait_until
  • Shape: Action block
  • Where it goes: inside any of the four main blocks, in the middle of a stack of action blocks. It can be used more than once.
  • What it does: On the block it reads "Wait until the (size) candle closes". The bot pauses at this block until the current candle of the chosen size has closed, then goes on with the next block. For waiting a fixed number of seconds, use Deriv's own blocks.
  • Inputs:
    • candle size: 1 minute, 2 minute, 3 minute, 5 minute, 10 minute, 15 minute, 30 minute, 1 hour, 2 hour, 4 hour, 8 hour or 1 day (default 1 minute).
  • How it works: A candle has closed when the first price of the next candle arrives. The bot uses the time stamps on the market's own prices, so a wrong clock on your phone does not matter. While waiting, the app stays responsive and the Stop button works at any time. The Journal says how many seconds the wait should take.
  • Example:
┌─ 2. Purchase conditions ───────────────────────────────────┐
│ Wait until the [ 5 minute ▾ ] candle closes                │
│ Purchase [ Rise ▾ ]                                        │
└────────────────────────────────────────────────────────────┘

The bot waits until the 5 minute candle is over, and then buys.

  • Good to know:
    • If no price arrives for 30 seconds after the candle should have closed, the bot stops with a plain message instead of waiting for ever. Check your connection.
    • If you press Stop while it waits, the wait ends quietly.

Bot ready

  • Kind: BRINOVS custom, block #41
  • Type id: bnv_bot_ready
  • Shape: True/false block
  • Where it goes: anywhere a true/false is wanted, for example in an if. It can be used many times.
  • What it does: On the block it reads "Bot is ready". It is true when the bot is in a safe state to buy: connected, logged in, receiving live prices, and sure of every open or unfinished purchase. It describes the bot, not the market.
  • Inputs: none.
  • Gives back: true when everything below is in order, otherwise false.
  • How it works: The bot checks, in this order: the connection is up, you are logged in, the live data feeds are running, any open contracts and unfinished buys have been matched with Deriv's records, and a fresh price arrived in the last 15 seconds. It is false while it is reconnecting or still checking. An unknown state counts as not ready.
  • Example:
┌─ 2. Purchase conditions ───────────────────────────────────┐
│ if  < Bot is ready >                                       │
│ then  Purchase [ Rise ▾ ]                                  │
└────────────────────────────────────────────────────────────┘

The bot buys only when it is ready.

  • Good to know:
    • Separate from this block, the bot already refuses every purchase while it is not ready, whether or not you use the block. The block just lets your own rules see the same answer.
    • If the BRINOVS execution layer (the part that buys for the bot) is switched off, this block always gives false.

Clear saved rules

  • Kind: BRINOVS custom (a helper in the Control and state menu; it has no catalogue number)
  • Type id: bnv_clear_saved_rules
  • Shape: Action block
  • Where it goes: only in the Run once at start part of 1. Trade parameters. A disabled copy comes ready there in a fresh Bot Builder.
  • What it does: Some BRINOVS blocks save their rule (a loss limit, a pause, a lock, a max stake) and the rule stays in force even after you delete the block. This block is the way out: it clears those saved rules so an old rule cannot stop a new bot.
  • Inputs:
    • Clear: the halts, locks and pauses (my settings stay) or everything saved (settings too) (default: the halts).
    • Resume ticket: a number socket (toolbox 1).
  • How it works: It clears only when its Resume ticket is higher than the last ticket it used (the first time, 1). Leaving it in the bot therefore does not keep wiping your limits. The Journal says what was cleared. It does not touch your trade history, totals or Persistent variables.
  • Example:
┌─ 1. Trade parameters ────────────────────────────────────────┐
│ Run once at start:                                           │
│   Clear saved rules: clear [ the halts, locks and pauses ▾ ] │
│   Resume ticket ( 2 )                                        │
└──────────────────────────────────────────────────────────────┘

If the last ticket used was 1, ticket 2 clears the saved halts once.

  • Good to know:
    • The ticket must be a whole number of 0 or more, or the bot stops with a message.
    • The block comes disabled, so it never clears anything by accident. Enable it only when you need it.

Statistics (blocks 42 to 44)

These blocks are value blocks: they give back numbers or lists that you plug into other blocks, such as an if or a stake box. They read the trades that have already settled, so they describe the past. They never predict the next trade and they never change your strategy by themselves. A run (also called a round) is one round of buying: a hedge or a multi purchase counts as one run, with its profits added up. A trade that ends at exactly 0 profit is break-even: a run, but neither a win nor a loss. With no trades yet, the answer is 0. Real trades and pretend (dry run) trades are never mixed: you choose which one to read.

Session stats

  • Kind: BRINOVS custom, block #42
  • Type id: bnv_session_stats
  • Shape: Value block (gives a number, or true/false)
  • Where it goes: anywhere a number is wanted (or a true/false, for the last field), inside the four main blocks. It can be used many times.
  • What it does: On the block it reads "Stats: (field)". It gives one statistic of your settled rounds for the scope you pick: this session, this bot, or today.
  • Inputs:
    • Stats: runs, wins, losses, break-even rounds, win rate (%), net profit or loss, profit factor, current streak (+ wins, - losses), longest winning streak, longest losing streak, average duration or enough runs? (true/false) (default runs).
    • scope: this session (since this run started), this bot (all kept records) (the last 5000 trades kept for this account) or today (UTC) (since 00:00 UTC). Default this session.
    • trades: real or pretend (dry run) (default real).
    • enough runs means at least: a whole number from 1 (toolbox 30).
  • Gives back: a number (a true/false for enough runs?).
  • How it works: Win rate is wins divided by runs, times 100. Profit factor is what the winning rounds made divided by what the losing rounds lost. It is "not a number" when there are wins and no losses. A streak is how many wins (+) or losses (-) came in a row; a break-even round ends it. Average duration uses the unit the trades were bought with (ticks, seconds and so on) and is "not a number" if the units are mixed. enough runs? is true when you have at least the number of runs you set: small samples mean little.
  • Example:
┌─ 2. Purchase conditions ───────────────────────────────────┐
│ if  < ( Stats: [ net profit or loss ▾ ]                    │
│        scope [ this session ▾ ]                            │
│        trades [ real ▾ ]                                   │
│        enough runs means at least ( 30 ) ) > ( -10 ) >     │
│ then  Purchase [ Rise ▾ ]                                  │
└────────────────────────────────────────────────────────────┘

The bot buys only while this session's net result is above -10. (The ">" in the middle is a Deriv compare block.)

  • Good to know:
    • The bot stops with a message if the minimum is not a whole number from 1 to 100000.
    • A statistic does not enforce a limit. To stop a bot after a loss, use a block that does (such as Session limits, or Stop or pause the bot).
    • Few runs say little: add the enough runs? field to your rule.

Rolling stats

  • Kind: BRINOVS custom, block #43
  • Type id: bnv_rolling_stats
  • Shape: Value block (gives a number)
  • Where it goes: anywhere a number is wanted, inside the four main blocks. It can be used many times.
  • What it does: Gives one statistic of only your most recent settled trades, for example the win rate of the last 20. You can narrow it to one market and one contract type.
  • Inputs:
    • Rolling stats: win rate (%), average result per trade, average win, average loss (as a positive number) or sample size (trades counted) (default win rate (%)).
    • over the last: a whole number of trades from 1 to 5000 (toolbox 20).
    • only market (empty = any): a text box, empty by default. Letters, digits and _, for example R_100.
    • only contract type (empty = any): a text box, empty by default. Written in capitals, for example DIGITOVER.
    • trades: real or pretend (dry run) (default real).
  • Gives back: a number. With no matching trades, 0.
  • How it works: The market and contract-type filters are applied first, then the last K of what is left. This block counts single trades, not rounds. Win rate is wins divided by trades, times 100. Average result per trade is the sum of the results divided by the number of trades. Average loss is shown as a positive number.
  • Example:
┌─ 2. Purchase conditions ───────────────────────────────────┐
│ if  < ( Rolling stats: [ win rate (%) ▾ ]                  │
│        over the last ( 20 ) trades                         │
│        only market (empty = any) [ R_100 ]                 │
│        only contract type (empty = any) [ DIGITOVER ]      │
│        trades [ real ▾ ] ) > ( 50 ) >                      │
│ then  Purchase [ Over ▾ ]                                  │
└────────────────────────────────────────────────────────────┘

The bot buys only if the last 20 real DIGITOVER trades on R_100 won more than half the time.

  • Good to know:
    • The bot stops with a message if the count is not a whole number from 1 to 5000, or the market or type is written wrongly (for example lower case letters in the type).
    • Ask for the sample size next to the other number: a win rate over 3 trades means almost nothing.
    • It describes history. It does not predict and it never changes your strategy on its own.

Trade history

  • Kind: BRINOVS custom, block #44
  • Type id: bnv_trade_history
  • Shape: Value block (gives a list)
  • Where it goes: anywhere a list is wanted, inside the four main blocks, for example in a Deriv list block. It can be used many times.
  • What it does: Gives a list of your last settled trades, oldest first and newest last. You can get whole rows, or just one column (all the profits, for example).
  • Inputs:
    • Trade history: the last (N) settled trades: a whole number from 1 to 500 (toolbox 20).
    • give me: a list of rows (time, market, type, stake, profit), a list of times (seconds), a list of markets, a list of contract types, a list of stakes or a list of profits (default: rows).
    • trades: real or pretend (dry run) (default real).
  • Gives back: a list. A row is [time in seconds, market, contract type, stake, profit]. An empty history gives an empty list.
  • How it works: It takes the settled trades of the kind you chose, keeps the last N, and gives them back as rows or as one column. The time is in seconds, not milliseconds. At most 500 trades are given, whatever the saved history holds.
  • Example:
┌─ 4. Restart trading conditions ──────────────────────────────┐
│ set [ recent ▾ ] to ( Trade history: the last ( 20 ) settled │
│       trades give me [ a list of profits ▾ ]                 │
│       trades [ real ▾ ] )                                    │
└──────────────────────────────────────────────────────────────┘

The variable holds the profits of the last 20 real trades. You can then use Deriv's list blocks, such as the sum of a list.

  • Good to know:
    • The bot stops with a message if N is not a whole number from 1 to 500.
    • It reads and describes. It buys or sells nothing and changes nothing.

Build a bot with these blocks

BRINOVS is free to open. Sign in with Deriv, open the Bot Builder, and try everything on a demo account.

Open BRINOVS

BRINOVS Digits is a free bot builder and trading page built on Deriv's Bot Builder. Trading carries risk and you can lose money. Nothing in this guide is financial advice or a promise of profit. Test every bot on a demo account first.

Guide home · Open BRINOVS