Add a trade count and tell the buy/sell function to stop sending buy/sell orders when more than 1 trade is open.
I assume that if you have made the EA you will know how to do this. ;-)
Add a trade count and tell the buy/sell function to stop sending buy/sell orders when more than 1 trade is open.
I assume that if you have made the EA you will know how to do this. ;-)
Code is from codebase.
Trade count wont help because I need all trades to be open what comes from signal.
Code is from codebase.
Trade count wont help because I need all trades to be open what comes from signal.
I understand... however there are several ways to solve it, one of them as I have indicated (even if the EA is multi-symbol and you want it to continue working in other pairs).
As you may have seen on other occasions:
- People who can't code usually don't get free help on this forum, although it might happen if you are lucky. Be patient.
- If you show your attempts and describe your specific problem clearly, you will probably receive a response from the community.
- If you don't want to learn to code, that's not a problem. You can look at the CodeBase section where you will find free and open source code, or at the Market for paid products (also sometimes free). Finally, you also have the option of hiring a programmer in the Freelance section.
Found solution
if(iTime(m_symbol.Name(),m_working_period,0)==m_last_deal_in) // on one bar - only one deal return(true);
if(IsNewCandle()) ⋮ if(IsNewCandle()) ⋮ if(IsNewCandle())
You can't know when a candle closes. Only when a new tick arrives that starts a new bar is the old bar closed, and that tick could arrive almost at the end of a bar's duration.
For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
MT4: New candle - MQL4 programming forum #3 (2014)
MT5: Accessing variables - MQL4 programming forum #3 (2022)
I disagree with making a new bar function, because it can only be called once per tick (second call returns false). A variable can be tested multiple times.
Running EA once at the start of each bar - MQL4 programming forum (2011)
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I would like to get that EA to trade only one deal per signal but while testing this EA I noticed that sometimes it opens two trades at the same time or it opens a trade after signal and then another trade comes one bar later.