RateOfChangeA = ROC[3](close)
RateOfChangeB = ROC[3](close[3])
Change = RateOfChangeA/RateOfChangeB
RETURN change
hi guys,
I have read through the forums & found that this issue exists in several scenarios, i understand that the divisor cannot divide by 0 but neither of these should be throwing a 0.
does anyone know what would cause this error with the code above, the code worked well without these lines but now that i have added them it stops the strategy from working.
thanks in advance & apologies if this has been answered. the threads i read never actually had a fix just several ideas that seemed impractical.
i think i found the issue. its in the RateOfChangeB ROC[3](close[3]) i changed to RateOfChangeB ROC[3](close[2]). lets see if this throws the error
Why do you think that this is this code that is throwing this error please? Are you using a CALL to get the value of “change”?
Hi Nicolas, the strategy was working fine & running without the addition of the ROC function. This is what makes me think it’s this piece of code.
I am still quite new to coding & strategy development so I am unsure exactly what a call is. I am assuming that a call is used when I want to use the parameter “change”.
“Change” is used further in the code when sending buy or sell signal.
apologies for code below doing this on mobile & having issues with editor.
IF Change >= 9 THEN
BUY X at market
ENDIF
Side note changing the variable didn’t help
Try to replace your code with:
RateOfChangeA = ROC[3](close)
RateOfChangeB = ROC[3](close[3])
Change = RateOfChangeA/max(ticksize,RateOfChangeB)
RETURN change
It will ensure that the divisor is at least minimal size of a tick.