/*[[ Name := $donchian_bar Author := Darma thanks to bheurekso for mentoring Link := http://www.darmasdt.com/ Separate Window := No First Color := Blue First Draw Type := Histogram First Symbol := 159 Use Second Data := Yes Second Color := Red Second Draw Type := Histogram Second Symbol := 159 ]]*/ Variable : shift(0); Variable : res(0),sup(0),pivothi(0),pivotlo(0); Variable : jual(false),beli(false); SetLoopCount(0); // loop from first bar to current bar (with shift=0) For shift=Bars-Period-1 Downto 0 Begin res=iCustom("$donchian_no",MODE_SECOND,shift); sup=iCustom("$donchian_no",MODE_FIRST,shift); pivothi=((2*h[shift])+l[shift]+(2*c[shift]))/5; pivotlo=(h[shift]+(2*l[shift])+(2*c[shift]))/5; //if l[shift]>sup and h[shift]>res // then beli=true else beli=false; //if h[shift]sup and pivothi>res then beli=true else beli=false; if pivothi