Wrong values being returned

 

Hi, im trying to set an SL price below the candlestick low. Ive tested everything separately and it all works yet currently the SLinPips printed for JPY pairs are inaccurate. 

input double                              sl_extras           = 1;     //pips

string symbol_loop[] = {"GBPUSD","EURJPY","GBPNZD"};
datetime old_time;


//+-------------------------------------------------------------------------------------------------------+
//|  On OnInit                                                                                            |
//+-------------------------------------------------------------------------------------------------------+

int OnInit()
{



    
    return(INIT_SUCCEEDED);
}


//+-------------------------------------------------------------------------------------------------------+
//|  On DeInit                                                                                            |
//+-------------------------------------------------------------------------------------------------------+

void OnDeinit(const int reason)
  {


  }

//+-------------------------------------------------------------------------------------------------------+
//|  OnTick                                                                                               |
//+-------------------------------------------------------------------------------------------------------+
void OnTick(){

   datetime GMT = iTime(_Symbol, PERIOD_M15, 1);
   if (GMT > old_time){
      old_time = GMT;

   for (int i = 0; i < ArraySize(symbol_loop); i++){
   string symbol = symbol_loop[i];
   double point = SymbolInfoDouble(symbol, SYMBOL_POINT); 
 

   double Low = low(symbol, 0);

   double spread = 1.9;
   double pipvalue = point * 10;
   double totalSLinpips = spread + sl_extras;
   double SLinPips = (totalSLinpips * pipvalue);

   
   double BuyingSLPrice = buyingStopLossPrice(sl_extras, spread, Low, pipvalue);

   Print(symbol, " SLinPips: ", SLinPips);   }
   }
}

double buyingStopLossPrice(double psl_extras, double pspread, double plow, double ppoint)
{
   return (plow - ((psl_extras + pspread) * (ppoint * 10)));
}



double low(string symbol, int shift)
{
    return iLow(symbol, PERIOD_CURRENT, shift);
}




 
luccc:

Hi, im trying to set an SL price below the candlestick low. Ive tested everything separately and it all works yet currently the SLinPips printed for JPY pairs are inaccurate. 


You can use 

 NormalizeDouble(SLinPips, Digits());

to normalize the price to symbol's digits