Official blocks: Restart trading conditions (after purchase)
Guide to the Restart trading conditions block, where the bot decides to trade again, plus Trade again, Result is and Contract Details blocks.
4. Restart trading conditions is the fourth and last root block. It is where you tell the bot what to do when a contract is finished: look at how it went, change your settings if you want, and decide whether to trade again. In the Bot Builder menu the root block and Trade again sit under "Restart trading conditions". The two helper blocks, Result is and Contract Details, sit in the Analysis group, under "Contract".
The bot runs this box once, right after a contract has ended (it either ran to its end or you sold it early in Sell conditions). Inside, the bot reads your blocks from top to bottom. If it reaches a Trade again block, a new round starts: the bot reads the Trade options block again, then goes back to Purchase conditions. If it never reaches Trade again, the bot stops. So a bot without a Trade again block trades only once.
Two words used here. A contract is one single trade. The stake is the money you put into it. Because the Trade options block is read again at the start of every round, any variable you change in this box (for example your stake) takes effect on the next round.
4. Restart trading conditions
- Kind: Official (Deriv)
- Type id:
after_purchase - Shape: Root block (a big box with no notch above or below; other blocks go inside it)
- Where it goes: On its own on the workspace. Only one copy is allowed. A fresh Bot Builder has one, with a Trade again block inside.
- What it does: Holds the rules that run after each finished contract. You can look at the result, update variables, check your own limits, and then let the bot trade again or stop.
- Inputs:
- One slot for a stack of blocks. Typical content: if blocks with Result is or Contract Details, blocks that set variables, and the Trade again block at the end.
- How it works: When a contract has ended, the bot runs the blocks in this box once. If a Trade again block runs, the bot goes straight to the next round. If the end of the box is reached without a Trade again block, the bot stops itself. A Trade again inside an if only runs when that if is true.
- Example: Trade again after every contract, with the stake back to 1 after a win.
┌─ 4. Restart trading conditions ──────────┐
│ if < Result is [ Win ▾ ] > then │
│ set [ stake ▾ ] to ( 1 ) │
│ Trade again │
└──────────────────────────────────────────┘- Good to know:
- This box is the place for your stop rules. If you leave out Trade again when a limit is reached, the bot ends the run.
- It runs once per finished contract, not on every tick.
- BRINOVS adds more blocks made for this box (see the BRINOVS part of this guide).
Trade again
- Kind: Official (Deriv)
- Type id:
trade_again - Shape: Action block (it ends a stack, so it has a notch on top only; nothing can go below it)
- Where it goes: Inside 4. Restart trading conditions, at the end of a stack or at the end of an if. Outside that box it switches itself off. You can use it more than once, in different branches.
- What it does: Tells the bot to start another round. Without it, the bot stops after the contract.
- Inputs:
- None. It has no boxes to fill.
- How it works: When the bot reaches this block, it marks "trade again" and leaves the Restart trading conditions box at once. The blocks after it, if any, are skipped. Then the next round begins: the bot reads the Trade options block and goes back to Purchase conditions.
- Example: Trade again only after a win.
┌─ 4. Restart trading conditions ──────────┐
│ if < Result is [ Win ▾ ] > then │
│ Trade again │
└──────────────────────────────────────────┘- Good to know:
- In the example above the bot stops after a loss, because Trade again is not reached.
- Deriv's wording: it transfers control back to the Purchase conditions block.
- It works at any depth, so you can put it inside nested if blocks.
Result is (Last trade result)
- Kind: Official (Deriv)
- Type id:
contract_check_result - Shape: True/false block
- Where it goes: Anywhere a true/false answer is wanted inside 4. Restart trading conditions, most often in an if. If you drop it in another root block (for example Purchase conditions), it switches itself off. It can be used as often as you like.
- What it does: Checks how your last contract ended: with a win or with a loss.
- Inputs:
- Result dropdown: Win or Loss. On the block it reads "Result is" followed by the choice.
- Gives back: True when the last contract's result matches your choice. Otherwise false.
- How it works: The bot looks at the finished contract. It works out the profit (what the contract paid out minus what you paid). A profit below 0 is a "loss". Anything else, including exactly 0, counts as a "win". Then it compares with your choice.
- Example: Do something only after a loss.
┌─ 4. Restart trading conditions ──────────┐
│ if < Result is [ Loss ▾ ] > then │
│ Trade again │
└──────────────────────────────────────────┘- Good to know:
- It always talks about the last finished contract.
- A contract sold early counts by its profit too.
- If you use it before any contract has finished, there is nothing to check yet.
Contract Details
- Kind: Official (Deriv)
- Type id:
read_details - Shape: Value block (gives a number, text or other value, depending on your choice)
- Where it goes: Anywhere a value is wanted inside 4. Restart trading conditions. Outside that box it switches itself off. It can be used as often as you like.
- What it does: Reads one fact about your last finished contract, such as the profit or the exit price.
- Inputs:
- Detail dropdown: deal reference id, purchase price, payout, profit, contract type, entry spot time, entry spot price, exit spot time, exit spot price, barrier, result. On the block it reads "Contract Details:" followed by the choice. A spot is the market price at a moment.
- Gives back: Numbers for reference id, purchase price, payout, profit, entry and exit spot price, and barrier (0 if the contract had no barrier). Text for contract type, result ("win" or "loss"), and the two spot times (shown as hours:minutes:seconds). "payout" is the amount paid back to you when the contract ended.
- How it works: The bot takes the finished contract's record from Deriv and picks the item you chose. The profit is the payout minus the purchase price, rounded to your currency's decimals.
- Example: Keep the profit of the last contract in a variable.
┌─ 4. Restart trading conditions ──────────┐
│ set [ last profit ▾ ] to │
│ ( Contract Details: [ profit ▾ ] ) │
│ Trade again │
└──────────────────────────────────────────┘- Good to know:
- It always talks about the last finished contract.
- Use it for records and rules. It does not change anything by itself.