I also saw the videos of ALR and I believe it is a very valuable strategy that I actually thought of before and did all the math for it a few month back. But unfortunately I don't know how to write MQL, and doing the trades manually is a big risk if you make any errors or enter wrong orders, so I parked it aside.
But I am glad to see in this forum there is some like minded people, so lets work together on creating an EA for that, we could all even agree to donate something for whoever volunteers for it. Better than everyone of us paying 2k
The only difference between my idea and the ALR in the videos is that it is a good idea to have seperate TP levels on each side of the trade so you can set it to a logical level like support or resistance that is a multiple of ATR away. Price is more likely to hit these levels and thus it would reduce the number of opened legs to close all the trade at BE.
The TP levels are "virtual" meaning that they will only be used for calculations, rather than actually set on the trades.
The trade is closed based on net profit of all positions when it reaches a preconfigured value. (basket trade)
I will attempt to outline all the math and logic needed to code the EA based on some previous programming experience.
Below are the variables that would be an input for the EA A = original Position size
P0,1,2,3..n = ALR trades in direction of original trade
p = TP distance in pips in direction of original trade set at logical value
H0,1,2,3..n = ALR trades hedging the original trade
h = TP distance in pips in OPPOSITE direction of original trade set at logical value
Z = ALR zone which is where we would put SL
C = Target profit in $ (this would be set to a small value to offset swap and rounding)
S = Spread (EA could read current thread from chart)
The formula for first ALR position in hedge direction is calculated based on that when price reached the TP value of the hedge position, the NET profit would be "C" $
H0 (s+h) - A (z+h) = C ---> H0 = [ A(z+h) + C]/ [s+h]
Formula for second ALR trade in direction of original trade using same logic as above:
(P0+A) (p+s) - H0 (z+p+s) = C ---> P0 = [(H0 (z+p+s) +C )/ (p+s) ] - A
Using the same logic for subsequent ALR trades:
H1 = {[(P0+A)(z+h) + C]/[s+h]} - H0
P1 = {[(H1+H0)(z+h+s) + C]/[p+s]} - P0 -A
etc...
General formula is:
H(n) = {[(sum(existing P positions)(z+h) +C]/[s+h]} - sum(existing H positions)
P(n) = {[(sum(existing H positions)(z+h+s) + C]/[p+s]} - sum(existing P positions) - A
Using this formula the EA could calculate the ALR position sizes one by one referencing the previous position sizes.
If original position was BUY then H positions would be sell and P positions would be buy
If original position was SELL then H positions would be buy and P positions would be sell
When the price crosses on ALR boundary, the EA checks the total position size in each direction.
If the total position size in the opposite direction is greater than the total position size in the direction the price is moving, the next ALR trade is opened in the following order
H0, P0, H1, P1, H2, P2, H(n), P(n)
Exposure can be calculated by simply adding all P positions + original positions MINUS H positions
The EA then has all the values needed to get attached to the chart and start working.
We could also print out the projected position values as showed in the videos.
The EA keeps monitoring the net profit of the open trades on that pair and once it reaches the preset value C all positions are closed. Although the closing is based on net profit, the TP/SL levels could be inserted as a safety net in case the EA stops working or the chart is closed.
One thing to note is that one the EA is attached to the chart it should not be touched once the first ALR trade is opened, and no values should be changed as it will mess up all the previous calculations.
Please let me know what you think and if this is enough details too code an EA.
Cheers