Official blocks: Purchase conditions (before purchase)
Guide to the Purchase conditions block, where the bot decides when to buy, plus the Purchase, Ask Price and Payout blocks that work inside it.
2. Purchase conditions is the second root block. It is where you tell the bot when to buy. In the Bot Builder menu these blocks sit under "Purchase conditions" (the Ask Price and Payout blocks sit in the Analysis group, under "Contract"). The bot runs this box after it has read the 1. Trade parameters block, and it runs it again on every new tick (a tick is one price update from the market) until a Purchase block buys a contract.
What can run inside it? The box accepts any block that makes a decision or reads a value: if and else blocks, comparisons, maths, variables, lists, tick and candle readings, indicators, the Ask Price and Payout blocks below, and the extra BRINOVS condition blocks. The one block that actually buys is Purchase. If your bot uses a "Tick analysis" block, that block runs on every new tick just before this box does.
A few words used here. A contract is one single trade. The stake is the money you put into it. The payout is the money Deriv pays you if it wins (it includes your stake). A proposal is Deriv's live price offer for a contract. A bot needs this box and at least one Purchase block inside it. If either is missing or switched off, the bot will not start.
2. Purchase conditions
- Kind: Official (Deriv)
- Type id:
before_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. It is mandatory, only one copy is allowed, and it cannot be deleted. A fresh Bot Builder already has it, with one Purchase block inside.
- What it does: Holds the rules for buying. When a Purchase block inside it runs, the bot buys that contract. If the rules say "not now", nothing is bought and the box runs again on the next tick.
- Inputs:
- One slot for a stack of blocks. Put Purchase blocks here, usually inside if blocks, so the bot only buys when your rule is true.
- How it works: The bot waits for a new tick, and also for live prices if your bot reads them (see Payout below). Then it runs the blocks in the box from top to bottom. If a Purchase block runs, the bot buys and moves on to the Sell conditions. If none runs, the bot waits for the next tick and runs the box again. The loop goes on until a purchase is made or you press Stop.
- Example: An example rule only: buy Odd when the last digit is 5 or more.
┌─ 2. Purchase conditions ─────────────────┐
│ if < ( Last Digit ) ≥ ( 5 ) > then │
│ Purchase [ Odd ▾ ] │
└──────────────────────────────────────────┘- Good to know:
- You can use several Purchase blocks in different branches, but only one buy happens per round.
- If the box has no Purchase block, the bot stops before it starts and the journal says "The Purchase block is mandatory and cannot be deleted/disabled."
- Stakes, durations and markets are not set here. They live in 1. Trade parameters.
Purchase
- Kind: Official (Deriv)
- Type id:
purchase - Shape: Action block (it ends a stack, so it has a notch on top only; nothing can go below it)
- Where it goes: Inside 2. Purchase conditions, on its own or under an if block. Outside that box it switches itself off. You can use it more than once, in different branches.
- What it does: Buys one contract of the type you pick, with the stake and duration from the Trade options block. This is the block that spends money.
- Inputs:
- Contract dropdown: the contracts allowed by the Trade Type and Contract Type chosen in 1. Trade parameters (for example Rise or Fall, Even or Odd, Over or Under). With "Both" you see both sides; otherwise only the one side.
- How it works: The bot sends the buy order to Deriv and waits for the answer. When the order is accepted, it writes the purchase in the journal and moves on to the Sell conditions. A second Purchase in the same round is ignored. If the connection drops or Deriv asks the bot to slow down, the bot waits and tries again. If the price moved, what happens depends on the "Restart buy/sell on error" tick box.
- Example: Buy Rise on every round.
┌─ 2. Purchase conditions ─────────────────┐
│ Purchase [ Rise ▾ ] │
└──────────────────────────────────────────┘- Good to know:
- Use a demo account while you test. Every Purchase spends your stake.
- If a BRINOVS switch or safety block is in your bot, it is checked before the order is sent and can change or refuse the purchase. For example, with the Hedge switch on, the bot also buys the opposite contract.
- The dropdown refills when you change the trade type or contract type. Check it after any change.
- Buying is not a promise of profit. Each contract can lose the whole stake.
Ask Price (Purchase price)
- Kind: Official (Deriv)
- Type id:
ask_price - Shape: Value block (gives a number)
- Where it goes: Anywhere a number is wanted inside 2. Purchase conditions (for example in a comparison). Deriv says it should be used only in that box. It can be used as often as you like.
- What it does: Gives the price Deriv is asking right now for the contract you pick. You can use it to buy only when the price is acceptable.
- Inputs:
- Contract dropdown (the same list as in the Purchase block). On the block it reads "Ask Price" followed by the contract.
- Gives back: A number: the current ask price (the cost to buy) for that contract, in your account currency.
- How it works: The bot looks up the live proposal for the contract you picked and returns its ask price. The proposal must be for the same trade options as the current round, so a change of stake or duration gives a fresh price.
- Example: Buy only if the price is 1 or less.
┌─ 2. Purchase conditions ───────────────────────┐
│ if < ( Ask Price [ Rise ▾ ] ) ≤ ( 1 ) > then │
│ Purchase [ Rise ▾ ] │
└────────────────────────────────────────────────┘- Good to know:
- In the code, only the Payout block switches on live prices for the bot. Ask Price on its own may find no price, so use it together with a Payout block.
- If no live price is ready for the contract, the block cannot give a number and the bot reports an error.
- It shows the price at the moment the box runs. The price can change on the next tick.
Payout (Potential payout)
- Kind: Official (Deriv)
- Type id:
payout - Shape: Value block (gives a number)
- Where it goes: Anywhere a number is wanted inside 2. Purchase conditions. Deriv says it should be used only in that box. It can be used as often as you like.
- What it does: Gives the payout Deriv offers right now for the contract you pick, which is the money you would get back if the contract wins. You can use it to skip rounds where the offer is too small.
- Inputs:
- Contract dropdown (the same list as in the Purchase block). On the block it reads "Payout" followed by the contract.
- Gives back: A number: the potential payout, in your account currency. It includes the stake.
- How it works: When this block is in your bot, the bot asks Deriv for live proposals (price offers) for your contracts and keeps them up to date. The block looks up the proposal for the contract you picked and returns its payout. The bot also waits until the first offers have arrived before it runs Purchase conditions.
- Example: Buy only when a win would pay at least 1.9 for a stake of 1.
┌─ 2. Purchase conditions ─────────────────────┐
│ if < ( Payout [ Odd ▾ ] ) ≥ ( 1.9 ) > then │
│ Purchase [ Odd ▾ ] │
└──────────────────────────────────────────────┘- Good to know:
- This is the block that switches on live prices for the whole bot. It also makes the Purchase block buy at the offered price.
- If there is no offer for the contract, the block cannot give a number and the bot reports an error.
- A high payout does not make a win more likely. It only tells you what a win would pay.