double (in global scope) - odd behaviour OP_BUY vs OP_SELL

 

Hello forum,

Something rather odd is happening, I have this simple order modify for the stoploss (see below).

The ADJ in ADJ*Point() is defined as a double on global scope. I am looking at ADJ values of 1 and fractions, say 0.5 (point).

The order modification works fine with the Buy orders, both for .5 and 1 pip, but only with 1 on the Sell side. I also tried dividing by /2, etc. it just doesn't want to hear about 0.5 or other fractional pips.

Any idea/explanation for this? Are there known issues for fractional doubles declared in scope, with OP_BUY vs OP_SELL??

Many thanks in advance!

Dan

 

if (Some_condition) { 
      
            for (int ibuy = OrdersTotal()-1; ibuy >=0; ibuy--){
            if( OrderSelect(ibuy, SELECT_BY_POS, MODE_TRADES) && OrderSymbol()== symbol && OrderMagicNumber()== magic && OrderType() == OP_BUY)
              {if (OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss() + ADJ*Point(),0,Red)) {Alert ("OK");}
                  else Alert ("WTF!");
                  }   


if (Some_condition) { 
      
            for (int isell = OrdersTotal()-1; isell >=0; isell--){
            if( OrderSelect(isell, SELECT_BY_POS, MODE_TRADES) && OrderSymbol()== symbol && OrderMagicNumber()== magic && OrderType() == OP_SELL)
              {if (OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss() - ADJ*Point(),0,Red)) {Alert ("OK");}
                  else Alert ("WTF!");
                  }
 

It is not clear from your post whether the order modify is failing or whether it is modified by an unexpected amount.

It doesn't matter whether it is a buy or a sell, it is not possible to modify by a fraction of Point() as Point() is the smallest possible  

Reason: