Martingale Strategy: How do I average down price and take profit for all trades?
-
Hello, I am trying to create a martingale strategy that averages down the price if price move against my trade. However, I am unable to get the part on modifying take profits right.
For example:
Buy 1st order: 0.1 lot at price 32590.00, TP = 50 pips at price 32640.00
when price moves down by 100 pips, I will open a second order:
Buy 2nd order: 0.2 lot at price 32490.00
when price moves down by another 100 pips. I will open a third order:
Buy 3rd order: 0.4 lots at 32390.00total: 0.7 lots with average price 32447. Total TP should be (7x50 = 350) pips in total, or 50 pips above the average price.
How do put in the blocks to calculate average price for all lots and adjust TP for all trades to be 50 pips above the average price?
I am currently receiving invalid TP error in strategy tester based on my project here: https://fxdreema.com/shared/y3U6u7vfc
-
@dewberries I don't fully understand that '50 pips above the average' part. Didn't you say it should be 350 pips?
-
@l-andorrà yes for 0.07 lot in total volume, all my trades should collect 350 pips in total.
But all trades should close at the same TP which is 50 pips above the average buy price.
For example:
Trade 1: buy 0.01 lots at $1000, TP = $1050
Trade 2: buy 0.02 lots at $9900, TP = 50 pips above average buy price = ($1000 + 2x$900)/3 +50 = $983I will need to modify trade 1 TP to be $983 as well, same as trade 2.
Trade 3: buy 0.04 lots at $9800, TP = 50 pips above average buy price = ($1000 + 2x$900 + 4x$800)/7 + 50 = $907
At this point, i will need to modify TP for trade 1, trade 2 and trade 3 = $907
Trade 1 will close at: $907 - $1000 = -$93
Trade 2 will close at: ($907 - $900)x2 = +$14
Trade 3 will close at: ($907 - $800)x4 = +$428Total profit: $349, approximately 350 pips in total for 0.07 volume lots
-
@dewberries In that case you will need a specific block structure designed to find that average buy price. Once stored into a variable you can use the standard 'pips away distance' loop. However, please remember that any new open trade will modify that average price.
-
@l-andorrà Thank you for your reply!
I have tried to use ‘bucket of trades’ block to obtain the average price and adjust it by 50 pips.
However. The price modified for TP is not the average price + 50 pips, but instead 2x of average price + 50 pips.
Do you know why?
On a second problem, when I place the ‘modify stops’ block under ‘for each trade’, it only modifies the first trade TP and not the subsequent trades (eg, trade 2, trade 3). I need all previous trades to have TP modified together.
Would you be able to propose a solution for this?
-
@dewberries I recommend to create a variable just to find the average open price of all open tredes via 'For each trade' loop. Then a second 'For each trade' loop should calculate the 50 pips distance.
-
no se si afecte aca pero cuando hago un bot para btc tengo que poner tp en un orden diferete ejemplo en ves de poner 6 pip tengo que poner 6000 o 600 no recuerdo entonces talves te de error porque estas metiendo 50 pip y es muy poco para ese par prueba a poner 5000
-
@alan-paredes2 eso es porque no has actualizado el apartado de las pip size rules del bot. Lo tienes que hacer aquí:

Si en tu broker el BTC usa 2 dígitos supongo que tendrás que añadir la fórmula '0.01 = 0.1' o quizás '0.01 = 1'. Prueba los dos para asegurarte.