Invalid Stops - page 3

 
Code2219 or probably 2319:
it prints 5.0000000 ?

Thanks for the lesson, it did.

 
Tha day that worked, by coincidence the price was "round" and stoploss could finishe with 0 or 5.
 
// get op as usual...
//bla bla bla
if(StopLoss>0) sl = SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_SIZE) * (int)round((op+StopLoss)/SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_SIZE));
 
Code2219 or probably 2319:

I Tried to change the sl as you said, and keep doing the same error:

 int type = (int)PositionGetInteger(POSITION_TYPE);
    double sl = PositionGetDouble(POSITION_SL), tp = PositionGetDouble(POSITION_TP), op = PositionGetDouble(POSITION_PRICE_OPEN);
    if (sl==0 && tp==0)
    {
      if (PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)
      {
        if (StopLoss!=0) sl = SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_SIZE) * (int)round((op-StopLoss)/SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_SIZE));
        if (TakeProfit!=0) tp = mysymbol.NormalizePrice(op + TakeProfit);
      }
      if (PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL)
      {
        if (StopLoss!=0) sl = SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_SIZE) * (int)round((op+StopLoss)/SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_SIZE));
        if (TakeProfit!=0) tp = mysymbol.NormalizePrice(op - TakeProfit);
      }
      if (sl!=0 || tp!=0) _res = trade.PositionModify(Symbol(), sl, tp);
    }
 
Do I need to add any library to round work?
 
Solved, Thanks Code2219 or probably 2319 !
 
Lucas Tavares:
Solved, Thanks Code2219 or probably 2319 !

invalid stop , caused too high value input

 
Siti Latifah:

invalid stop , caused too high value input

What?
My problem was because i was putting a stop between 2 pip, an unreachable value.
 
Lucas Tavares:
What?
My problem was because i was putting a stop between 2 pip, an unreachable value.

you right, invalid stop is an unreachable value.

can be too close or to far.

see below image

SL BUY> use BID

TP BUY> use ASK


slltp

 
Siti Latifah:

you right, invalid stop is an unreachable value.

can be too close or to far.

see below image

SL BUY> use BID

TP BUY> use ASK



You have a new point of view, nice! But I do believe that for the Brazil market, it won't change anything, bid and ask are 1 pip far normally.
But thanks! I'll try to see if it changes any point gain!