{ Example system for testing exits. To activate an exit, remove the braces { } surrounding the code for that exit. Copyright 2007 Breakout Futures www.BreakoutFutures.com } Inputs: ChanLen (20), NBEnt (20), FrATR (1.0), MALen (20); Var: ATR (0), MarkPos (0), TrailOn (FALSE); ATR = Average(TrueRange, 20); MarkPos = MarketPosition; Buy next bar at Highest(H, ChanLen) + 1 point stop; Sell short next bar at Lowest(L, ChanLen) - 1 point stop; If MarkPos <> 0 and MarkPos <> MarkPos[1] then TrailOn = FALSE; { Trade entered this bar so reset trail flag } { Exit at N bars since entry } If MarketPosition = 1 and BarsSinceEntry = NBEnt then Sell next bar at market; If MarketPosition = -1 and BarsSinceEntry = NBEnt then Buy to cover next bar at market; { Exit using a money management stop } {If MarketPosition = 1 then Sell next bar at EntryPrice - FrATR * ATR stop; If MarketPosition = -1 then Buy to cover next bar at EntryPrice + FrATR * ATR stop; } { Exit with a trailing stop } { If MarketPosition = 1 and TrailOn = FALSE and (Close - EntryPrice) > FrATR * ATR then TrailOn = TRUE; If MarketPosition = 1 and TrailOn then Sell next bar at (EntryPrice + 0.5 * (C - EntryPrice)) stop; If MarketPosition = -1 and TrailOn = FALSE and (EntryPrice - Close) > FrATR * ATR then TrailOn = TRUE; If MarketPosition = -1 and TrailOn then Buy to cover next bar at (EntryPrice - 0.5 * (EntryPrice - C)) stop; } { Exit at a profit target } If MarketPosition = 1 then Sell next bar at EntryPrice + FrATR * ATR limit; If MarketPosition = -1 then Buy to cover next bar at EntryPrice - FrATR * ATR limit; { Exit on a moving average crossover } { If MarketPosition = 1 and C < Average(C, MALen) then Sell next bar at market; If MarketPosition = -1 and C > Average(C, MALen) then Buy to cover next bar at market; } { Exit on RSI movement } { If MarketPosition = 1 and RSI(C, 14) crosses above 70 then Sell next bar at market; If MarketPosition = -1 and RSI(C, 14) crosses below 30 then Buy to cover next bar at market; }