{ ScaleOutCombo strategy Example of scaling out of a trade. The trade is entered with two contracts. If the trade is profitable, one contract is exiting at a relatively tight target. The stop for the second contract is then moved to breakeven and trailed from that point. Copyright 2009 Breakout Futures www.BreakoutFutures.com } Inputs: NBarEnt (6), NMA1 (70), MinsTm (300), MaxEntrz (1), NATR (90), TargFr (1.5), StopFr (1.5); Var: EntFlag1 (false), EntFlag2 (false), EntFlag3 (false), EntFlag4 (false), EntFlag5 (false); Var: Time1(0); Var: TargSz(0), StopSz(0), TrailOn(false), TrPrice(0); Var: ATR(0); Time1 = CalcTime(SessionStartTime(1, 1), MinsTm); ATR = Average(TrueRange, NATR); EntFlag1 = High[17] >= Low[18] and Low[4] <= Close[16]; EntFlag2 = Close < Average(Close, NMA1); EntFlag3 = time <= Time1; EntFlag4 = TrueRange < ATR; EntFlag5 = EntriesToday(date) < MaxEntrz; If EntFlag1 and EntFlag2 and EntFlag3 and EntFlag4 and EntFlag5 and MarketPosition <> -1 then Begin Sell short 2 contracts next bar at Lowest(L, NBarEnt) stop; TargSz = TargFr * ATR; StopSz = StopFr * ATR; TrailOn = FALSE; End; If MarketPosition < 0 then Begin { Place target exit if target not hit yet } If L > EntryPrice - TargSz or BarsSinceEntry = 0 then Buy to cover("Targ") 1 contract next bar at EntryPrice - TargSz limit; { Activate trailing stop if target has been hit } If TrailOn = False and L <= EntryPrice - TargSz and BarsSinceEntry > 0 then Begin TrailOn = True; TrPrice = EntryPrice; End; { Place trailing stop } If TrailOn then Begin TrPrice = MinList(TrPrice, (Close + TargSz)); Buy to cover("Trail") next bar at TrPrice stop; End; { Place money management stop } Buy to cover("MM") next bar at EntryPrice + StopSz stop; End; SetExitOnClose; {------------------------------------------------------------------------------------------------------------} { ScaleOutTarg strategy Example of scaling out of a trade. The trade is entered with two contracts. If the trade is profitable, one contract is exiting at a relatively tight target. The stop for the second contract is then moved to breakeven and trailed from that point. This strategy deletes the second contract. Only the target exit is used. Copyright 2009 Breakout Futures www.BreakoutFutures.com } Inputs: NBarEnt (6), NMA1 (70), MinsTm (300), MaxEntrz (1), NATR (90), TargFr (1.5), StopFr (1.5); Var: EntFlag1 (false), EntFlag2 (false), EntFlag3 (false), EntFlag4 (false), EntFlag5 (false); Var: Time1(0); Var: TargSz(0), StopSz(0), TrailOn(false), TrPrice(0); Var: ATR(0); Time1 = CalcTime(SessionStartTime(1, 1), MinsTm); ATR = Average(TrueRange, NATR); EntFlag1 = High[17] >= Low[18] and Low[4] <= Close[16]; EntFlag2 = Close < Average(Close, NMA1); EntFlag3 = time <= Time1; EntFlag4 = TrueRange < ATR; EntFlag5 = EntriesToday(date) < MaxEntrz; If EntFlag1 and EntFlag2 and EntFlag3 and EntFlag4 and EntFlag5 and MarketPosition <> -1 then Begin Sell short 1 contracts next bar at Lowest(L, NBarEnt) stop; TargSz = TargFr * ATR; StopSz = StopFr * ATR; TrailOn = FALSE; End; If MarketPosition < 0 then Begin { Place target exit if target not hit yet } If L > EntryPrice - TargSz or BarsSinceEntry = 0 then Buy to cover("Targ") 1 contract next bar at EntryPrice - TargSz limit; { Activate trailing stop if target has been hit } { If TrailOn = False and L <= EntryPrice - TargSz and BarsSinceEntry > 0 then Begin TrailOn = True; TrPrice = EntryPrice; End; { Place trailing stop } If TrailOn then Begin TrPrice = MinList(TrPrice, (Close + TargSz)); Buy to cover("Trail") next bar at TrPrice stop; End; } { Place money management stop } Buy to cover("MM") next bar at EntryPrice + StopSz stop; End; SetExitOnClose; Value99 = WriteTrades3(StopSz * BigPointValue, 0, EntryPrice + StopSz, "C:\ScaleOutTarg-WriteTrades3.csv"); {------------------------------------------------------------------------------------------------------------} { ScaleOutTrail strategy Example of scaling out of a trade. The trade is entered with two contracts. If the trade is profitable, one contract is exiting at a relatively tight target. The stop for the second contract is then moved to breakeven and trailed from that point. This strategy deletes the first contract. Only the trailing exit is used. Copyright 2009 Breakout Futures www.BreakoutFutures.com } Inputs: NBarEnt (6), NMA1 (70), MinsTm (300), MaxEntrz (1), NATR (90), TargFr (1.5), StopFr (1.5); Var: EntFlag1 (false), EntFlag2 (false), EntFlag3 (false), EntFlag4 (false), EntFlag5 (false); Var: Time1(0); Var: TargSz(0), StopSz(0), TrailOn(false), TrPrice(0); Var: ATR(0); Time1 = CalcTime(SessionStartTime(1, 1), MinsTm); ATR = Average(TrueRange, NATR); EntFlag1 = High[17] >= Low[18] and Low[4] <= Close[16]; EntFlag2 = Close < Average(Close, NMA1); EntFlag3 = time <= Time1; EntFlag4 = TrueRange < ATR; EntFlag5 = EntriesToday(date) < MaxEntrz; If EntFlag1 and EntFlag2 and EntFlag3 and EntFlag4 and EntFlag5 and MarketPosition <> -1 then Begin Sell short 1 contracts next bar at Lowest(L, NBarEnt) stop; TargSz = TargFr * ATR; StopSz = StopFr * ATR; TrailOn = FALSE; End; If MarketPosition < 0 then Begin { Place target exit if target not hit yet } {If L > EntryPrice - TargSz or BarsSinceEntry = 0 then Buy to cover("Targ") 1 contract next bar at EntryPrice - TargSz limit;} { Activate trailing stop if target has been hit } If TrailOn = False and L <= EntryPrice - TargSz and BarsSinceEntry > 0 then Begin TrailOn = True; TrPrice = EntryPrice; End; { Place trailing stop } If TrailOn then Begin TrPrice = MinList(TrPrice, (Close + TargSz)); Buy to cover("Trail") next bar at TrPrice stop; End; { Place money management stop } Buy to cover("MM") next bar at EntryPrice + StopSz stop; End; SetExitOnClose; Value99 = WriteTrades3(StopSz * BigPointValue, 0, EntryPrice + StopSz, "C:\ScaleOutTrail-WriteTrades3.csv");