What code should I put in ea so that it executes one order at a time?

 

I created a robot but in the backtest it is making several orders at the same time on the same asset. How do I activate only one order at a time?

 
ricardo medeiros:

I created a robot but in the backtest it is making several orders at the same time on the same asset. How do I activate only one order at a time?

Does this issue occur only in backtest?

 
ricardo medeiros:

I created a robot but in the backtest it is making several orders at the same time on the same asset. How do I activate only one order at a time?

At a time? What did you mean by that? Bar?

 
ricardo medeiros:

I created a robot but in the backtest it is making several orders at the same time on the same asset. How do I activate only one order at a time?

https://www.mql5.com/en/forum/325580

One trade per bar...
One trade per bar...
  • 2019.11.02
  • www.mql5.com
Is there a simple way to get an EA to only open one trade per bar...
 
ricardo medeiros: I created a robot but in the backtest it is making several orders at the same time on the same asset. How do I activate only one order at a time?

Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the source file.
     How To Ask Questions The Smart Way. (2004)
          Be precise and informative about your problem

We can't see your broken code.

Fix your broken code.

Do you have a new bar test?

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)

Reason: