/*[[ Name := ADX Author := Bheurekso Link := bheurekso@yahoo.com Separate Window := Yes Pertama Color := Blue Pertama Draw Type := Line Use Second Data := Yes Second Color := Red Second Draw Type := Line ]]*/ Inputs : DXperiod(14), Pilihan(0), Populasi(-1); Variables : shift(0), Stempel(0), Prevbars(0), Pertama(true), LoopAnjing(0); Variables : Tutup(0), TutupTadi(0), Atas(0), AtasTadi(0), Bawah(0), BawahTadi(0); Variables : TRtadi(0), TRbaku(0), TR(0); Variables : BedaAtas(0), BedaBawah(0), PDMI(0), MDMI(0); Variables : PDItadi(0), MDItadi(0), PDIbaku(0), MDIbaku(0), PDI(0), MDI(0); Variables : DX(0), ADXtadi(0), ADX(0), ADXR(0); If Stempel=t[0] then exit; Stempel=t[0]; SetLoopCount(0); // Antisipasi kekonyolan 1 If DXperiod < 1 Then Exit; // Reload! If Bars < prevbars Or Bars-prevbars>1 Then Pertama = True; prevbars = Bars; If Pertama Then { if Populasi<0 then LoopAnjing = Bars-DXperiod-1 else LoopAnjing=Populasi-DXperiod-1; // Antisipasi kekonyolan 2 If LoopAnjing < 0 Then Exit; Pertama = False; }; LoopAnjing = LoopAnjing+1; For shift = LoopAnjing Downto 0 { Tutup=c[shift];TutupTadi=c[shift+1];Atas=h[shift];AtasTadi=h[shift+1];Bawah=l[shift];BawahTadi=l[shift+1]; TRtadi=TR; TRbaku=max(abs(Atas-Bawah), max(abs(Atas-TutupTadi),abs(TutupTadi-Bawah))); TR= TRbaku+TRtadi*(DXperiod-1)/DXperiod; BedaAtas=Atas-AtasTadi; BedaBawah=BawahTadi-Bawah; if (BedaAtas < 0 and BedaBawah < 0) or (BedaAtas=BedaBawah) then {PDMI=0;MDMI=0;}; if (BedaAtas > BedaBawah) then {PDMI=BedaAtas;MDMI=0;}; if (BedaAtas < BedaBawah) then {PDMI=0;MDMI = BedaBawah;}; PDItadi=PDIbaku; MDItadi=MDIbaku; PDIbaku= PDMI+PDItadi*(DXperiod-1)/DXperiod; MDIbaku= MDMI+MDItadi*(DXperiod-1)/DXperiod; PDI=100*PDIbaku/TR; MDI=100*MDIbaku/TR; DX=100*abs(PDI-MDI)/(PDI+MDI); ADXtadi=ADX; ADX=(DX+(DXperiod-1)*ADXtadi)/DXperiod; if pilihan=1 then ADXR=(ADX+GetIndexValue(shift+period))/2; if Pilihan=0 then { SetIndexValue(shift,PDI); SetIndexValue2(shift,MDI); }; if Pilihan=1 then { SetIndexValue(shift,ADX); SetIndexValue2(shift,ADXR); }; LoopAnjing = LoopAnjing-1; };