The classic scalping in markets with a wide price gap
This is a classic scalping example for two scenarios:
1. Backing then Laying.
Back at the current lay price minus X ticks. As the bet starts to get matched (either all of it or parts of the bet), green up at Y ticks' profit, i.e. lay at Y ticks lower than the price of the back bet. If the market prices move either up or down, reposition the unmatched back bet at the new best lay price minus X ticks.
2. Laying then Backing.
Lay at the current back price plus X ticks. As the bet starts to get matched (either all of it or parts of the bet), green up at Y ticks' profit, i.e. back at Y ticks higher than the price of the lay bet. If the market prices move either up or down, reposition the unmatched lay bet at the new best back price plus X ticks.
For both scenarios: at a certain time before the off, cancel all unmatched bets and trade out all open bets at the current best prices.
Well before the start of an event, e.g. a horse race, there is a wide gap (difference) between the back and lay prices of selections. With time, the gap begins to narrow as bettors accept each other's offers. The scalping method aims to place bets as close to the current best price as possible, in the hopes that your bet will be matched first, and at a lucrative price. Basically, you aim to back at nearly the lay price or lay at nearly the back price and green up later.
Note: you can't run both scenarios at the same time, because if both back and lay bets are placed on a selection simultaneously, the triggers will get confused as to which of those bets are the initial ones and which are the green-up ones, so they might start to cancel and re-place green-up bets unnecessarily.
Disable one of the trigger blocks in favour of the other or add conditions that explicitly rule out that both scenarios place bets on the same selections. For example, you can let the "Backing then laying" block be applied to the first three favourites, and the "Laying then backing" block to all other selections.
You will find several constants in the file to adjust the triggers:
|mins_before_start||When to start betting, minutes before the off|
|min_gap||Minimum price gap (in ticks)|
|bet_size||Initial bet size for back and lay bets|
|greenup_tcks||Number of ticks for a green-up|
|offset_tcks||Number of ticks to offset the initial price. When you are backing first, this will be the number of ticks to offset against the current lay price. When you are laying first, this will be the number of ticks to offset against the current back price.|
|close_secs||When to trade out all unmatched bets, seconds before the off.|
|min_rank_back||Minimum selection rank for backing|
|max_rank_back||Maximum selection rank for backing|
|min_rank_lay||Minimum selection rank for laying|
|max_rank_lay||Maximum selection rank for laying|
The first condition in the backing and laying triggers is a stub, i.e. you can replace it with your own conditions or selection filters. Make sure you add them at the right place without disrupting the logic of the triggers. Here is where to press to add new conditions:
How it works
Here is the demonstration of what I mean for Scenario 1. The triggers for Scenario 2 work in an identical way, only the first bet to place is Lay. The number of selections on which you can bet simultaneously is not limited, i.e. you can place bets on multiple selections at the same time.
This is what happens as soon as part of the bet is matched and the market prices have moved away from the initial position:
At the specified number of seconds before the off, the triggers leave no unmatched or open bets in the market:
In a bid to learn how triggers work in general, let's look at one of the triggers here, "first backing", which places an opening back bet aiming to green it up later.
The trigger is set to be repeated no more often than once in 2 sec, and it has two actions:
- cancel then back. The Price is set to
r_ticks(lay_price, -offset_tcks). Here,
r_ticksis a function that adds the specified number of ticks in the second argument to the price in the first argument. We have
lay_pricefor the selection's lay price (internal variable) and
offset_ticksfor the number of ticks (a constant we defined in the triggers header). In other words, we back at the price that is
offset_tickslower than the selection's lay price.
The Amount of the bet is
bet_size - back_matched. Here,
bet_sizeis a constant for the initial size of bet, and
back_matchedis the total amount of your matched back bets on this selection. Why not just use
bet_size? Because we intend to be re-posting our bet at a new price once the market moves up or down. Some part of the bet can be matched at any time, and the rest of it may remain unmatched. To avoid placing the same amount over and over, we must deduct the amount that has been already matched.
- set user variable. We need this action to safely loop the trigger. It writes the current time into the variable
last_bl_time. Next time the trigger repeats its action, it will make sure to wait for several seconds since
last_bl_time, otherwise we risk producing a bunch of duplicate bets we don't need.
Let's open the trigger's conditions.
First comes a condition block. You probably remember that a block contains several conditions or nested condition blocks that are connected with an identical logical operator, such as "AND" or "OR."
- The selection's rank (e.g. 1 for first favourite, 2 - for 2nd favourite, and so on) must fall within the values defined in the constants.
- AND this trigger must not have placed bets in this market (i.e. running for the first time)
- The trigger has placed bets on this selection before. This condition insures you against the possible change of the selection's rank and falling out of the required range after some bets have already been placed on it.
- AND the price of the selection's latest unmatched back bet (internal variable
bu_backp) is no longer equal to the lay price minus
offset_tcks, i.e. the market has moved
- AND the lay offer at the current price is at least one
bet_sizegreater than what we placed as the initial bet (
back_unmatchedis the sum of unmatched back bets). We don't want to keep cancelling and re-placing our own bet, do we? Someone else must pour some money in at that price, and that's when the trigger will kick in and outplay them.
Second part of the conditions:
- If a mere penny remains till the intended
bet_size, we won't be pursuing that bet, as the exchange is not happy about you betting pennies
- AND the selection must have a sufficient gap between its back and lay prices (the number of ticks is
max_gap), otherwise scalping just won't work out, and instead bets will be placed at around current back and lay prices
- AND enough time must be left till the beginning of the event
- AND at least 3 seconds must pass since the last moment the trigger executed its actions. Now, remember the second trigger action "set user variable"? It comes into play now: the formula
(now_time – XXX)/mf_secondreturns the number of seconds that have passed since the time recorded in the variable XXX (insert the actual name of the variable). Each time the trigger "first backing" repeats, it sets
last_bl_timeto a new value of time, thus waiting out till the exchange registers our bet and updates all the variables that our calculations depend on.
This is just one trigger out of the multitude that can be created to fulfill betting strategies. Yet even breaking down one trigger into simple pieces gives you more clarity on how to approach common problems in online betting. Don't shy away from experimenting with the conditions on your own, play around with constants and check what come out of it.
For a safe testing environment without the risk for your account to be blocked by BetFair, use Time Machine.