Do not divide by 0!

Below the code of SQX_ATR indicator, in some cases value returned by Minlist is ZERO.

Please always check before trying to divide by ZERO ;)
Check all indicators.

inputs:
    Period( numericsimple );

Value1 = Minlist(Period, CurrentBar);

if CurrentBar = 1 then
    SQ_ATR = TrueRange
else
    SQ_ATR = (SQ_ATR[1] * (Value1 - 1) + TrueRange) / Value1;
    
{ Force series function, since otherwise this function can verify as simple, but needs to be called at every bar to return correct results }
If false then Value10 = SQ_ATR[1];
Attachments
No attachments
  • Votes +1
  • Project StrategyQuant X
  • Type Bug
  • Status Refused
  • Priority Normal

History

Kc
#1

coensio

05.12.2022 14:20

Task created

E
#2

Emmanuel

05.12.2022 18:57
Voted for this task.
MF
#3

Mark Fric

06.12.2022 08:23

Status changed from New to Refused

we have controls for this, but i your example this should never happen - unless you set Period to 0 - which is so wrong that it should throw error.
Kc
#4

coensio

09.12.2022 11:24

For people who will get this error on TS side (and they will):


if Value1 > 0 then

     SQ_ATR = (SQ_ATR[1] * (Value1 - 1) + TrueRange) / Value1;



Votes: +1

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please