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:

  1. Lay on the second favourite
  2. Green-up the selection that was laid on
  3. Repeat the above if all bets are matched

Getting started

Let’s start with the simple part and implement the first two steps.

Simple triggers for laying and greening up

These triggers are fairly straightforward. If I activate them in a random horse race, here is what I will get:

How triggers place bets

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.

Changing the way a block of triggers is repeated

Looping the triggers

I will change the block’s Repeat property from “just once” to “no more often than 5 sec.”. 

Repeating a block of triggers

Tip: always set the repetition frequency to a value that is greater than the frequency of updating your bets (Betting Options -> Update list of bets every … sec). So if bets are updated every 3 sec, it is important that the block is repeated no more often than 4 seconds or slower. Your triggers must wait for the latest bets to arrive!

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.

Trigger for closing the block and repeating the bets

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.

Specifying the conditions on which the triggers will loop

Let’s try and see how it works!

Wrong trigger conditions can lead to unpredictable results

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:

Tip: never ever take anything for granted. Always meticulously specify all your conditions.

Here’s how it should be:

Correct conditions for looping green-up triggers

This setup will bring to the desired result:

How correct triggers perform in a market

Resume

To sum up: 

  1. 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;
  2. 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 ;
  3. 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.
  4. It is recommended to add a delay to test bets, in order to simulate real bets more accurately:
    Delaying test bets
If you have not heard of BetFair yet or do not have an account, register today and get £20 free. Use the link below:
New customers only, bet up to €/£20 on the Exchange and if your first bet loses, we’ll refund you €/£20 in Cash. Bet must be placed in first 7 days of account opening. T&Cs apply.
Gamble responsibly! Always be aware that betting is NOT risk-free. You must be 18+ years old before you try gambling, but even as an adult, withhold from spending money in an ill-judged manner. Our company does not encourage you to prefer gambling over other meaningful activities. If gambling is affecting your life or the lives of people close to you, please contact GamCare
 
© 2005-2024 WellDone Creative Software. All rights reserved. Terms and conditions.
BetFair® and the BetFair Logo are registered trade marks of Flutter Entertainment plc. Gamble responsibly.