The topics that follow provide four simple guided Tutorials that can be used when getting to know RealTest.
There is also a series of tutorial videos on the mhptrading YouTube channel.
The Examples folder (C:\RealTest\Scripts\Examples) contains the following:
Tutorial Scripts
•sample1.rts - simple moving average crossover strategy for SPY (see Tutorial 1)
•sample2.rts - a parameterized version of sample1, allowing for optimization (see Tutorial 2)
•sample2a.rts - a three-parameter version of sample2 (also used in Tutorial 2)
•sample_scan.rts - introduces the Data section and the scanner (see Tutorial 3)
•sector_etfs.rts - implements a monthly rotational strategy for the S&P 500 sector ETFs (see Tutorial 4)
Import Examples
•import_csv.rts - shows how to specify CSV data import (data not provided)
•import_ms.rts - shows how to specify MetaStock data import (data not provided)
•import_multi.rts - shows how to combine data from multiple sources into a single RTD file
•import_norgate.rts - shows how to import data directly from Norgate NDU, and how to access Norgate's index constituency data
•import_tiingo.rts - shows how to import data from Tiingo, if you have an API key
•import_yahoo.rts - shows how to import all the SPX components from Yahoo (see Tutorial 3)
•djia_earnings.rts - shows how to use an Event List File to include earnings dates in your imported data
•djia_make_syminfo.rts - shows how to create a Symbol Information File with Norgate metadata for use with other data sources
•djia_use_syminfo.rts - shows how to use a symbol information file to add metadata to a Yahoo import
•actual_trades.rts - shows how to "test" a list of actual trades using an Imported Trade List file, includes templates for various trade list formats
Scanning Examples
•breadth.rts - shows how to use cross-sectional formulas in the Data Section to calculate and chart a market-breadth indicator
•correl_multi.rts - demonstrates the multi-symbol correlation functions by building a correlation matrix for DJIA constituents
•gics_indu_rank.rts - shows how to find the top X stocks in the top Y industries using GICS classification
•ibd_rs.rts - shows how to calculate IBD's relative strength ranks for any universe of stocks
•index_breadth.rts - shows the best way to calculate breadth statistics using only historical index constituents each day
•industry_indices.rts - shows how to use Norgate's "Corresponding Industry Index" features to know the industry relative strength of any stock
•multi_filter_scan.rts - shows how to write a scan that creates multiple rows per symbol per date with different data in each row
•opex_and_vxex.rts - calculates monthly options expiration and VIX futures expiration dates
•sctr.rts - shows how to calculate "StockCharts Trend Rank" for any universe of stocks
•stockbee_mm.rts - shows how to calculate current and historical values for the Stockbee Market Monitor breadth indicators
Indicators and Techniques
•actual_trades.rts - shows how to "play back" a list of trades from a CSV file
•anchored_vwap.rts - shows how to calculate volume-weighted average price anchored to a specific past date
•annual_taxes.rts - calculates capital gains and dividend income taxes for any script by simply including it at the end
•beta_indicator.rts - shows how to calculate "beta" of individual stocks vs. an index
•dividend_yield_series.rts - shows how to calculate the dividend yield series for all stocks
•ehlers_windows.rts - implements a set of indicators presented by John Ehlers in the Sept. 2021 issue of TASC
•fundamentals.rts - shows how to import and scan for Norgate current fundamentals
•management_fees.rts - calculates management and performance fees for any script by simply including it at the end
•martingale.rts - shows how to allow multiple positions in one symbol within a single strategy
•oc_all_actual.rts - shows how to structure a script to play back OrderClerkTrades.csv with multiple strategies (possibly from different scripts)
•scale_in.rts - shows how to scale into a position as price moves in your favor, keeping risk smaller
•supertrend.rts - shows how to calculate and plot the "supertrend" indicator (dual trailing stops)
•trail_half.rts - shows how to divide a strategy into two half-allocation strategies to implement "take half off at a target and trail the rest"
•yield_rank.rts - shows how to calculate annualized dividend yield from actual dividends and rank stocks by their yields
Single-Strategy Systems
•cii_rotate.rts - shows how to use Norgate's Corresponding Industry Index capability to hold the top 3 stocks of the top 5 industries each month
•clenow_stocks_on_move.rts - implements this strategy from a well-known book (dynamic sizing is done the old way)
•clenow_stocks_on_move_dynamic.rts - implements the same strategy as above using dynamic sizing mode
•dalio_all_weather.rts - implements the Ray Dalio "All-Weather Portfolio"
•dalio_all_weather_maxdiff.rts - same as above but waits for X% difference before rebalancing
•dividend_capture.rts - shows how to use Norgate dividend data and a slightly unusual approach to capturing dividends
•flipper.rts - a simple implementation of the Nick Radge "Flipper" strategy idea
•higher_lows.rts - a trend-following strategy that uses a series of higher pivot lows as an entry signal
•hybrid_asset_allocation.rts - implements this Keller and Keuning monthly ETF rotational strategy
•keller_baa.rts - implements the Keller Bold Asset Allocation monthly ETF rotational strategy
•keltner_pullback.rts - a pullback-after-momentum strategy based on the work of Adam Grimes, uses risk-based position sizing
•ndx_rotate.rts - a simple momentum-based rotational strategy using Nasdaq 100 component stocks
•ndx_rotate_factor_test.rts - shows how to loop through a set of completely different formulas using the optimizer
•ndx_rotate_rebalance.rts - monthly rebalance version using dymanic sizing mode
•ndx_rotate_weekly_reduce.rts - a variation of ndx_rotate that reduces position size during drawdowns
•oex_tf_fresh_signal.rts - simple trend-following strategy that only enters on a "fresh signal"
•optimal_diversity.rts - uses "greedy scoring" to calculate an optimally diversified portfolio from the S&P 100 universe
•radge_bbo.rts - the "BBO" strategy from Holy Grails by Nick Radge
•sector_etfs_breadth.rts - monthly rotation using sector constituent breadth to rank the ETFs
•simple_day_trade.rts - implements a simple long-only "day trading strategy" that enters with limit orders and exits market-on-close (MOC)
•simple_day_trade_basket_orders.rts - shows how easy it is to to generate a daily IB Basket Trader order file for this strategy
•simple_day_trade_basket_scan.rts - shows how produce the same order list using a Scan, in case you ever needed to
•spy_tlt_uis.rts - demonstrates using Walk-Forward optimization to implement a SPY/TLT strategy from an article
•tf_dynamic_size.rts - a simple trend-following strategy that resizes positions when distance from stop changes
•tf_sell_half_at_1R.rts - a simple trend-following strategy that sells half at a 1R target and trails a stop for the remainder
•trend_following_basics.rts - illustrates a variety of stop techniques, risk-based position sizing, and "fresh breakout" detection
•vigilant_asset_allocation.rts - implements this Keller and Keuning monthly ETF rotational strategy
•vxx_long_short.rts - be long or short the VXX ETF depending on VIX term structure
•weekly_moc_asx - a simplified weekly mean-reversion strategy
•weekly_moc_asx_daily_weekly.rts - the above implemented as a weekly strategy within a daily script
•weekly_moc_asx_daily_daily.rts - the above implemented as weekly logic in a daily strategy
•weekly_trend_following.rts - a weekly Russell 1000 trend-following strategy similar to the Nick Radge "Weekend Trend Trader"
Multi-Strategy Systems
•bensdorp_book.rts - an implementation of the strategies described in Automated Stock Trading Systems by Laurens Bensdorp
•combined.rts - demonstrates how to combine strategies that use different symbol universes
•combined_multi_bar_size.rts - shows how strategies in a script can each use their own bar size and refer to external bar sizes
•combined_rebalance.rts - a version of combined.rts that models running each strategy in its own account with periodic transfers
•goal_30_15.rts - a response to a challenge to show a set of strategies with > 30% ROR and < 15% MaxDD (from 2014-2021)
•goal_30_15_asx.rts - a version of the above tailored for the Australian market ($XAO constituents)
•goal_30_15_tsx.rts - a version of the above tailored for the Canadian market ($SPTSXconstituents)
•mhp_classic.rts - provided for those who might be curious about the kinds of strategies Marsten traded in the early 2000s
•multi_moc_top_down.rts - combines four variations of simple_day_trade.rts using top-down setup selection
•oex_tf_top_down.rts - combines three OEX trend-following strategies using top-down setup selection
•two_accounts.rts - compound two strategies together in one account with combined with a third strategy in a separate account
Mean Reversion Theme and Variations
•mr_sample.rts - presents a somewhat sophisticated long/short mean-reversion strategy pair using Norgate data (and an example of "tail risk" in January 2021)
•mr_sample_benchmark.rts - adds a benchmark strategy to the mr_sample example
•mr_sample_common.rts - contains the common elements of the following three examples, each of which includes this script
•mr_sample_debug.rts - demonstrates use of strategy debugging formulas to look under the hood of a running test, and also demonstrates the usefulness of the Library script section
•mr_sample_hedged.rts - adds an index ETF hedge to the mr_sample strategy pair
•mr_sample_orders.rts - shows how to configure this pair of strategies for OrderClerk order generation
•mr_sample_orders_basket.rts - shows how to configure the strategy pair for daily IB Basket Trader order file generation
•mr_sample_scan.rts - demonstrates a possible Daily Setups Scan that could be used with the mr_sample strategy pair
•mr_sample_test_scan.rts - shows how to run a test+scan to generate a set of daily orders
•mr_sample_tracking.rts - shows how to test a strategy that only takes trades when its own equity curve is above a moving average (avoided above mentioned "tail risk"...)
•mr_sample_tracking_alloc.rts - shows how to test a strategy that reduces its allocation when its drawdown increases
•mr_sample_tradelist.rts - shows how to combine strategies from separate scripts by using tradelist generation and playback
•mr_sample_long_only.rts and mr_sample_short_only.rts are also provided for use with the above example
Futures Examples
•cl_term_structure.rts - plots the 8 most recent CL contracts and scans for the 12 most recent ones
•es_compare.rts - using Norgate futures data, tests buy and hold of two continuous contract series (adjusted and unadjusted) vs. rolling through each individual contract
•futures_calendar_spread.rts - shows two ways to construct calendar spreads using Norgate futures data
•futures_trend_follow_simple.rts - simplest trend-following strategy using continuous back-adjusted contract data only
•futures_volume_rank.rts - trend-following strategy that uses #Rank #ByMkt to trade the most active individual contract from each market and roll as needed
•gc_kelly.rts - demonstrates how to model Kelly Criterion position sizing using a simple trend-following strategy for gold futures
•turtles.rts - an approximation of the original "Turtles" futures system, as documented by Curtis Faith
•vx_futures.rts - be long or short the front-month VX futures contract depending on the term structure
•vx_term_structure.rts - illustrates how to plot the entire VX futures term structure in the indicator pane of a $VIX chart
Files Used by Examples Scripts
•actual_trades.csv - the list of trades used in the actual_trades.rts example
•chartist_api_template.csv - order list template file for "The Chartist Smart API" (Nick Radge) output format
•djia_earnings.csv - a sample list of earnings dates for the DJIA components since 1/1/2019 (not guaranteed to be accurate)
•djia_info.csv - a detailed symbol information metadata file for the DJIA components
•djia_syms.txt - symbols of the current DJIA components
•holidays.au.txt - example Australian market HolidayList file to use when generating orders
•holidays.us.txt - example US market HolidayList file to use when generating orders (or simply use HolidayList: us_auto)
•ib_basket_template.csv - order list template file for IB Basket Trader output format
•spx_syms.txt - symbols of the current S&P 500 components
|