I hope this finds everyone in good health. I am working on an expert adviser, but it is giving me a headache. The expert adviser open similar
positions when stops or takeprofits are hit. That is, is a sell trade goes bad and hits a
stop
loss, the EA opens another trade immediately. Can anyone please lend me a code to prevent this. I have searched in the forum but I
could only find an MT4 code. I only work with MetaTrader5. Save a soul. Thank you in advance
- Flexible MetaTrader 5 trading system with all order types
- MQL5 Wizard: Development of trading robots for MetaTrader 5
- MetaTrader 5 Built-in Trading Strategy Tester
- <Deleted>
- You are looking at a signal. Act on a change of signal.
MQL4 (in Strategy Tester) - double testing of entry conditions - Strategy Tester - Expert Advisors and Automated Trading - MQL5 programming forum #1
Nelson Wanyama:
I hope this finds everyone in good health. I am working on an expert adviser, but it is giving me a headache. The expert adviser open similar positions when stops or takeprofits are hit. That is, is a sell trade goes bad and hits a stop loss, the EA opens another trade immediately. Can anyone please lend me a code to prevent this. I have searched in the forum but I could only find an nt4 code. I only work with MetaTrader5. Save a soul. Thank you in advance
This is might be to do with your code logic, not mt4/5 I hope this finds everyone in good health. I am working on an expert adviser, but it is giving me a headache. The expert adviser open similar positions when stops or takeprofits are hit. That is, is a sell trade goes bad and hits a stop loss, the EA opens another trade immediately. Can anyone please lend me a code to prevent this. I have searched in the forum but I could only find an nt4 code. I only work with MetaTrader5. Save a soul. Thank you in advance
After a sl or tp is hit, are the conditions for opening a trade still valid? Then of course a new trade will be made, unless your code does something to prevent it....for example, after a loss no trade for x bars or price not within x pts of stoploss...
andrew4789:
This is might be to do with your code logic, not mt4/5
Let me see if I can restrict trading if CurrentPrice is above HistoryDealClosePrice. This is might be to do with your code logic, not mt4/5
After a sl or tp is hit, are the conditions for opening a trade still valid? Then of course a new trade will be made, unless your code does something to prevent it....for example, after a loss no trade for x bars or price not within x pts of stoploss...
Please help me find a code to do this.
I just need the "if" statement

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