{------------------------------------------------------------------------------- Trading Strategy Code Population member: 0 Max bars back: 24 Created by: Adaptrade Builder version 4.1.0.0 Created: 2/26/2022 4:32:28 PM Scripting language: TradeStation 6 or newer Symbol: @ES#C 1 Day (Daily bars), Primary (Data1) (C:\..\@ES#C 1 Day.txt) Build dates: 9/4/2000 to 1/2/2013 Project file: C:\..\SimpleBreakout.gpcode -------------------------------------------------------------------------------} { Strategy inputs } Inputs: NL1 (5), { Indicator look-back length (bars), long trades } NL2 (25), { Indicator look-back length (bars), long trades } NS1 (5), { Indicator look-back length (bars), short trades } NS2 (25), { Indicator look-back length (bars), short trades } NBarEnL1 (3), { Indicator look-back length (bars), long trades } NTargL1 (10), { Indicator look-back length (bars), long trades } NTargL2 (10), { Indicator look-back length (bars), long trades } TargFrL (1.0000), { Multiple of price difference (e.g., ATR); exit, long trades } NMML1 (10), { Indicator look-back length (bars), long trades } NMML2 (10), { Indicator look-back length (bars), long trades } MMFrL (1.0000), { Multiple of price difference (e.g., ATR); exit, long trades } NBarEnS1 (3), { Indicator look-back length (bars), short trades } NMMS1 (10), { Indicator look-back length (bars), short trades } NMMS2 (10), { Indicator look-back length (bars), short trades } MMFrS (1.0000), { Multiple of price difference (e.g., ATR); exit, short trades } NTargS1 (10), { Indicator look-back length (bars), short trades } NTargS2 (10), { Indicator look-back length (bars), short trades } TargFrS (1.0000), { Multiple of price difference (e.g., ATR); exit, short trades } PSParam (1.00), { Position sizing parameter value } RoundPS (true), { Round-to-nearest (true/false) } RoundTo (1), { Round-to position size value } MinSize (1), { Minimum allowable position size } SizeLimit (100); { Maximum allowable position size } { Variables for entry and exit prices } Var: EntPrL (0), EntPrS (0), TargPrL (0), TargPrS (0), LStop (0), SStop (0); { Variables for entry and exit conditions } Var: VarL1 (0), VarL2 (0), VarS1 (0), VarS2 (0), EntCondL (false), EntCondS (false); { Variables for position sizing } Var: NShares (0); { Entry prices } EntPrL = Highest(H, NBarEnL1); EntPrS = Lowest(L, NBarEnS1); { Entry and exit conditions } VarL1 = Average(C, NL1); VarL2 = Average(C, NL2); VarS1 = Average(C, NS1); VarS2 = Average(C, NS2); EntCondL = VarL1 > VarL2; EntCondS = VarS1 < VarS2; { Position sizing calculations } NShares = PSParam; If RoundPS and RoundTo > 0 then NShares = IntPortion(NShares/RoundTo) * RoundTo; NShares = MaxList(NShares, MinSize); NShares = MinList(NShares, SizeLimit); { Entry orders } If MarketPosition = 0 and EntCondL then begin Buy("EnStop-L") NShares shares next bar at EntPrL stop; end; If MarketPosition = 0 and EntCondS then begin Sell short("EnStop-S") NShares shares next bar at EntPrS stop; end; { Exit orders, long trades } If MarketPosition = 1 then begin If BarsSinceEntry = 0 then begin LStop = EntryPrice - MMFrL * (Highest(H, NMML1) - Lowest(L, NMML2)); end; Sell("ExStop-L") next bar at LStop stop; TargPrL = EntryPrice + TargFrL * (Highest(H, NTargL1) - Lowest(L, NTargL2)); Sell("ExTarg-L") next bar at TargPrL limit; end; { Exit orders, short trades } If MarketPosition = -1 then begin If BarsSinceEntry = 0 then begin SStop = EntryPrice + MMFrS * (Highest(H, NMMS1) - Lowest(L, NMMS2)); end; Buy to cover("ExStop-S") next bar at SStop stop; TargPrS = EntryPrice - TargFrS * (Highest(H, NTargS1) - Lowest(L, NTargS2)); Buy to cover("ExTarg-S") next bar at TargPrS limit; end;