/*[[ Name := DiNapoli Deterend Price Oscillator Author := Copyright © 2005, a1cor. Separate Window := Yes First Color := Blue First Draw Type := Line Use Second Data := Yes Second Color := Gray Second Draw Type := Line ]]*/ Input : MAPeriod(7); Variable : shift(0), dpo(0); Variables : loopbegin(0), first(True), prevbars(0); SetLoopCount(0); // check for additional bars loading or total reloading If Bars < prevbars Or Bars-prevbars>1 Then first = True; prevbars = Bars; // loopbegin prevent counting of counted bars exclude current If first Then Begin loopbegin = Bars-MAPeriod-1; If loopbegin < 0 Then Exit; // not enough bars for counting first = False; // this block is to be evaluated once only End; // Detrend Price Oscillator loopbegin = loopbegin+1; // current bar is to be recounted too For shift = loopbegin Downto 0 Begin dpo=C[shift]-iMAEx(MAPeriod,MODE_SMA,0,PRICE_CLOSE,shift); SetIndexValue(shift,dpo); SetIndexValue2(shift,0); loopbegin = loopbegin-1; // prevent to previous bars recounting End;