A Simply SPY Pullback Strategy in RealTest
This lesson demonstrates how to convert a Pine Script system into RealTest's code and run some basic backtests, including optimization of specific parameters.
Check out my other free lessons!Source Code
Notes: A simple SPY ETF pullback system based on an old Pine Script lesson: https://courses.theartoftrading.com/pages/a-simple-pullback-strategy-in-pine-script ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Import: //! NORGATE // DataSource: Norgate // IncludeList: .SPY_ETF // SaveAs: spy_norgate.rtd //! YAHOO DataSource: Yahoo IncludeList: SPY SaveAs: spy_yahoo.rtd // Dates StartDate: Earliest EndDate: Latest Settings: DataFile: spy_yahoo.rtd //! YAHOO //DataFile: spy_norgate.rtd //! NORGATE StartDate: Earliest // 1/1/2009 TRADINGVIEW | 29/1/1993 YAHOO EndDate: Latest BarSize: Daily UseAvailableBars: False Currency: USD AccountSize: 100000 Parameters: // Beat Benchmark: AccountBalancePct: from 100 to 200 step 50 def 100 // 150x MA_Slow_Length: from 100 to 200 step 50 def 200 // 200 MA_Fast_Length: from 5 to 50 step 25 def 10 // 10 Stop_Percent_Range: from 0.1 to 0.2 step 0.05 def 0.1 // 10% Data: MA_Slow: MA(Close, MA_Slow_Length) MA_Fast: MA(Close, MA_Fast_Length) LongSetup: Close > MA_Slow and Close < MA_Fast SellCondition: Close > MA_Fast Strategy: SimplePullbackStrategy Commission: 0.005 * Shares Side: Long Quantity: AccountBalancePct QtyType: Percent MaxPositions: 1 EntrySetup: LongSetup ExitRule: SellCondition or Close < FillPrice * (1 - Stop_Percent_Range) Benchmark: Benchmark_SPY Side: Long Allocation: S.Equity EntrySetup: Symbol=$SPY Charts: // Chart drawings MA_Slow: {#} MA_Slow MA_Fast: {#} MA_Fast StopLoss: {#} FillPrice * (1 - Stop_Percent_Range)