OnTrade() is working weird and strange.
- www.mql5.com
- Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6.
- EA modification
- wrong stop loss and take profit
Hello. I wanna implement Martingale strategy in my EA, after each losing trade the risk is multiplied by 2. However, after the first losing trade the risk multiplies by 64 and the EA stop working after that. Can someone expain what might go wrong? It's very important for me. Thanks
1. Insert the code correctly (using the button
). The first time I corrected your messages and pasted the code correctly.
2. Remember to reset the variable risk to its initial state
1. Insert the code correctly (using the button ). The first time I corrected your messages and pasted the code correctly.
2. Remember to reset the variable risk to its initial state
else if(profit1 >= 0) { risk = 0.01; }
Thanks for correcting. The variable risk is supposed to be reset to initial state with, so after the profitable trade the risk set to 1 percent. But the problem is that it does not multiply by 2, but 8 instead.
It only depends on your knowledge of mathematics.
You are not listening to me and you are making the same mistake: you are not resetting the variable risk to its original state.
Add: By the way, you need to multiply not by '2', but by '2.0'!
Client Terminal Events - MQL5 programs - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5