# Trailing Green-Up

Similar to trailing stop-loss, whereby you place a stop-loss bet after  the price has reached the maximum (or minimum) value and turned back, you can also do it with greening-up to maximise your profits and minimise risks.

Here's the goal: lay on a selection whose price has been growing up for some time, then wait till the price has reached the maximum point and started to fall. Place a greening-up back bet to close the position and secure the maximum profit. Also, if the price goes in the wrong direction, distribute loss evenly between selections and start the cycle again.

So what we will try to achieve in this example is a continuous laying then backing on certain selections who meet the following criteria:

- their price must have increased by more than 2 ticks over the last minute
- the selection must be among the first three favourites.
- the gap between the back and lay prices should not exceed 1 tick.

Take a look at the picture to the left. It demonstrates the kind of situation we are trying to catch with the triggers.

You can see that the price of "Chelsea" has been growing up to the point when it reached 9.6. Then it dropped to 7.6. This can be the right moment to place a closing bet to prevent bigger losses. Although you can't really predict where the price is going. That is why we've made triggers that can place both greening-up bets (if you're lucky) and stop-loss bets (if you're not) in the same cycle.

The file consists of two blocks. The first block contains triggers for setting up the values that you can modify. The first one is for the number of ticks by which the price should decrease before the program places the greening-up bet. The variable that holds this value is called "spread" and is initialised in a trigger called "setting spread value". For example, you layed on the second favourite, and its price has increased up to 5.0. If "spread" is equal to 4 (as in the example), then the trigger will place the back bet when the price has fallen down to 4.6 or below. The second trigger called "setting min. price growth in ticks" is for setting up the minimum value by which the price of the selection must have increased before the program starts laying on it.

The second block contains triggers for remembering the maximum back price of the selection it layed on, two triggers for placing back and lay bets, and a trigger for closing the block and making it repeat. Each time this block is repeated, the triggers may place bets on a different selection: i.e. first time on the favourite, then on the second favourite, then on the favourite again etc. That is why the variable "maxbp" should be computed anew in the beginning of each cycle.

Here's an example of how the triggers were betting in one of tonight's soccer match.

Pay attention to the fact that the first pair of bets were not profitable: MF Pro placed a stop-loss back bet at the price of 16.5, thus closing that cycle with a loss of £0.36. But later it completed two more cycles that both ended with profit. To compensate the possible loss that the selection might be exposed to, in the next cycle the trigger lays a bigger amount. E.g. in the picture above it layed 2.36 to partially cover the previous loss of £0.36.

I would say that these triggers will work well only in markets with high liquidity, porbably certain In-Play markets too (but be careful with short horse races). Experiment with them in Test Mode and choose the markets and trigger parameters that suit you best.

It is convenient to watch the variables that are set by the triggers to know where exactly your position is. See an example:

From the picture you can see that there is an open bet on "Little Lambseativy". The maximum back price that was registered for this selection is 4.1. The trigger will place a back bet as soon as its price falls down to 3.85 or below. The formula in the second row of the "View Variables" table is: