/*[[ Name := DiNapoli Deterend Price Oscillator Author := Copyright © 2005, a1cor. Separate Window := Yes First Color := Red First Draw Type := Line Use Second Data := Yes Second Color := Blue Second Draw Type := Line ]]*/ Input : MAPeriod1(3),MAPeriod2(7); Variable : shift(0), dpo1(0), dpo2(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 if MAPeriod2 > MAPeriod1 then loopbegin = Bars-MAPeriod2-1 else loopbegin = Bars-MAPeriod1-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 dpo1=C[shift]-iMAEx(MAPeriod1,MODE_SMA,0,PRICE_CLOSE,shift); dpo2=C[shift]-iMAEx(MAPeriod2,MODE_SMA,0,PRICE_CLOSE,shift); SetIndexValue (shift,dpo1); SetIndexValue2(shift,dpo2); loopbegin = loopbegin-1; // prevent to previous bars recounting End;