Michael Reuben Msidada:
I have known this error for years and I always handling it by checking freeze/stop zones then add a few pips as a breathing room then send the order.
I'm I missing something? Any help?
I have known this error for years and I always handling it by checking freeze/stop zones then add a few pips as a breathing room then send the order.
I'm I missing something? Any help?
On ECN brokers, the broker may not know, thus the functions return zero.
Your code then only uses one PIP.
William Roeder #:
On ECN brokers, the broker may not know, thus the functions return zero.
Your code then only uses one PIP.
So you think it okay to just ignore the
SymbolInfoInteger(pSymbol,SYMBOL_TRADE_STOPS_LEVEL)
and hardcode the stoplevel breathing room to may be 3 pips/30 points?
How you guys doing it?
I have handled the error by doing these modification for anyone wondering
// Adjust stop level double AdjustAboveStopLevel(string pSymbol, double pPrice, int pPoints = 10, int pStopLevel=50) { double currPrice = SymbolInfoDouble(pSymbol,SYMBOL_ASK); double point = SymbolInfoDouble(pSymbol,SYMBOL_POINT); double stopLevel = SymbolInfoInteger(pSymbol,SYMBOL_TRADE_STOPS_LEVEL) * point; double stopPrice; if(stopLevel>0){ // Incase broker stoplevel return 0 stopPrice = currPrice + stopLevel; }else{ stopPrice = currPrice + pStopLevel * point; Print("SymbolInfoInteger(pSymbol,SYMBOL_TRADE_STOPS_LEVEL) is returning 0, artificial StopLevel:", pStopLevel, " will be used instead."); } double addPoints = pPoints * point; if(pPrice > (stopPrice + addPoints)) return(pPrice); else { double newPrice = stopPrice + addPoints; Print("Price adjusted above stop level to "+DoubleToString(newPrice)); return(newPrice); } } double AdjustBelowStopLevel(string pSymbol, double pPrice, int pPoints = 10, int pStopLevel=50) { double bidPrice = SymbolInfoDouble(pSymbol,SYMBOL_BID); double point = SymbolInfoDouble(pSymbol,SYMBOL_POINT); double stopLevel = SymbolInfoInteger(pSymbol,SYMBOL_TRADE_STOPS_LEVEL) * point; double stopPrice; if(stopLevel>0){ // Incase broker stoplevel return 0 stopPrice = bidPrice - stopLevel; }else{ stopPrice = bidPrice - pStopLevel * point; Print("SymbolInfoInteger(pSymbol,SYMBOL_TRADE_STOPS_LEVEL) is returning 0, artificial StopLevel:", pStopLevel, " will be used instead."); } double addPoints = pPoints * point; if(pPrice < (stopPrice - addPoints)) return(pPrice); else { double newPrice = stopPrice - addPoints; Print("Price adjusted below stop level to "+DoubleToString(newPrice)); return(newPrice); } }

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
I have known this error for years and I always handling it by checking freeze/stop zones then add a few pips as a breathing room then send the order. Here are my codes:
That should solve the problem and that is what I have been used on other EAs that didn't trigger the error
Confusion:
What I'm confused is that the error when sending the buy order to the sell position which means, it is closing since they have the same size.
But I thought this error should not occur when closing a position, as the order is using the market price and with some allowed deviation, it should good.
Here are the closing codes:
I'm just calling the MQL5 trade.mqh library function CTrade::PositionClose(ticket)
I'm I missing something? Any help?