{------------------------------------------------------------------------------- Trading Strategy Code Population member: 119 Max bars back: 80 Created by: Adaptrade Builder version 4.2.1.0 Created: 9/5/2022 11:30:01 AM Scripting language: TradeStation 6 or newer Symbol: @ES#C 1 Day (Daily bars), Primary (Data1) (C:\Adaptrade\MarketData\@ES#C 1 Day.txt) Build dates: 9/4/2000 to 6/15/2020 Project file: C:\...\BreakoutStrats_symmetric_with_stops.gpstrat -------------------------------------------------------------------------------} { Strategy inputs } Inputs: NBarEnt1 (78), { Indicator look-back length (bars) } NATR (62), { Indicator look-back length (bars) } EntFr (2.7722), { Multiple of price difference (e.g., ATR); entry } NBarEx1 (63), { Number of bars from entry for market exit } NTarg1 (74), { Indicator look-back length (bars) } TargPts (99.750000), { Number of points for limit price } NBarEx2 (60), { Number of bars from entry for market exit if unprofitable } NBarEx3 (3), { Number of bars from entry for market exit if profitable } NMM1 (80), { Indicator look-back length (bars) } NMM2 (37), { Indicator look-back length (bars) } NStdStop2 (-2.912564), { Number of standard deviations } NMM3 (55), { Indicator look-back length (bars) } MMFr (2.7995), { Multiple of price difference (e.g., ATR); exit } PriceBandSz (0.0000), { Size of price band for limit orders } 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 (200); { Maximum allowable position size } { Variables for average true range for entry and exit orders } Var: AveTR (0); { Variables for entry and exit prices } Var: EntPrL (0), EntPrS (0), TargPrL (0), TargPrS (0), LStop (0), SStop (0), InBandExL(false), InBandExS(false); { Variables for entry and exit conditions } Var: EntCondL (false), EntCondS (false); { Variables for position sizing } Var: NShares (0); { Average true range } AveTR = AvgTrueRange(NATR); { Entry prices } EntPrL = WAverage(L, NBarEnt1) + EntFr * AveTR; EntPrS = WAverage(H, NBarEnt1) - EntFr * AveTR; { Entry and exit conditions } EntCondL = true; EntCondS = true; { 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 and C < EntPrL then begin Buy("EnStop-L") NShares shares next bar at EntPrL stop; end; If MarketPosition = 0 and EntCondS and C > EntPrS 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 = TriAverage(O, NMM1) - MMFr * AbsValue(BollingerBand(L, NMM2, NStdStop2) - TriAverage(O, NMM3)); end; Sell("ExStop-L") next bar at LStop stop; TargPrL = TriAverage(L, NTarg1) + TargPts; InBandExL = AbsValue(TargPrL - C) <= PriceBandSz; If InBandExL then Sell("ExTarg-L") next bar at TargPrL limit; If BarsSinceEntry >= NBarEx1 or (BarsSinceEntry >= NBarEx3 and C > EntryPrice) or (BarsSinceEntry >= NBarEx2 and C < EntryPrice) then Sell("ExMark-L") next bar at market; end; { Exit orders, short trades } If MarketPosition = -1 then begin If BarsSinceEntry = 0 then begin SStop = TriAverage(O, NMM1) + MMFr * AbsValue(BollingerBand(L, NMM2, NStdStop2) - TriAverage(O, NMM3)); end; Buy to cover("ExStop-S") next bar at SStop stop; TargPrS = TriAverage(H, NTarg1) - TargPts; InBandExS = AbsValue(TargPrS - C) <= PriceBandSz; If InBandExS then Buy to cover("ExTarg-S") next bar at TargPrS limit; If BarsSinceEntry >= NBarEx1 or (BarsSinceEntry >= NBarEx3 and C < EntryPrice) or (BarsSinceEntry >= NBarEx2 and C > EntryPrice) then Buy to cover("ExMark-S") next bar at market; end;