Download MetaTrader 5
To add comments, please log in or register
Copy the deals of successful traders. Subscribe to signals!
Dannoo007
195
Dannoo007 2015.11.14 22:03 

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!");
                  }
Keith Watford
Moderator
8028
Keith Watford 2015.11.14 22:51  

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  

/
To add comments, please log in or register