Hello,
I use this function to calculate the True Range
I call this function with efsInternal function and it works fine but sometimes I get some big spikes in the true range.
Why does this happen and how can I make this better also from the point of view of efficiency?
Also I am not sure but I think TRH and TRL should be local variables but I think that in my function TRL is global and I cannot understand why?
Thank you in advance
I use this function to calculate the True Range
Code:
function TrueRange(){ var TRH = TRL = 0; //compute True High if (high(0)>close(-1)) {TRH = high(0);} else if(high(0)<close(-1)) {TRH = close(-1);} //compute True Low if (low(0)<close(-1)) {TRL = low(0);} else if(low(0)>close(-1)) {TRL = close(-1);} //compute True Range var TR = TRH-TRL; return (TR); }
Why does this happen and how can I make this better also from the point of view of efficiency?
Also I am not sure but I think TRH and TRL should be local variables but I think that in my function TRL is global and I cannot understand why?
Thank you in advance
Comment