{exception} floating point invalid operation in simple indi  [SOLVED]

Questions about MultiCharts and user contributed studies.
MeiHua
Posts: 26
Joined: 12 Aug 2012
Has thanked: 1 time

{exception} floating point invalid operation in simple indi

Postby MeiHua » 13 Aug 2012

I have had it plot fine before but now over longer data i cant understand why. Is there ever a time here where the average true range will be 0?? its the only divisor. I am using 5 min charts of YM for past 10 years if anyone can replicate.

Code: Select all

input: length ( 10 );

Vars: Ratio ( 0 ), TSI ( 0 );

Ratio = absvalue((close - close[length]))/averagetruerange(length);

TSI = Average(Average(Ratio,length),100);

Plot1(TSI, "TSI");
Plot2(1.65 , "Boundary");

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: {exception} floating point invalid operation in simple i  [SOLVED]

Postby TJ » 13 Aug 2012

I have had it plot fine before but now over longer data i cant understand why. Is there ever a time here where the average true range will be 0?? its the only divisor. I am using 5 min charts of YM for past 10 years if anyone can replicate.

Code: Select all

input: length ( 10 );

Vars: Ratio ( 0 ), TSI ( 0 );

Ratio = absvalue((close - close[length]))/averagetruerange(length);

TSI = Average(Average(Ratio,length),100);

Plot1(TSI, "TSI");
Plot2(1.65 , "Boundary");
re: Is there ever a time here where the average true range will be 0??

Why is it not possible???


try this:

Code: Select all

input: length ( 10 );

Vars: Ratio ( 0 ), TSI ( 0 ), denom(0);

denom = averagetruerange(length);

if denom = 0 then
ratio = 0
else
Ratio = absvalue((close - close[length]))/ denom;

TSI = Average(Average(Ratio,length),100);

Plot1(TSI, "TSI");
Plot2(1.65 , "Boundary");

MeiHua
Posts: 26
Joined: 12 Aug 2012
Has thanked: 1 time

Re: {exception} floating point invalid operation in simple i

Postby MeiHua » 13 Aug 2012

Thank you, I should have never believed it to be impossible. Very quick solution.

MeiHua
Posts: 26
Joined: 12 Aug 2012
Has thanked: 1 time

Re: {exception} floating point invalid operation in simple i

Postby MeiHua » 13 Aug 2012

Sorry, another quick question. I am trying to get that to take the data from data 2. But i keep getting wrong results. I used a print and output debug already. I also tried to use the custom true range function as well. But i don't think its calculating correctly. Is there a way to use the averagetruerange function with data2? i saw the only input you can give it is length.

Code: Select all

denom = Average(Truerangecustom(high data2, low data2, close data2), length);

if denom = 0 then
ratio = 0
else
Ratio = absvalue((close data2 - close[length] data2))/ denom;

TSI = Average(Average(Ratio,length),100);

Print(Date, TSI);

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: {exception} floating point invalid operation in simple i

Postby TJ » 13 Aug 2012

Sorry, another quick question. I am trying to get that to take the data from data 2. But i keep getting wrong results. I used a print and output debug already. I also tried to use the custom true range function as well. But i don't think its calculating correctly. Is there a way to use the averagetruerange function with data2? i saw the only input you can give it is length.

Code: Select all

denom = Average(Truerangecustom(high data2, low data2, close data2), length);

if denom = 0 then
ratio = 0
else
Ratio = absvalue((close data2 - close[length] data2))/ denom;

TSI = Average(Average(Ratio,length),100);

Print(Date, TSI);
see post #5
viewtopic.php?f=16&t=6929


Return to “MultiCharts”