Error 4051 invalid stoploss

 

Hello i got an error like this

 


could anyone please help me to figure out how to fixed it?.. this is my stoploss code :

double getOrderStopLoss(int orderMagicNumber, int orderType, double price) {

   double value = 0;

   if(orderMagicNumber == 700) {

      if ((Bars>20)&&(sqLowest(Symbol(), 0, 20 , 2) > (price-(MaxStopLoss*gPointCoef))))

         {

         value = sqLowest(Symbol(), 0, 20 , 2);}

         else

         value = (price-(MaxStopLoss*gPointCoef));

            }

   if(orderMagicNumber == 800) {

      if ((Bars>20)&&(sqHighest(Symbol(), 0, 20 , 2) < (price+(MaxStopLoss*gPointCoef))))

         {

         value = sqHighest(Symbol(), 0, 20 , 2);}

         else

         value = (price+(MaxStopLoss*gPointCoef));              

   }

   return(NormalizeDouble(value, Digits));

}

//-------------------------------------------------------------------------

double getPointCoef(int orderMagicNumber) {

   double coef = 0;

   string sym = Symbol();

   double rDigits, pointPow;

if(orderMagicNumber == 700) {

      sym = Symbol();

      if(sym == Symbol()) {

         coef = gPointCoef;

      } else {

         rDigits = MarketInfo(sym, MODE_DIGITS);

         if(rDigits > 0 && rDigits != 2 && rDigits != 4) {

            rDigits -= 1;

         }

         pointPow = MathPow(10, rDigits);

         coef = 1/pointPow;      

      }

   }

   if(orderMagicNumber == 800) {

      sym = Symbol();

      if(sym == Symbol()) {

         coef = gPointCoef;

      } else {

         rDigits = MarketInfo(sym, MODE_DIGITS);

         if(rDigits > 0 && rDigits != 2 && rDigits != 4) {

            rDigits -= 1;

         }

         pointPow = MathPow(10, rDigits);

         coef = 1/pointPow;      

      }

   }

    return(coef);

}

//----------------------------------------------------------------------

double sqHighest(string symbol, int timeframe, int period, int shift) {

   double maxnum = -1000000;

   double val;



   for(int i=shift; i<shift+period; i++) {

      if(symbol == Symbol()) {

         val = iHigh(NULL, timeframe, i);

      } else {

         val = iHigh(symbol, timeframe, i);

      }

      if(val > maxnum) {

         maxnum = val;

      }

   }

   return(maxnum);

}

//+------------------------------------------------------------------+

double sqLowest(string symbol, int timeframe, int period, int shift) {

   double minnum = 1000000;

   double val;



   for(int i=shift; i<shift+period; i++) {

      if(symbol == Symbol()) {

         val = iLow(NULL, timeframe, i);

      } else {

         val = iLow(symbol, timeframe, i);

      }

      if(val < minnum) {

         minnum = val;

      }

   }

   return(minnum);

}
 
     if(symbol == Symbol()) {

         val = iHigh(NULL, timeframe, i);

      } else {

         val = iHigh(symbol, timeframe, i);

No need for that, just use symbol.

I get that intermittently on my GUI with my broker. Just retry on the next tick.

 
whroeder1:

No need for that, just use symbol.

I get that intermittently on my GUI with my broker. Just retry on the next tick.

Hello Sir, sorry sir i couldn't get what u mean? i'm not a coder could u give me more detailed what the code should be ? thank you sir for your help 

 
Lee Benny Salim: i'm not a coder could
  1. learn to code it. If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.
  2. or pay (Freelance) someone to code it.
We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help
          urgent help.
Reason: