Problem with modified TrailingSL Error MT5

 

 I have Problem with modified SL Error, Please help me to correct it. I am attache Price Error Screen Shot and Code for TrailingSL .

Here is Screen Shot.

SL Error


Trailing  SellSL Code

void AdvanceSellStop(double Bid) 

  {

  // Set Desire stop Loss for buy trade

  double ssl = NormalizeDouble(Bid +100 *_Point,_Digits);

  for (int s = PositionsTotal()- 1;s >= 0;s--)

   {

   string symbol = PositionGetSymbol(s); // Get Symbol of the Position5

   PositionSelect(s);

   if(Symbol() == symbol)

     if(PositionGetInteger(POSITION_TYPE) == ORDER_TYPE_SELL);

     {

      ulong SellTicket = PositionGetInteger(POSITION_TICKET); // Current Ticket No

      static double SellSL = PositionGetDouble(POSITION_SL);   // Current SL

      double LSSL  = (Ask + (40*_Point));

      double Stp = PositionGetDouble(POSITION_TP);   // Current TP

      if(Bid - Stp < (30*_Point))Stp = (Stp -(30*_Point));

      if(POSITION_PRICE_OPEN < SellSL ||  POSITION_PRICE_OPEN > (Ask + (50*_Point)))

        {

        SellSL = (POSITION_PRICE_OPEN - (5*_Point));

        trade.PositionModify(SellTicket,SellSL,Stp); 

        }

    // if(Ask < (SellSL - (60*_Point)) || SellSL < LSSL)SellSL = (SellSL - (60*_Point));     

    // if(Ask < (SellSL - (40*_Point)) || SellSL < LSSL)SellSL = (SellSL - (40*_Point));     

     if(Ask < (SellSL - (20*_Point)) || SellSL < LSSL)SellSL = (SellSL - (20*_Point));    

     

     if( SellSL + (5*_Point) < ssl )

     // if(Ask < (SellSL + (20*_Point)) || SellSL < LSSL)SellSL = (SellSL - (20*_Point)); 

       {   

       SellSL =  SellSL + (1*_Point);

       trade.PositionModify(SellTicket,SellSL,Stp);   

        LSSL =  SellSL;  

       }     

     } // End Symbol if Loop   

   } // End For Loop 

 } // End Function


 
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code correctly in a new post.
 
Step by step debug and see when and where the value gets out of bound.

Although you pasted the code, it is hard to read.

(I hate missing parenthese)

Tell me what is this?

  if(POSITION_PRICE_OPEN < SellSL

Should this beaa parameter to
PositionGetDouble()??




Reason: