RealTest: A Channel Breakout Strategy
This is the RealTest source code to my Channel Breakout Strategy featured in my weekly newsletter.
Check out my other free lessons!Source Code
Notes: Channel Breakout System Based on Courtney Smith's Strategy (from his book: https://amzn.to/3OtvHkH) © Zen & The Art of Trading Pty Ltd This is an example script for educational purposes, and is not to be considered financial advice. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Any advice is considered general advice and has been prepared without taking into account your objectives, financial situation or needs. Because of that, before acting on this advice you should therefore consider the appropriateness of the advice having regard to your situation and your own objectives, financial situation and needs. We recommend you obtain financial, legal and taxation advice before making any financial investment decision. If the advice relates to the acquisition, or possible acquisition, of a product (other than a security e.g. a CFD) then the client should obtain the relevant Product Disclosure Document and consider it before making any decision about whether to acquire the product. Past performance is not a reliable indication of future performance. This material has been prepared based on information believed to be accurate at the time of publication. Subsequent changes in circumstances may occur at any time and may impact the accuracy of the information. All results are considered to be Hypothetical unless otherwise specified: Hypothetical performance results have many inherent limitations. Unlike an actual performance record, simulated results do NOT represent actual trading. Also, since the trades have NOT actually been executed, the results may have under OR over compensated for the impact, if any, of certain market factors, such as lack of liquidity, market spread or commissions among other things that are hard to predict. THE HIGH DEGREE OF LEVERAGE THAT CAN OBTAINED USING MARGIN CAN WORK AGAINST YOU AS WELL AS FOR YOU. THE USE OF LEVERAGE CAN LEAD TO LARGE LOSSES AS WELL AS GAINS. THE RISK OF LOSS WHEN USING MARGIN MAY NOT BE LIMITED. THIS MEANS YOU MAY LOSE MORE THAN THE AMOUNT REQUIRED TO HOLD AND CONTROL THE PARTICULAR SECURITY. Import: DataSource: Norgate IncludeList: .S&P 500 Current & Past // For including all current & historical constituents IncludeList: $SPX // For referencing the SPX price itself in regime filter Constituency: $SPX // For checking if a stock belongs to SPX (historical constituents) StartDate: 1/1/1990 EndDate: Latest SaveAs: ZenChannelBreakout.rtd StartDate: 1/1/1990 EndDate: Latest Settings: DataFile: ZenChannelBreakout.rtd StartDate: 1/1/2000 EndDate: Latest BarSize: Daily UseAvailableBars: False AccountSize: 100000 Currency: USD TopDownMode: True Benchmark: Benchmark_SP500 Side: Long Allocation: S.Equity EntrySetup: Symbol=$$SPX OrderSettings: EndDate: Latest OrdersMode: Template HolidayList: Examples\holidays.txt OrdersTemplate: Examples\ib_basket_template.csv Parameters: Positions: 10 MA_Length: 200 Data: StockMA: EMA(Close, MA_Length) ChannelTop: Highest(High, 55)[1] Filters: MA(Volume, 50) > 500000 and Close > StockMA RegimeFilter: Extern($$SPX, Close > MA(Close , 200)) TradeEntry: InSPX and Close > ChannelTop and Filters TradeRank: 100 - ROC(Close, 20) TrailStop: Low - (ATR(5)) Strategy: Test_RegimeFilter Side: Long Quantity: 100 / Positions QtyType: Percent MaxPositions: Positions EntrySetup: TradeEntry and RegimeFilter ExitRule: If(RegimeFilter, Close < StockMA, Close < Highest(TrailStop, BarsHeld + 1)) ExitTime: NextOpen SetupScore: TradeRank Commission: Max(1.00, 0.005 * Shares) Strategy: Test_NoRegimeFilter Side: Long Quantity: 100 / Positions QtyType: Percent MaxPositions: Positions EntrySetup: TradeEntry ExitRule: Close < StockMA ExitTime: NextOpen SetupScore: TradeRank Commission: Max(1.00, 0.005 * Shares) Charts: // Plot Name {format} formula // On Chart MA_Value: {#} EMA(Close, MA_Length) Chan_TOP: {#} ChannelTop StopLoss: {#} if (BarsHeld > 0, Highest(TrailStop, BarsHeld + 1), nan) // Indicator Pane RegimeFilter: {#^} RegimeFilter // Volume Pane MyVolume: {#|} Volume MyVolumeMin: {#|} 500000 MyVolumeMA: {#|} MA(Volume, 50)