Error Get SL = 0

 

i want to create flexible stoploss range by confirmation of candlestick, but my code still error . 


Here is my code : 


int GetSLPip()
{

   int pips = 0;
   double p = 0;
   double delta=50;
   
   for (int i=0; i<=delta; i++)
   {
       // Counting Pips for SL Value 
   double HighSL  = MathAbs (High[1]+3*pt); 
   double LowSL   = MathAbs (Low[1]-3*pt) ; 
   double pipSLB  = MathAbs (Open[0]-LowSL);
   double pipSLS  = MathAbs (HighSL - Open[0]);

                      
               
            if (Close[1]>Open[2])
            {
               p = MathAbs(Ask - pipSLB) / pt;
               //pips = pips + NormalizeDouble(p,0);
               pips++;
            }
            
            if (Close[1]<Open[2])
            {
               p = MathAbs(pipSLS - Bid) / pt;
               //pips =  pips + (NormalizeDouble(p,0));
               pips++;
              
            }        
        
       
   }   
   Print("Error Get SL Pips : ",GetLastError()); 
   return(pips);
}
 

What errors are you getting ?

Not sure what kind of function is that but your code seems kind of useless. You have a loop that doesn't seem to do anything.

If the variable "pt" is a global variable, then you must provide the full source code to get some help.