/*[[ Name := ATR_FILTER Author := Copyright © 2003, Mick K Link := // Use at own risk Separate Window := Yes First Color := PowderBlue First Draw Type := Histogram First Symbol := 217 Use Second Data := Yes Second Color := Red Second Draw Type := Line Second Symbol := 218 ]]*/ Input: stochBack(24); Input: Minor(4), Major(48); Input: centreShift(10); Input: maxBars(2000); Variable : shift(0), tmp(0), mb(0); Variable : st1(0), st2(0), cnt(0); array: YArray[40000](0); array: xArray[40000](0); /* Ideally for 1 hour bars, is a good indication when to trade. The idea of course is that: 1) if the volatility is rising, you're much more likely to be at the beginning of the swing 2) the the volatility is dropping, chances are you're buying into the end of the swing, or the "dumb money". Youll see that when indicator is rising and at/around the 0 point is a good indicator when to allow trading. (ie allow trading on rising indicator, especially after "zero" point reached) I never enter any trades when this indicator is falling, and also extra consider closing when indicator falls back to just above zero line again. Obviously, use with discretion and use at your own risk :) */ SetLoopCount(0); mb = min( maxBars, bars-1 ); // loop from first bar to current bar (with shift=0) For shift = mb Downto 0 Begin tmp = iATR(Minor,shift)/iATR(major,shift); xArray[shift]=tmp; YArray[shift] = ( 1 * xArray[shift+ 4]) + ( 0 * xArray[shift+ 3]) + ( -2 * xArray[shift+ 2]) + ( 0 * xArray[shift+ 1]) + ( 1 * xArray[shift+ 0]) + ( -0.5740619151 * YArray[shift+4]) + ( 2.5125378244 * YArray[shift+3]) + ( -4.2770927795 * YArray[shift+2]) + ( 3.3350085812 * YArray[shift+1]); tmp = YArray[shift]; st1=0; st2=0; if (stochBack>1) then begin For cnt = stochBack Downto 0 Begin tmp = YArray [shift+cnt]; if (abs(tmp)>st1) then st1=abs(tmp); end; tmp = (100*YArray [shift]/st1); end; tmp = tmp + centreShift; SetIndexValue(shift, tmp); setIndexValue2(shift, 0); End;