Your question makes no sense. What does "Martingale" (which in this context, is about doubling your position's volume after a loss), have to do with break-even or trailing-stops?
Are you perhaps confusing it with "Grids" or same symbol hedging?
What ever the case, stay away from all three. You are just wasting money and setting yourself up to blow your account.
Forum on trading, automated trading systems and testing trading strategies
what's the cons of this strategy?
Fernando Carreiro, 2024.10.17 23:02
That is called "nedging" or hedging on the same symbol. That is a total waste of money and you pay twice the fees (spread, commission, etc.).
Having two positions open in the opposite direction is equivalent to cancelling each other out, and you can see that clearly on a "netting" account instead of a "hedging" account.
The correct way, is to simply wait for your confirmation of the trend and only then open the position.
Learn the maths ...
The martingale not only double size. the size increase compare to previous position.
example. on EU I buy lot 0.1 at 1.1000 and my TP is 1.2000. The price goes down and I buy 0.12 at 1.0900 set TP 1.2000. so when the price is going up I set BE 1.1000 for both position. wait the price hit TP or BE. that algorithm is possible to code it.
That is not called "Martingale". That is called "Averaging Down" or "Dollar-Cost Averaging".
Either way, yes it can be coded and I have already given you the equations to calculate that in the previous post #2.
- I repeat, it is not called "Martingale". Please call it the correct name.
- It does not matter if it is two or many positions. The calculations are the same.
- If you want help with your code, then you need to show your attempt at coding it so that we can help you identify the problem with it.
- If you don't know how to code the above equations in code, then you should consider hiring someone to code it for you.
Position 1: Volume 0.10, Price = 1.10000
Position 2; Volume 0.12, Price = 1.09000
Break-even price
= ( ( 0.10 * 1.10000 ) + ( 0.12 * 1.09000 ) ) / ( 0.10 + 0.12 )
= ( 0.11 + 0.1308 ) / 0.22
= 0.2408 / 0.22
= 1.09454545...
≈ 1.09455
The break-even price is 1.09455, not 1.10000
Position 1: Volume 0.10, Price = 1.10000
Position 2; Volume 0.12, Price = 1.09000
Break-even price
= ( ( 0.10 * 1.10000 ) + ( 0.12 * 1.09000 ) ) / ( 0.10 + 0.12 )
= ( 0.11 + 0.1308 ) / 0.22
= 0.2408 / 0.22
= 1.09454545...
≈ 1.09455
The break-even price is 1.09455, not 1.10000
Yes is BE 1.09455. but i'm want to add some profit on that including spread. now my developer is stuck the code. when i'm tested their coding for single entry update one by one. so i can see the result not really correct. we are fighting on that. he said no a such thing.
if the spread is changing, then, yes, it might not be possible to get the exact price, however, what is a few points in the long game? just add the number of profit that you want. But if the tp or sl is virtual or hidden, then, of course it is possible.
A varying spread will only affect it if there are positions in both directions, not when they are all in the same direction, which is the OP's case.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi All,
I would like to ask is it possible to create the code for martingale strategy with BE/trailing stop. is it possible to calculate the BE with min profit + trailing stop. and those calculation will update all the same symbol and position at the same time. is it possible and is it can test in the strategy tester or only live trading. can you the link for the guide as well.