/*[[ Name := Mean Deviation Author := Luis Damiani Separate Window := yes First Color := lime First Draw Type := histogram First Symbol := 104 Use Second Data := yes Second Color := OrangeRed Second Draw Type := histogram Second Symbol := 104 ]]*/ Inputs : Periods(6),delta(3),num_bars(200); Variables : shift(0), cnt(0), loopbegin(0); Variables : md(0),md_1(0),trade(0); Variables : prevbars(0),start(-1); SetLoopCount(0); For shift=num_bars Downto 0 Begin md=(((high[shift]+low[shift]+close[shift])/3)-iMAEx(periods,MODE_SMA,0,PRICE_TYPICAL,shift))/iCCIEx(periods,PRICE_TYPICAL,shift)/0.015; //md_1=(((high[shift+1]+low[shift+1]+close[shift+1])/3)-iMAEx(periods,MODE_SMA,0,PRICE_TYPICAL,shift+1))/iCCIEx(periods,PRICE_TYPICAL,shift+1)/0.015; if mddelta then trade=delta;}; if !(trade>0) then {SetIndexValue2(shift,md);SetIndexValue(shift,0);} else {SetIndexValue2(shift,0);SetIndexValue(shift,md);}; md_1=md; End; md_1=0;