Unable to compare with i-lookback value New comment Shashank Kumar 2022.03.09 05:52 Hello, I have written an indicator which compares another current indicator candle value to current - lookback indicator candle: CopyBuffer(Multihandle,0,0,rates_total,handledata); int start; if(prev_calculated<lookback) start=lookback; else start=prev_calculated-1; for(int i=start; i<rates_total && !IsStopped(); i++) { SupportBuffer[i] = (handledata[i]/handledata[i-lookback])*100; } //--- return value of prev_calculated for next call return(rates_total); it is giving divide by 0 error, any idea how to fix the code? Vladimir Karputov 2022.03.09 06:09 #1 Before dividing, you must check if "handledata[i-lookback]" is zero. New comment
Hello,
I have written an indicator which compares another current indicator candle value to current - lookback indicator candle:
it is giving divide by 0 error, any idea how to fix the code?