***DONCHIAN BREAK OUT WITH PROTECTIVE AND TRAILING STOP*** vars: daysInTrade(0), lookBack(30), midLevel(0), longLipPt(0), shortLitPt(0); if (marketPosition = 1) then begin midLevel= entryPrice(0)-(highest(high,30)-lowest(low,30))/2.0; end; if((marketPosition = -1) then begin midLevel= entryPrice(0)+(highest(high,30)-lowest(low,30))/2.0; end; if marketposition <> 0 and barSinceEntry(0)>0 and (Mod(barsSinceEntry(0),5)=0)) then begin lookBack = lookBack -2 ; LookBack = maxlist(lookBack, 6) end; longLiqPt = maxlist(lowest(low, lookBack), midLevel); shortLiqPt= minlist(highest(high, lookBack), midlevel); if barsSinceEntry(0)=0 and marketPosition <>0) then begin longLipPt= midLevel; shortLiqPt = midLevel; end; if(marketPosition = 1) then exitlong("long exit") at longLiqPt stop; if(marketPosition = -1) then exitshort("shortexit") at shortLiqPt stop; buy ("donchian buy") tomorrow at highest (high, 30) stop; sell ("donchian sell") tomorrow at lowest (low, 30) stop; if(marketPosition = 0) then lookBack = 30;