The same EA Some time can enter a trade with SL and TP, but some time it cann't

 

Hi,

I get a wired  problem recently, The same EA Some time  can enter a trade with SL and TP, but some time it cann't.

When I do the backtest,  at late night time, it seem better, it can enter trade with SL and TP, but other time it can not. It is the same EA.

Any body has the same problem? how do you fix it?

Thanks a lot.

 

Maybe, it's because the distance between the current price and the stops is not large enough.

If you are buying, the stop loss can't be defined higher than (bid - SymbolInfoDouble(symbol, SYMBOL_POINT)  * (SymbolInfoInteger(symbol,SYMBOL_TRADE_STOPS_LEVEL)).

And the take profit can't be defined lower than (bid + SymbolInfoDouble(symbol, SYMBOL_POINT) * (SymbolInfoInteger(symbol,SYMBOL_TRADE_STOPS_LEVEL)).

At the same way, if you are selling, then you sl can't be lower than (ask + SymbolInfoDouble(symbol, SYMBOL_POINT) * (SymbolInfoInteger(symbol,SYMBOL_TRADE_STOPS_LEVEL)).

And your take profit can't be higher then (ask - SymbolInfoDouble(symbol, SYMBOL_POINT) * (SymbolInfoInteger(symbol,SYMBOL_TRADE_STOPS_LEVEL)).

Of course, you have to consider that the bid and ask price can chance during the process. So I suggest to create a spare quantity, like 5, and add to SymbolInfoInteger(symbol,SYMBOL_TRADE_STOPS_LEVEL) when you are calculation the stops thresholds.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
 
Jin:

Maybe, it's because the distance between the current price and the stops is not large enough.

If you are buying, the stop loss can't be defined higher than (bid - SymbolInfoDouble(symbol, SYMBOL_POINT)  * (SymbolInfoInteger(symbol,SYMBOL_TRADE_STOPS_LEVEL)).

And the take profit can't be defined lower than (bid + SymbolInfoDouble(symbol, SYMBOL_POINT) * (SymbolInfoInteger(symbol,SYMBOL_TRADE_STOPS_LEVEL)).

At the same way, if you are selling, then you sl can't be lower than (ask + SymbolInfoDouble(symbol, SYMBOL_POINT) * (SymbolInfoInteger(symbol,SYMBOL_TRADE_STOPS_LEVEL)).

And your take profit can't be higher then (ask - SymbolInfoDouble(symbol, SYMBOL_POINT) * (SymbolInfoInteger(symbol,SYMBOL_TRADE_STOPS_LEVEL)).

Of course, you have to consider that the bid and ask price can chance during the process. So I suggest to create a spare quantity, like 5, and add to SymbolInfoInteger(symbol,SYMBOL_TRADE_STOPS_LEVEL) when you are calculation the stops thresholds.

 

thanks for your help.
 


I found that   the EA can enter trade with SL and TP  when the MT5 use this as a default folder,

C:\Documents and Settings\Owner\Application Data\MetaQuotes\Terminal\

But EA can not enter trade with SL and TP when is use the other one:

C:\Program Files\MetaTrader 5\MQL5\Experts

The MT5 change the default folder buy itself, normally when the time is after midnight or early in the morning, it choose the first one as default, but rest of time, it choose second one.

Can we choose default folder by ourselves? Why MT5 do that?

Thanks

Reason: