There is no such thing as a negative or zero stop loss. You either have a SL some pips away from your opening position or you don't.
The SL level is always lower from the opening price if its a buy position or higher if its a sell position.
There is no such thing as a negative or zero stop loss. You either have a SL some pips away from your opening position or you don't.
The SL level is always lower from the opening price if its a buy position or higher if its a sell position.
I mean while coding.
What happens if an error occurs and the value of "Stop Loss price" is a negative number?
For example SL = price - 10*ATR . And I am not checking if 10 times ATR is bigger then price
I mean while coding.
What happens if an error occurs and the value of "Stop Loss price" is a negative number?
For example SL = price - 10*ATR . And I am not checking if 10 times ATR is bigger then price
Why do not you check it out in the code? For example this is code for negative SL
ENUM_ORDER_TYPE otype = ORDER_TYPE_BUY_LIMIT;
double price = SymbolInfoDouble(_Symbol, SYMBOL_ASK) - 0.02;
if(Trade.OrderOpen(_Symbol, otype, Lot, 0, price, -0.22, 0, ORDER_TIME_SPECIFIED, TimeCurrent() + 3*60, "TestSpeed"))
and result
2017.02.07 15:19:27.207 TestSpeedTradeFunctions (EURUSD,M15) CTrade::OrderSend: buy limit 0.10 EURUSD at 1.04804 sl: -0.22000 [invalid stops]
2017.02.07 15:19:27.206 Trades '912389': failed buy limit 0.10 EURUSD at 1.04804 sl: -0.22000 [Invalid stops]
Why do not you check it out in the code? For example this is code for negative SL
ENUM_ORDER_TYPE otype = ORDER_TYPE_BUY_LIMIT;
double price = SymbolInfoDouble(_Symbol, SYMBOL_ASK) - 0.02;
if(Trade.OrderOpen(_Symbol, otype, Lot, 0, price, -0.22, 0, ORDER_TIME_SPECIFIED, TimeCurrent() + 3*60, "TestSpeed"))
and result
2017.02.07 15:19:27.207 TestSpeedTradeFunctions (EURUSD,M15) CTrade::OrderSend: buy limit 0.10 EURUSD at 1.04804 sl: -0.22000 [invalid stops]
2017.02.07 15:19:27.206 Trades '912389': failed buy limit 0.10 EURUSD at 1.04804 sl: -0.22000 [Invalid stops]
Thank you
Acctually this problem is not accuring. But it is possible
Now I know I should check it
![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
A very noobie question;
What happens if I use a negative SL at PositionOpen? (the order is sent anyway? It goes with a zero SL?)