How to repeat actions in the same market
This is a case study on how to loop one or more operations on the same selection with the use of triggers. We will look at the ways to group actions in a block and repeat that block upon certain conditions.
Here is a typical example: lay on the second favourite, then green-up, and if all bets are matched, then repeat till the market’s start.
I will break this sentence in parts as I always do when I’m working on a trigger. Here are the actions that the triggers will perform:
- Lay on the second favourite
- Green-up the selection that was laid on
- Repeat the above if all bets are matched
Getting started
Let’s start with the simple part and implement the first two steps.
These triggers are fairly straightforward. If I activate them in a random horse race, here is what I will get:
Now let’s make the triggers place new bets and green them up repeatedly. This can be done by repeating the block of these triggers.
By default any block is repeated “just once”. It means that each trigger from that block has only one chance to fire in any given market (unless specified differently through the settings of an individual trigger). If you need one or more triggers to be repeated in the same market, potentially on the same selections, you will group these triggers in a block that will be repeated.
Looping the triggers
I will change the block’s Repeat property from “just once” to “no more often than 5 sec.”.
The words “no more often than 5 sec.” actually mean that the block can be repeated every 5 seconds or less frequently, depending on your market refresh rate.
A common mistake is to leave it as that, i.e. hoping that this is all that is needed for the triggers to repeat.
This is wrong, as you need to let the program know on what conditions the block must be repeated. To do this, I’m going to add a special trigger with the “close block” action.
When this trigger fires, all triggers in this block are reset to the initial state, where they are considered not executed yet. This will give them an opportunity to fire again, just what we need!
Let’s look at the third step of our task again:
Repeat the above if all bets are matched
So it is not enough to just repeat the actions, it is very important that we repeat only after all bets are matched, or rather, if there are no unmatched bets (otherwise it’ll just keep laying like crazy)! I’m adding this condition to the trigger.
Let’s try and see how it works!
Something went wrong, as it still is laying like crazy! The triggers seem to be ignoring my conditions!
In fact they aren’t. It is just not immediately clear that they are almost always true: even before the first bet is placed. No bets = no unmatched bets, the block is free to be repeated! After the first lay bet is placed, they are also true, as there are no unmatched bets, so way to go and place the next one, and so on.
Those conditions are not complete. When I formulated them on paper, I missed some important points which are usually taken for granted:
- Both lay and green-up triggers must fire before the new cycle of betting begins.
- The back payouts and lay liabilities of all selections must be balanced, i.e. there mustn’t be open positions on any selections.
Here’s how it should be:
This setup will bring to the desired result:
Resume
To sum up:
- You do not need to repeat a block of triggers if you only plan to bet once on any of the selections in a market;
- To repeat certain triggers, place them in a separate block and set that block’s “Repeat” property to “no more often than X mins”, where X is a number greater than the frequency of updating your bets, e.g. bets updated every 3 seconds, then triggers repeated every 5-6 seconds ;
- Formulate all the conditions upon which your triggers must be repeated. Add them all to a separate trigger and set its action to “close block”. Choose the name of the block that your triggers are within.
- It is recommended to add a delay to test bets, in order to simulate real bets more accurately: