I am getting too many error "Faied Modify [Invalid Stop] " in BreakEven Source code

 

Sir,

I have 20 StopLevel & 19 Spread in OctaFX Broker.

I am getting too many error "Invalid Stop".....(Please see this Attached Photo

What am I wrong this Source code ?

//+------------------------------------------------------------------+
//|     Breakeven Gain & Breakeven                                   |
//+------------------------------------------------------------------+
void BreakEven(string Symbol_param, int Magic_1, int slippage_1, double Input_BreakevenGain, double Input_Breakeven)
  {
   for(int i = PositionsTotal() - 1; i >= 0; i--)
     {
      ulong Position_Ticket = PositionGetTicket(i);
      string Check_Symbol = PositionGetString(POSITION_SYMBOL);
      long Pos_Magic = PositionGetInteger(POSITION_MAGIC);
      
      if(PositionSelectByTicket(Position_Ticket) && Check_Symbol == Symbol_param && Pos_Magic == Magic_1)
        {
         ENUM_POSITION_TYPE Position_Type = (ENUM_POSITION_TYPE) PositionGetInteger(POSITION_TYPE);
         double Price_Current = PositionGetDouble(POSITION_PRICE_CURRENT);
         double Price_Open = PositionGetDouble(POSITION_PRICE_OPEN);
         double Position_SL = PositionGetDouble(POSITION_SL);
         double Position_TP = PositionGetDouble(POSITION_TP);
         
         double Breakeven_SL = MathMax(SymbolInfoInteger(Symbol_param,SYMBOL_TRADE_STOPS_LEVEL) * point,Input_Breakeven);
         double BreakevenGain_SL = MathMax(SymbolInfoInteger(Symbol_param,SYMBOL_TRADE_STOPS_LEVEL) * point,Input_BreakevenGain);
         

         if(Position_Type == POSITION_TYPE_BUY)
           {
            if(Price_Current - Price_Open > BreakevenGain_SL)
              {
               if(Position_SL < Price_Open || Position_SL == 0.0)
                 {
                  if(!Mql_Modify_Breakeven(Symbol_param, Magic_1, slippage_1, Position_Ticket, Position_TP, Price_Open + Breakeven_SL))
                    {
                     Print("Buy Order Price = ", Price_Open, ", BreakEven Failed");
                    }

                 }
              }
           }
         else
            if(Position_Type == POSITION_TYPE_SELL)
              {
               if(Price_Open - Price_Current > BreakevenGain_SL)
                 {
                  if(Position_SL > Price_Open || Position_SL == 0.0)
                    {
                     if(!Mql_Modify_Breakeven(Symbol_param, Magic_1, slippage_1, Position_Ticket, Position_TP, Price_Open - Breakeven_SL))
                       {
                        Print("Sell Order Price = ", Price_Open, ", BreakEven Failed");
                       }
                    }
                 }

              }
        }
     }
//---
  }


I am using System Function ..

//+--------------------------------+
//|  BreakEven & BreakEven Gain    |
//+--------------------------------+
bool Mql_Modify_Breakeven(string Symbol_Param, int Magic_1, int slippage_1, ulong Position_Ticket, double modify_TP, double modify_SL)
  {
   MqlTradeRequest Modifyrequest = {};
   MqlTradeResult Modifyresult = {};

   double Ask = SymbolInfoDouble(Symbol_Param, SYMBOL_ASK);
   double Bid = SymbolInfoDouble(Symbol_Param, SYMBOL_BID);

   ENUM_POSITION_TYPE Pos_type = (ENUM_POSITION_TYPE) PositionGetInteger(POSITION_TYPE);
   double Pos_Volume = PositionGetDouble(POSITION_VOLUME);

   Modifyrequest.symbol = Symbol_Param;
   Modifyrequest.action = TRADE_ACTION_SLTP;
   Modifyrequest.position = Position_Ticket;
   Modifyrequest.volume = Pos_Volume;
   Modifyrequest.deviation = slippage_1;
   Modifyrequest.magic = Magic_1;
   Modifyrequest.sl = modify_SL;
   Modifyrequest.tp = modify_TP;

   if(!MyOrderSend(Modifyrequest, Modifyresult))
     {
      Print("Mql Modify BreakEven is Failed");
      return false;
     }

   return true;
  }
Files:
 

Sir,

I used One Symbol but There is no more error in BreakEven.

If I used Multi Symbol but I am getting too many error "Falied Modify Invalid Stop" in  BreakEven.

 
Vikram J U #:

Sir,

I used One Symbol but There is no more error in BreakEven.

If I used Multi Symbol but I am getting too many error "Falied Modify Invalid Stop" in  BreakEven.

i do not see any definition of "point". maybe you have not selected the different symbol for the point(s)?

 
Revo Trades #:

i do not see any definition of "point". maybe you have not selected the different symbol for the point(s)

Sorry Sir,

I removed this code "Breakeven_SL" & I changed this code in "BreakevenGain_SL"  but there is no more error in BreakEven.

double Breakeven_SL = MathMax(SymbolInfoInteger(Symbol_param,SYMBOL_TRADE_STOPS_LEVEL) * point,Input_Breakeven); //  Removed this Source code
double BreakevenGain_SL = MathMax((SymbolInfoInteger(Symbol_param,SYMBOL_TRADE_STOPS_LEVEL)+Spread) * point,Input_BreakevenGain); //Changed "Stoplevel + Spread"

It works very well..

Thanks

 
Vikram J U #:

Sorry Sir,

I removed this code "Breakeven_SL" & I changed this code in "BreakevenGain_SL"  but there is no more error in BreakEven.

It works very well..

Thanks

what i meant was:

What do "point" and Spread mean? what are their values?

If point is not changed for each symbol, then you will get errors, maybe not all the time, but a lot of the time.

show the lines that you have for "point". You have not posted all the lines that we need to see.

         double Breakeven_SL = MathMax(SymbolInfoInteger(Symbol_param,SYMBOL_TRADE_STOPS_LEVEL) * point,Input_Breakeven);
         double BreakevenGain_SL = MathMax(SymbolInfoInteger(Symbol_param,SYMBOL_TRADE_STOPS_LEVEL) * point,Input_BreakevenGain);
    

see where you have * point, Input_Breakeven);

"point" is not defined or given a value til here. You must have it defined earlier in the code that you did not show.

 
Revo Trades #:

what i meant was:

What do "point" and Spread mean? what are their values?

If point is not changed for each symbol, then you will get errors, maybe not all the time, but a lot of the time.

show the lines that you have for "point". You have not posted all the lines that we need to see.

see where you have * point, Input_Breakeven);

"point" is not defined or given a value til here. You must have it defined earlier in the code that you did not show.

Sir,I have "point" code  because There are different 5 Digits or 4 Digits Broker 

Please see this Code :-

// Point
double point = 0 ;
int OnInit()
  {
        //Digits
   int digits = 1;
   if(Digits() == 3 || Digits() == 5)
     {
      digits = 10;
      point = Point() * digits;
     }
   else
      if(Digits() <= 2 || Digits() == 4)
        {
         digits = 10;
         point = Point() * 1;
        }
return(INIT_SUCCEEDED);
}
 
Vikram J U #: Sir,I have "point" code  because There are different 5 Digits or 4 Digits Broker. Please see this Code :-

No! A "point" is a "point" and should not be changed. Don't confuse "points" with "pips".

The Stops Level is expressed in "points", not "pips". Don't try to change the definition.

Use either the variable "_Point" or the function "Point()". Don't adjust it.

For multi-symbol EAs, you will need to obtain the point size for the symbol using the SymbolInfoDouble function and the "SYMBOL_POINT".

 
Vikram J U #:

Sir,I have "point" code  because There are different 5 Digits or 4 Digits Broker 

Please see this Code :-

...and that is exactly what i thought I would see. Your point needs to be changed for each symbol. 1 point is different for every pair. See Master Fernandos' response. Especially the last line.

Fernando Carreiro #:

No! A "point" is a "point" and should not be changed. Don't confuse "points" with "pips".

The Stops Level is expressed in "points", not "pips". Don't try to change the definition.

Use either the variable "_Point" or the function "Point()". Don't adjust it.

For multi-symbol EAs, you will need to obtain the point size for the symbol using the SymbolInfoDouble function and the "SYMBOL_POINT".

 
Thank you replying to me...😄
Tomorrow I will practice this MQL5 programming 
 
Vikram J U #:
Thank you replying to me...😄
Tomorrow I will practice this MQL5 programming 

any progress and success with this?

Reason: