/*[[ Name := Donchian Squeez Author := Luis Damiani Separate Window := No First Color := red First Draw Type := Symbol First Symbol := 104 Use Second Data := Yes Second Color := Red Second Draw Type := Symbol Second Symbol := 104 ]]*/ Inputs : Periods(24),pips_depth(13), Extremes(0),margins(0),Advance(1); // Periods: number of bars used for calculating the Donchian channel //Extremes: if 1 uses the highest high and the lowest low -> I do not recomend using this // if 0 uses the open of the extremes bar -> the open point of a bar (as well as the close // are the points of maximum probability of concentration of the prices during the bar //margins: is the percent of the channel subtrated from the channel border before printing it, negative values are allowed //Advance: the numbers of bars ahead Variables : shift(0), cnt(0), loopbegin(0); Variables : smin(0), smax(0), SsMax(0), SsMin(0),atr(0); Variables : bar(0), prevbars(0), start(0), cs(0), prevcs(0),commodt(0); SetLoopCount(0); cs= Periods+Extremes+margins+Advance; //checksum used to see if parameters have been changed if cs=prevcs and (commodt=symbol) then start=Bars-prevbars //params haven't changed only need to calculate new bar else start=-1; commodt=symbol; prevbars = Bars; prevcs = cs; if (start=1 | start=0) then bar=start else bar=bars-1; For shift=bar Downto 0 Begin //atr=iatr(36,shift); if extremes !=0 then { SsMax = High[Highest(MODE_HIGH,shift,Periods)]; SsMin = Low[Lowest(MODE_LOW,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; if smax-smin