Help needed on, simple but strange error!!!

 

Hi Fellow Members

I have a strange error/issue, where my variable are correctly found but division results is shown as Zero!!!

if(i <= 3) {
        if(DoPrint) PrintFormat("%s [%s] idxLoop[%i] TSV EMA (%i - %i) / %i = [%i]%+.8f",vMethod,mIndexTime,idxLoop,TSV[i].ema,TSV[i+2].ema,TSV[i+2].ema,i,TSV[i].slope);
        TSV[i].slope             = (TSV[i].ema - TSV[i+2].ema) / TSV[i+2].ema;
}
2023.08.21 17:55:59.301 iCandlePatterns (US30,H1)       [US30,PERIOD_H1] CiCandlePattern::UpdateCalculationData [2023.08.15 10:00] idxLoop[100] TSV EMA (911206 - 749683) / 749683 = [3]+0.00000000
2023.08.21 17:55:59.301 iCandlePatterns (US30,H1)       [US30,PERIOD_H1] CiCandlePattern::UpdateCalculationData [2023.08.15 10:00] idxLoop[99] TSV EMA (805571 - 1085636) / 1085636 = [2]+0.00000000
2023.08.21 17:55:59.301 iCandlePatterns (US30,H1)       [US30,PERIOD_H1] CiCandlePattern::UpdateCalculationData [2023.08.15 10:00] idxLoop[98] TSV EMA (710476 - 911206) / 911206 = [1]+0.00000000

as you can see, the calculation outcome is 710476 - 911206 = -200730 / 911206 = -0.22029, however the result is 0.000000 (makred in red ink)!!!

Any clues why the calculated results are showing zero value?

Thanks in advance :)

Time Segmented Volume (TSV)
Time Segmented Volume (TSV)
  • www.mql5.com
Based on the original “Time Segmented Volume (TSV)” developed by Worden Brothers, Inc.
 
Anil Varma:

Hi Fellow Members

I have a strange error/issue, where my variable are correctly found but division results is shown as Zero!!!

as you can see, the calculation outcome is 710476 - 911206 = -200730 / 911206 = -0.22029, however the result is 0.000000 (makred in red ink)!!!

Any clues why the calculated results are showing zero value?

Because it's zero.

Your ema values are integers, so your slope value is the result of an integers division, can't have decimals.

 
Alain Verleyen #:

Because it's zero.

Your ema values are integers, so your slope value is the result of an integers division, can't have decimals.

Thanks @Alain changing buffers to double resolved the issue.