Double or Bust – Betfair Trading Bot for Horse Racing

From Cymatic Trader forum:

Is the following scenario possible?

I am looking at backing a named runner just before the off and then, after 5 - 10 seconds I would like the current price of that selection compared to the matched back price bet.

If X lower then place a lay at DOB, if not hedge.

Bfexplorer Solution:

First we should know what acronym DOB means.

DOB stands for “double or bust” it is a Betfair trading strategy used on the horse racing markets. The DOB Betfair strategy involves backing a horse pre race and having a lay bet matched in-play at half the odds of the initial stake.

So if you read once again what is asked on cymatic forum:“If X lower then place a lay at DOB, if not hedge.” , what is actually counterproductive as he wanted to leave his bet position open with lay bet when already in profit, otherwise hedge, so in loss.

I would paraphrase this strategy to following sentence: if in profit for X ticks then hedge the bet position otherwise leave bet position open with hedge bet open on my double liability profit price.

This betfair strategy can be setup without programming, just by setting up parameters for following bfexplorer bots:

Close Selection Bet Position at Odds

Cancel Bots on Selection

Sequence Execution

Place Bet and Close Selection Bet Position

If Then Else

Execute at Time

Concurrent Execution

Basically all those bot settings can be reused in other strategies so do not worry you will create a lot of bot settings. In my video the final bot executing this DO strategy is called: “My DOB trading strategy”

This series of my articles is more about betfair bot trigger programming, so I will show the same strategy programmed in betfair bot trigger:


If you think more about this strategy then you can find that utilizing “Execute Trigger Bot” features what we need to implement in bot trigger code are following procedures:

Checking the profit balance at set time span

Hedging bet position when at least in X ticks profit.

DOB bet position will be managed by our action bot executed by “Execute Trigger Bot”, parameter BotName, or of course we can place bet manually and then use just hedge feature in our bot trigger code.

Therefore I named the bot trigger:   Hedge or leave running.

What you can see in bot trigger code?

How to read/get custom defined values for your bot trigger, have a look at functions getTimeToCheckProfit or getMyProfitInTicks, lines: 30 or 33.

How to check bet position and recalculate it to ticks profit, function: shouldClosePositionForProfitOrLoss, lines 35 – 50.

How to cancel other action bot execution, the method: cancelMyActionBot, lines 52 – 60.

How to setup for execution the action bot, the line: 74, and how to execute it (ask “Execute Trigger Bot” for execution), the line:

How to setup bfexplorer bot and its parameters, the function: setupMyHedgeBot, lines 62 – 63, and how to execute it (ask “Execute Trigger Bot” for execution), the line: 93.

And finally how to declare TriggerStatus and how to use it in Execute function to set bot trigger status, of course this part can be implemented at least two other ways.

Try to modify the code, or just use some parts of the code in your bot triggers.