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
Documentation on MQL5: Trade Functions / HistorySelect
- www.mql5.com
HistorySelect - Trade Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
- 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
Launger :
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
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
Vladimir Karputov #:
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. 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; }
Launger # :
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.
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'!
OnTrade is called by multiple conditions.
sending, modifying or removing of a pending order; cancellation of a pending order with not enough of money or expiration; activation of a pending order; opening, adding or closing a position (or part of the position); modifying of the open position (change stops – Stop Loss and/or Take Profit).
Client Terminal Events - MQL5 programs - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
You multiply by 2 on every one, no just on trade closing.
Client Terminal Events - MQL5 programs - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register