division by 0 error
Forums › ProRealTime English forum › ProOrder support › division by 0 error
- This topic has 5 replies, 2 voices, and was last updated 5 years ago by
Nicolas.
-
-
12/10/2020 at 12:59 PM #15321312345RateOfChangeA = ROC[3](close)RateOfChangeB = ROC[3](close[3])Change = RateOfChangeA/RateOfChangeBRETURN 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.
12/10/2020 at 1:03 PM #15321412/10/2020 at 1:04 PM #15321512/10/2020 at 1:32 PM #153217Hi 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
12/10/2020 at 1:33 PM #15321812/10/2020 at 1:42 PM #153221Try to replace your code with:
12345RateOfChangeA = ROC[3](close)RateOfChangeB = ROC[3](close[3])Change = RateOfChangeA/max(ticksize,RateOfChangeB)RETURN changeIt will ensure that the divisor is at least minimal size of a tick.
-
AuthorPosts
Find exclusive trading pro-tools on