{------------------------------------------------------------------------------- Trading Strategy Code Population member: 257 Max bars back: 119 Created by: Adaptrade Builder version 4.2.1.0 Created: 9/6/2022 4:05:04 PM 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_nonsymmetric_with_stops.gpstrat -------------------------------------------------------------------------------} { Strategy inputs } Inputs: ShiftL1 (19), { Indicator shift value (bars), long trades } NS1 (2), { Level of floor trader pivot function (1 to 3), short trades } NS2 (80), { Indicator look-back length (bars), short trades } EntPtsL (12.500000), { Number of points for stop price, long trades } TargFrL (4.2918), { Multiple of price difference (e.g., ATR); exit, long trades } NBarExL1 (24), { Number of bars from entry for market exit if profitable, long trades } NMML1 (36), { Indicator look-back length (bars), long trades } MMFrL (0.7067), { Multiple of price difference (e.g., ATR); exit, long trades } NBarEntS1 (96), { Indicator look-back length (bars), short trades } EntPtsS (119.500000), { Number of points for stop price, short trades } NMMS1 (8), { Indicator look-back length (bars), short trades } NATRMMS (67), { Indicator look-back length (bars), short trades } MMFrS (3.0900), { Multiple of price difference (e.g., ATR); exit, short trades } NTargS1 (34), { Indicator look-back length (bars), short trades } NBarExS1 (24), { Number of bars from entry for market exit, short trades } 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: ATRMMS (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: VarL1 (0), VarL2 (0), VarS1 (0), VarS2 (0), VarS3 (0), EntCondL (false), EntCondS (false); { Variables for position sizing } Var: NShares (0); { Average true range } ATRMMS = AvgTrueRange(NATRMMS); { Entry prices } EntPrL = O + EntPtsL; EntPrS = XAverage(L, NBarEntS1) - EntPtsS; { Entry and exit conditions } VarL1 = AS_CongestCount[ShiftL1]; VarL2 = AS_CongestCount; VarS1 = AS_PivotR(NS1); VarS2 = XAverage(VarS1, NS2); VarS3 = TypicalPrice; EntCondL = VarL1 <> VarL2; EntCondS = VarS2 <> VarS3; { 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 = Highest(L, NMML1) - MMFrL * TrueRange; end; Sell("ExStop-L") next bar at LStop stop; TargPrL = EntryPrice + TargFrL * TrueRange; InBandExL = AbsValue(TargPrL - C) <= PriceBandSz; If InBandExL then Sell("ExTarg-L") next bar at TargPrL limit; If BarsSinceEntry >= NBarExL1 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(C, NMMS1) + MMFrS * ATRMMS; end; Buy to cover("ExStop-S") next bar at SStop stop; TargPrS = WAverage(L, NTargS1); InBandExS = AbsValue(TargPrS - C) <= PriceBandSz; If InBandExS then Buy to cover("ExTarg-S") next bar at TargPrS limit; If BarsSinceEntry >= NBarExS1 then Buy to cover("ExMark-S") next bar at market; end;