/*[[ Name := Modified Donchian Channels Author := Damiani Link := Separate Window := No First Color := Teal First Draw Type := Line First Symbol :=160 Use Second Data := Yes Second Color := Teal Second Draw Type := Line Second Symbol := 160 ]]*/ Variables : Periods(3),Extremes(0),margins(0),Advance(1); Variables : shift(0), cnt(0), loopbegin(0); Variables : smin(0), smax(0), SsMax(0), SsMin(0); SetLoopCount(0); loopbegin = Bars-1; For shift = loopbegin-Period Downto 0 Begin if extremes !=0 then { SsMax = High[Highest(MODE_OPEN,shift,Periods)]; SsMin = Low[Lowest(MODE_OPEN,shift,Periods)]; } Else { SsMax = Open[Highest(MODE_OPEN,shift,Periods)]; SsMin = Open[Lowest(MODE_OPEN,shift,Periods)]; }; smin = SsMin+(SsMax-SsMin)*margins/100; smax = SsMax-(SsMax-SsMin)*margins/100; SetIndexValue(shift-Periods+1-Advance,smin); SetIndexValue2(shift-Periods+1-Advance,smax); loopbegin = loopbegin-1; End;