{------------------------------------------------------------------------------- Trading Strategy Code Population member: 68 Max bars back: 1 Created by: Adaptrade Builder version 3.2.0.0 Created: 12/16/2020 1:13:14 PM Scripting language: TradeStation 6 or newer Symbol file: C:\Adaptrade\MarketData\@ES#C 30 Minutes.txt Build dates: 9/3/2012 to 6/14/2017 Project file: C:\Adaptrade\Newsletters\Adaptrade\PricePatterns.gpstrat -------------------------------------------------------------------------------} { Strategy inputs } Inputs: LevEntL1 (1), { Level of floor trader pivot function (1 to 3), long trades } EntFrL (2.7168), { Multiple of price difference (e.g., ATR); entry, long trades } NBarExL1 (51), { Number of bars from entry for market exit, long trades } EntrySzS (900.00), { Value of fixed size entry (stop/limit) per share/contract, short trades } NBarExS1 (13), { Number of bars from entry for market exit if unprofitable, short trades } TrailFlrS (1050.00), { Trailing stop floor value per share/contract, short trades } TrailPctS (53.0000), { Trailing stop percentage, 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), SStop (0), NewSStop (0), STrailOn (false); { 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 = AS_PivotR(LevEntL1) - EntFrL * TrueRange; EntPrS = C + EntrySzS/BigPointValue; { Entry and exit conditions } VarL1 = OpenD(0); VarL2 = CloseD(1); VarS1 = HighD(0); VarS2 = TypicalPrice; 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("EnLimit-L") NShares shares next bar at EntPrL limit; end; If MarketPosition = 0 and EntCondS then begin Sell short("EnLimit-S") NShares shares next bar at EntPrS limit; end; { Exit orders, long trades } If MarketPosition = 1 then begin If BarsSinceEntry >= NBarExL1 then Sell("ExMark-L") next bar at market; end; { Exit orders, short trades } If MarketPosition = -1 then begin If BarsSinceEntry = 0 then begin SStop = Power(10, 10); STrailOn = false; end; If EntryPrice - C > TrailFlrS/BigPointValue then STrailOn = true; If STrailOn then begin NewSStop = EntryPrice - TrailPctS * (EntryPrice - C)/100.0; SStop = MinList(SStop, NewSStop); end; If STrailOn then Buy to cover("ExTrail-S") next bar at SStop stop; If BarsSinceEntry >= NBarExS1 and C > EntryPrice then Buy to cover("ExMark-S") next bar at market; end;