MarketInfo MODE_STOPLEVEL incorrect?

 
If I try to place an order with an initial stoploss at the MODE_STOPLEVEL (or MODE_STOPLEVEL +/- 1 Point for sell/buy), I get error #130 "Invalid stops".

But if I try 2* the stop level or even 1.5 * the stop level, the order is accepted.

I would assume that stoplevel alone, or at the worst case +/- 1 Point for sell/buy should have been sufficient.

Errors:
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,...,Ask-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point,...);
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,...,Ask-(MarketInfo(Symbol(),MODE_STOPLEVEL)+1)*Point,...);

Accepted:
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,...,Ask-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point*2,...);
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,...,Ask-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point*1.5,...);

I want every losing trade to lose a known maximum. I've seen orders lose more than a given maximum if no initial stoploss was set at OrderSend, because it never reaches OrderModify code in many samples.
 
If you're long, the market price to close the position is the Bid, not the Ask.

Try setting the stoploss to:
Bid-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point
 
Thanks.
 
something is definitely wrong. I.E.- testing GBPJPY, MODE_STOPLEVEL=15 (SPREAD=12), and EA opens LONG @232.76 - then it tries to trail the stoplevel and here it comes:
@233.06 (30 pips) - error 130
@233.27 (51 pips) - error 130
@233.24 (48 pips) - SET!

This not the one case. This is with all orders!!! For now modifying orders seems USELESS! Any comments? Thanks

or is the code so BAD?:
OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(newSL, Digits), OrderTakeProfit(), OrderExpiration(), Yellow)


 
double TMinStop( string order_symbol)
{
   return (( MarketInfo( order_symbol, MODE_STOPLEVEL) + 1.0) * 
      MarketInfo( order_symbol, MODE_POINT));
}

bool TValidMarketBuyLimit( string order_symbol, double new_price)
{
   return ( new_price <  ( MarketInfo( order_symbol, MODE_ASK) - TMinStop( order_symbol)));
}

bool TValidMarketSellLimit( string order_symbol, double new_price)
{
   return ( new_price >  ( MarketInfo( order_symbol, MODE_BID) + TMinStop( order_symbol)));
}

bool TValidMarketBuyStop( string order_symbol, double new_price)
{
   return ( new_price >  ( MarketInfo( order_symbol, MODE_ASK) + TMinStop( order_symbol)));
}

bool TValidMarketSellStop( string order_symbol, double new_price)
{
   return ( new_price <  ( MarketInfo( order_symbol, MODE_BID) - TMinStop( order_symbol)));
}
 
Thank you but the question is about already opened order not waiting orders.


LOL, the proper stoplevel sould be 16 for GBPJPY. And as you can see it fails to set the stoplevel for an open order which is 30pips in profit (OrderTakeProfit()=0 to simplify).
 
The distance will be same. If you can set waiting order you can move or modify any order with the same value.
 
I.e. you try to set Stop Level above current price for Long?
 
O, s***t am I so stupid?! Will never program anything with such a brain! LOL , Thanks all!
 
Don't mention it. Lol
Reason: