/*[[ Name := MyNRTR_WATR_Line_v1 Author :=IgorAD Link := igorad2004@list.ru Separate Window := No First Color := Blue First Draw Type := Symbol First Symbol := 119 Use Second Data := Yes Second Color := Red Second Draw Type := Symbol Second Symbol := 119 ]]*/ Inputs : PeriodWATR(10),Risk(0.3),Kwatr(1),nbars(500); Variable : i(0),shift(0),trend(0),AvgRange(0),dK(0); Arrays : smin[8000](0),smax[8000](0),watr[8000](0); For shift=nBars-1-PeriodWATR Downto 0 Begin AvgRange=0; for i=PeriodWATR-1 DownTo 0 { dK = 1+(PeriodWATR-i)/PeriodWATR; AvgRange=AvgRange+ dK*Abs(High[shift+i]-Low[shift+i]); }; WATR[shift] = AvgRange/PeriodWATR; smax[shift]=c[shift]+kwatr*watr[shift]; smin[shift]=c[shift]-kwatr*watr[shift]; if c[shift]>smax[shift+1]-2*risk*kwatr*watr[shift+1] then trend=1; if c[shift]0 and smin[shift]smax[shift+1] then smax[shift]=smax[shift+1]; if trend=1 then { SetIndexValue2(shift, -1); SetIndexValue(shift, smin[shift]);}; if trend=-1 then { SetIndexValue2(shift, smax[shift]); SetIndexValue(shift, -1); }; End;