INF error for only 1 variable

 

Hi all,

For some strange reason, the buffer wd[i] returns INF indefinitely. Ive normalized the digits but its still giving an INF value. Can someone pinpoint the error in the code?

Will be greatly appreciated.

Thank you.

 int i = (int)MathMax(prev_calculated-1,1); for(; i<rates_total; i++){
//---  
      double   price          =  getPrice(inpBandPrice,open,close,high,low,i,rates_total);
               vala[i]        =  ma_buffer[i];
      double   smoothedMulti  =  MathRound(((inpBandPeriod-1)/2)-1);
      
      double   sum = 0;
      for(int j=1; j<=smoothedMulti && (i-j)>=0; j++){
         sum += vala[i-j];
      }      
      vals[i] = NormalizeDouble(sum/smoothedMulti,Digits());
      double   diff           =  NormalizeDouble(close[i] - vals[i],Digits());
      //double   diff           =  NormalizeDouble(price,Digits()) - vals[i];
      
      if(diff>=0){
         wu[i] =  (i>inpBandPeriod)?(wu[i-1]*(smoothedMulti-1)+(diff*diff)) * MathPow(smoothedMulti,-1):0; 
         wd[i] =  (i>inpBandPeriod)?(wd[i-1]*(smoothedMulti-1)) * MathPow(smoothedMulti,-1):0;
      }
      else {
         wd[i] =  (i>inpBandPeriod)?(wd[i-1]*(smoothedMulti-1)+(diff*diff)) * MathPow(smoothedMulti,-1):0;
         wu[i] =  (i>inpBandPeriod)?(wu[i-1]*(smoothedMulti-1)) * MathPow(smoothedMulti,-1):0;
      }
      double   bandMulti      =  MathMax(MathRound(((smoothedMulti-1)*MathPow(2,-1))-1),1);
      
      valu[i]  =  vals[i] + (bandMulti * MathSqrt(wu[i]));
      vald[i]  =  vals[i] - (bandMulti * MathSqrt(wd[i]));
      valm[i]  =  NormalizeDouble((valu[i]+vald[i])*MathPow(2,-1),Digits());

//--- 
      //midline[i] = NormalizeDouble((valu[i]+vald[i])/2,Digits());    
      //double smooth = 0;
      //double smoothP = 3;
      //for(int k=1; k<=smoothP && (i-k)>=0; k++){
      //   smooth += midline[i-k];
      //}
      //valm[i] = smooth/smoothP;
//---      
      valmC[i] =  valmC[i-1];
      if(valm[i] > valm[i-1])valmC[i] = 0;
      if(valm[i] < valm[i-1])valmC[i] = 1;
      
      atru[i]  =  valm[i] + (inpBandDeviations*atr_buffer[i]);
      atrd[i]  =  valm[i] - (inpBandDeviations*atr_buffer[i]);
      
      Print("i :",i," ","price: ",close[i]," ","vals[i] :",vals[i]," ","diff :",diff," ","wu :",wu[i]," ","wu[i-1] :",wu[i-1]," ","wd[i] :",wd[i]," ","wd[i-1] :",wd[i-1]);
//---
   }   

// --- Print results
//2022.07.18 20:59:14.046       2022.06.01 00:02:01   i :105552 price: 1.07321 vals[i] :1.07344 diff :-0.00023 wu :0.00002 wu[i-1] :0.00002 wd[i] :inf wd[i-1] :inf
//2022.07.18 20:59:14.426       2022.06.01 00:02:17   i :105552 price: 1.07323 vals[i] :1.07344 diff :-0.00021 wu :0.00002 wu[i-1] :0.00002 wd[i] :inf wd[i-1] :inf
//2022.07.18 20:59:14.808       2022.06.01 00:02:18   i :105552 price: 1.07321 vals[i] :1.07344 diff :-0.00023 wu :0.00002 wu[i-1] :0.00002 wd[i] :inf wd[i-1] :inf
//2022.07.18 20:59:15.189       2022.06.01 00:02:19   i :105552 price: 1.07323 vals[i] :1.07344 diff :-0.00021 wu :0.00002 wu[i-1] :0.00002 wd[i] :inf wd[i-1] :inf

Regards,

John

 
John.Doe:

Hi all,

For some strange reason, the buffer wd[i] returns INF indefinitely. Ive normalized the digits but its still giving an INF value. Can someone pinpoint the error in the code?

Will be greatly appreciated.

Thank you.

Regards,

John

Would need more to go on- like a compilable program which one could debug

 
No one yet knows and it's an error in the compiled system, but Metatrader 5 and its renowned expert programmers still can't solve it, but they are the best and the error will soon be fixed.