{------------------------------------------------------------------------------- Trading Strategy Code Population member: 229 Max bars back: 68 Created by: Adaptrade Builder version 4.2.0.0 Created: 9/4/2022 6:28:46 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_Keltner.gpstrat -------------------------------------------------------------------------------} { Strategy inputs } Inputs: NBarEnt1 (68), { Indicator look-back length (bars) } NStdEnt1 (0.708396), { Number of standard deviations } NATRMM (1), { Indicator look-back length (bars) } MMFr (1.9030), { Multiple of price difference (e.g., ATR); exit } NBarEx1 (7), { Number of bars from entry for market exit if profitable } 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: ATRMM (0); { Variables for entry and exit prices } Var: EntPrL (0), EntPrS (0), LStop (0), SStop (0); { Variables for entry and exit conditions } Var: EntCondL (false), EntCondS (false); { Variables for position sizing } Var: NShares (0); { Average true range } ATRMM = AvgTrueRange(NATRMM); { Entry prices } EntPrL = KeltnerChannel(H, NBarEnt1, NStdEnt1); EntPrS = KeltnerChannel(L, NBarEnt1, -NStdEnt1); { 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 = EntryPrice - MMFr * ATRMM; end; Sell("ExStop-L") next bar at LStop stop; If BarsSinceEntry >= NBarEx1 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 = EntryPrice + MMFr * ATRMM; end; Buy to cover("ExStop-S") next bar at SStop stop; If BarsSinceEntry >= NBarEx1 and C < EntryPrice then Buy to cover("ExMark-S") next bar at market; end;