ordermodify stoploss at wrong value

 

HI,

ik got a double variable named bebuy which has the number 10 in it.

I want to use the following to modify the stoploss, but somehow instead of Ask-bebuy(=Ask-10 pips), it puts the SL maybe 200 pips lower?

I believe i use something wrong in the syntax, but can't see it. Who can help me with this?

void breakevenbuy()
{
for (int x = OrdersTotal()-1;x>=0;x--)
{
 OrderSelect(x,SELECT_BY_POS);
 {
  if (OrderType()==OP_BUY && OrderMagicNumber() == Magic) 
  {
   while(IsTradeContextBusy()) Sleep(100);
   OrderModify(OrderTicket(),OrderOpenPrice(),Ask-bebuy*pips2dbl,NULL,0,CLR_NONE);
  } 
 }
} 
CloseSell();
}
 

I think

1) OrderSelect takes 3 parameters in this context.

2) pips2dbl is probably wrong for this broker.

 
taesong:

I think

1) OrderSelect takes 3 parameters in this context.

2) pips2dbl is probably wrong for this broker.


1) i have changed it into OrderSelect(x,SELECT_BY_POS, MODE_TRADES); but no difference. the SL is somehow set 120pips below, instead of 10 (for example)

2) pips2dbl is correct working in same way with other ea's i made. it's just to adjust for my 5 digit broker (go markets). Got it once from WHRoeder i think.

if (Digits == 5 || Digits == 3)
   {    // Adjust for five (5) digit brokers.
               pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
   } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; 
 

can't tell without seeing the entire codes.

 

agreed. Are you sure about the 10? Any init() containing x *= y;

OrderSelect takes 3 arguments, the 3rd has a default = mode_trades.

Should always test return codes.
  1.     for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
            OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
        &&  OrderMagicNumber()  == magic.number             // my magic number
        &&  OrderSymbol()       == Symbol() ){              // and my pair.
    
  2. if (!OrderModify(OrderTicket(),OrderOpenPrice(),Ask-bebuy*pips2dbl,NULL,0,CLR_NONE))
        Alert("OrderModify failed: ", GetLastError());

 
WHRoeder:

agreed. Are you sure about the 10? Any init() containing x *= y;

OrderSelect takes 3 arguments, the 3rd has a default = mode_trades.

Should always test return codes.


Thans for the reply, i have sent the whole EA code to you. Hope you can see the fault in there.
Reason: