Here is this month's selection of Traders' Tips, contributed by various developers of technical analysis software to help readers more easily implement some of the strategies presented in this and other issues. October 2007
TRADERS' TIPSYou can copy these formulas and programs for easy use in your spreadsheet or analysis software. Simply "select" the desired text by highlighting as you would in any word processing program, then use your standard key command for copy or choose "copy" from the browser menu. The copied text can then be "pasted" into any open spreadsheet or other software by selecting an insertion point and executing a paste command. By toggling back and forth between an application window and the open Web page, data can be transferred with ease.
This month's tips include formulas and programs for:
TRADECISION: Accumulated Range Ratio Indicator
METASTOCK: Accumulated Range Ratio Indicator
TRADESTATION: Accumulated Range Ratio Indicator
eSIGNAL: Accumulated Range Ratio Indicator
AMIBROKER: Tandem Studies On Market Movement
WEALTH-LAB: Tandem Studies On Market Movement
AIQ: Tandem Studies On Market Movement
STRATASEARCH: Tandem Studies On Market Movement
SWINGTRACKER: Accumulated Range Ratio Indicator
TD AMERITRADE'S StrategyDesk: Tandem Studies On Market Movement
VT TRADER: Moving Average Triosor return to October 2007 Contents
TRADECISION: Accumulated Range Ratio Indicator
Editor's note: Code for Tradecision is already included in Dima Vonko's article in this issue, "Tandem Studies On Market Movement." The code in Improvian language implements the parameter values for the primary phase (the trend), secondary phase (the correction), and resulting ratio. The code can be used directly in Tradecision's Phase Rover.
METASTOCK: Accumulated Range Ratio IndicatorDima Vonko's article in this issue, "Tandem Studies On Market Movement," describes the calculation and use of the accumulated range ratio indicator for bull markets. The formula for this indicator and the instructions for adding it to MetaStock follow.
To enter these indicators into MetaStock:
1. In the Tools menu, select Indicator Builder.
2. Click New to open the Indicator Editor for a new indicator.
3. Type the name of the formula.
4. Click in the larger window and type in the formula.
5. Click OK to close the Indicator Editor.Name: Accumulated Range Ratio Bull
Formula:
smd:=Input("Month and Day at start of the trend [ mmdd ]",1,1235,103); sy:=Input("year at start of the trend [ yyyy ]",1,3235,2007); cmd:=Input("Month and Day at start of the correction [ mmdd ]",1,1235,103); cy:=Input("year at start of the correction [ yyyy ]",1,3235,2007); emd:=Input("Month and Day at end of the correction [ mmdd ]",1,1235,103); ey:=Input("year at end of the correction [ yyyy ]",1,3235,2007); sdt:= (Month()=Int(smd/100)) AND (DayOfMonth()=Rnd(Frac(smd/100)*100)) AND (Year()=sy); cdt:=(Month()=Int(cmd/100)) AND (DayOfMonth()=Rnd(Frac(cmd/100)*100)) AND (Year()=cy); edt:= (Month()=Int(emd/100)) AND (DayOfMonth()=Rnd(Frac(emd/100)*100)) AND (Year()=ey); tsum:=Cum(If(BarsSince(sdt)>=0,H-ValueWhen(1,sdt,L),0)); csum:=Cum(If(BarsSince(cdt)>=0,ValueWhen(1,cdt,H)-L,0)); LastValue(ValueWhen(1,edt,csum)/ValueWhen(1,cdt,tsum))
This indicator will prompt for three dates: the start of the trend; the start of the correction; and the end of the correction. After entering all three values, it will plot a flat line at the value of the ratio.--William Golson
Equis International
www.metastock.com
TRADESTATION: Accumulated Range Ratio IndicatorDima Vonko's article in this issue, "Tandem Studies On Market Movement," describes a technique for evaluating the last two market phases and using the results to filter long entries. The article stresses expert visual inspection of the price data for phase delineation. It also suggests a mechanical, long-only trading technique based on two moving averages. The code given here implements Vonko's suggestions.
FIGURE 1: TRADESTATION, ACCUMULATION RANGE RATIO. In this sample TradeStation chart, the TandemStudy strategy is applied to a daily chart of IBM. The gray lines display the short and long moving averages, which define market phases. To simplify the display, the IBM price data is plotted as a line connecting the daily closing prices.Four phases are defined by the relative positions of the current close and two moving averages. Long positions are entered only while the shorter-duration moving average is above the longer-duration average. If the close crosses over the shorter average, a strong upward phase has been entered, according to Vonko. If the close crosses under the shorter moving average, a weak phase has been entered. The duration of each phase is recorded and used to produce an "accumulation range ratio." This ratio filters possible entries at the beginning of a new strong upward phase. Finally, the duration of the primary phase is used as another entry filter. The code allows for optimization of the two average lengths, the accumulation range threshold, and the duration weight.To download the code, go to the Support Center at TradeStation.com. Search for the file "Tandem.ELD." TradeStation does not endorse or recommend any particular strategy.
Strategy: TandemStudy inputs: Price( Close ), LongAvgLen( 50 ), ShortAvgLen( 5 ), AccumRatioThreshold( 1 ) ; variables: LongAvg( 0 ), ShortAvg( 0 ), PhaseNum( 0 ), TL_ID( 0 ), PrimaryPhaseStren( 0 ), SecondaryPhaseStren( 0 ), AccumRangeRatio( 0 ), PrimaryPhaseNum( 0 ), SecondaryPhaseNum( 0 ), PrimaryBarCount( 0 ), SecondaryBarCount( 0 ), PhaseBarCount( 0 ), PhaseStrength( 0 ), PhasePivot( 0 ), SwingPrice( 0 ) ; LongAvg = XAverage( Price, LongAvgLen ) ; ShortAvg = XAverage( Price, ShortAvgLen ) ; if Close > ShortAvg then PhaseNum = iff( ShortAvg > LongAvg, 1, 3 ) else PhaseNum = iff( ShortAvg > LongAvg, 2, 4 ) ; TL_ID = TL_New( Date[1], Time[1], ShortAvg[1], Date, Time, ShortAvg ) ; TL_SetColor( TL_ID, LightGray ) ; TL_ID = TL_New( Date[1], Time[1], LongAvg[1], Date, Time, LongAvg ) ; TL_SetColor( TL_ID, DarkGray ) ; if PhaseNum <> PhaseNum[1] then begin if PrimaryPhaseStren <> 0 then AccumRangeRatio = SecondaryPhaseStren / PrimaryPhaseStren ; PrimaryPhaseNum = SecondaryPhaseNum[1] ; SecondaryPhaseNum = PhaseNum[1] ; PrimaryPhaseStren = SecondaryPhaseStren ; SecondaryPhaseStren = PhaseStrength[1] ; if PhaseNum = 1 and SecondaryPhaseNum = 2 and PrimaryPhaseNum = 1 and AccumRangeRatio > AccumRatioThreshold and Average( Close, PrimaryBarCount * 1.5 ) < Close and Close > ShortAvg then Buy this bar Close ; PrimaryBarCount = SecondaryBarCount ; SecondaryBarCount = PhaseBarCount ; PhaseBarCount = 1 ; if PhaseNum <= 2 then begin PhasePivot = Low ; PhaseStrength = High - PhasePivot ; end else begin PhasePivot = High ; PhaseStrength = PhasePivot - Low ; end ; end else begin PhaseBarCount = PhaseBarCount + 1 ; if PhaseNum <= 2 then PhaseStrength = PhaseStrength + High - PhasePivot else PhaseStrength = PhaseStrength + PhasePivot - Low ; end ; if Close crosses under ShortAvg and MarketPosition = 1 then Sell next bar at market ;--Mark Mills
TradeStation Securities, Inc.
A subsidiary of TradeStation Group, Inc.
www.TradeStation.com
eSIGNAL: Accumulated Range Ratio IndicatorFor this month's Traders' Tip, we've provided the eSignal formula code named "AccumulatedRRB.efs," based on the code provided in Dima Vonko's article in this issue, "Tandem Studies On Market Movement."
The eSignal study contains formula parameters that may be configured through the Edit Studies option in the Advanced Chart to change the color and line thickness of the indicator (Figure 2).
FIGURE 2: eSIGNAL, ACCUMULATED RANGE RATIO. Here is the AccumulatedRRB based on Dima Vonko's article in this issue. The final result was multiplied it by 100 for decimal display purposes in the Advanced Chart.We took the final result of the indicator and multiplied it by 100 for decimal display purposes in the Advanced Chart.To discuss this study or download a complete copy of the formula, please visit the EFS Library Discussion Board forum under the Forums link at www.esignalcentral.com or visit our EFS KnowledgeBase at www.esignalcentral.com/support/kb/efs/. The eSignal formula scripts (EFS) are also available for copying and pasting from the STOCKS & COMMODITIES website at www.Traders.com.
/*************************************** Provided By : eSignal (Copyright © eSignal), a division of Interactive Data Corporation. 2007. All rights reserved. This sample eSignal Formula Script (EFS) is for educational purposes only and may be modified and saved under a new file name. eSignal is not responsible for the functionality once modified. eSignal reserves the right to modify and overwrite this EFS file with each new release. Description: Tandem Studies On Market Movement by Dima Vonko Version 1.0 8/6/2007 Notes: * Study requires version 8.0 or later. Formula Parameters: Default: ***************************************/ function preMain() { setStudyTitle("Accumulated Range Ratio Bull "); setShowTitleParameters(false); setCursorLabelName("ARRB", 0); var fp1 = new FunctionParameter("cColor", FunctionParameter.COLOR); fp1.setName("Color"); fp1.setDefault(Color.blue); var fp2 = new FunctionParameter("nThick", FunctionParameter.NUMBER); fp2.setName("Thickness"); fp2.setLowerLimit(1); fp2.setDefault(2); } // Global Variables var bVersion = null; // Version flag var bInit = false; // Initialization flag // globals for PrimaryPhaseValue calculation: var xPrimary = null; var firstBarLow = null; var nPsum = 0; var nPsum_1 = 0; // globals for SecondaryPhaseValue calculation: var xSecondary = null; var firstBarHigh = null; var nSsum = 0; var nSsum_1 = 0; function main(cColor, nThick) { if (bVersion == null) bVersion = verify(); if (bVersion == false) return; //Initialization if (bInit == false) { setDefaultBarFgColor(cColor, 0); setDefaultBarThickness(nThick, 0); xPrimary = efsInternal("calcP"); xSecondary = efsInternal("calcS"); bInit = true; } var nPrimaryPhase = xPrimary.getValue(0); var nSecondaryPhase = xSecondary.getValue(0); if (nPrimaryPhase == null || nSecondaryPhase == null) return; // AccumulatedRangeRatioBull var nARRB = nSecondaryPhase / nPrimaryPhase; return nARRB*100; } function calcP() { if (getCurrentBarCount() == 1) { firstBarLow = low(0); nPsum = high(0) - firstBarLow; nPsum_1 = nPsum; } else { if (getBarState() == BARSTATE_NEWBAR) { nPsum_1 = nPsum; } firstBarLow = low(-1); nPsum = nPsum_1 + (high(0) - firstBarLow); } return nPsum; } function calcS() { if (getCurrentBarCount() == 1) { firstBarHigh = high(0); nSsum = firstBarHigh - low(0); nSsum_1 = nSsum; } else { if (getBarState() == BARSTATE_NEWBAR) { nSsum_1 = nSsum; } firstBarHigh = high(-1); nSsum = nSsum_1 + (firstBarHigh - low(0)); } return nSsum; } function verify() { var b = false; if (getBuildNumber() < 779) { drawTextAbsolute(5, 35, "This study requires version 8.0 or later.", Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT, null, 13, "error"); drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=https://www.esignal.com/download/default.asp", Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT, null, 13, "upgrade"); return b; } else { b = true; } return b; }--Jason Keck
eSignal, a division of Interactive Data Corp.
800 815-8256, www.esignalcentral.com
AMIBROKER: TANDEM STUDIES ON MARKET MOVEMENTThis month we present direct translation of the code provided in the "Tandem Studies On Market Movement" article by Dima Vonko to AmiBroker Formula Language. We expanded the code to include separate plots for the primary phase (green), secondary phase (red), and accumulated range ratio (blue). To use the formula, type it in Formula Editor, then press the "Apply indicator" button. Click on a chart to select the beginning of the trend, then press the F12 key. Then click on a chart again to select the beginning of the correction phase and press the Shift+F12 keys.
AmiBroker code: function PrimaryPhaseValue( start ) { firstBarLow = ValueWhen( start, Low ); return Sum( High - firstBarLow, 1 + BarsSince( start ) ); } function SecondaryPhaseValue( start ) { firstBarHigh = ValueWhen( start, High ); return Sum( firstBarHigh - Low, 1 + BarsSince( start ) ); } starttrend = DateTime() == BeginValue( DateTime() ); startcorrection = DateTime() == EndValue( DateTime() ); pp = PrimaryPhaseValue( starttrend ); sp = SecondaryPhaseValue( startcorrection ); AccumulatedRangeRatioBull = sp / pp; Plot( AccumulatedRangeRatioBull, "AccumulatedRangeRatioBull", colorBlue ); Plot( pp, "Primary Phase", colorGreen, styleOwnScale ); Plot( sp, "Secondary Phase", colorRed, styleOwnScale ); SetBarsRequired( 0, 0 );--Tomasz Janeczko, AmiBroker.comGO BACK
www.amibroker.com
WEALTH-LAB: Tandem Studies On Market MovementAs Dima Vonko noted in his article in this issue, "Tandem Studies On Market Movement," his formulas "presuppose the correct selection of the turning points." That is, either the trader has to provide his/her own interpretation of a chart, carefully segmenting it into "market phases," or the trading system has to locate those turning points automatically.
At Wealth-Lab, we are more interested in providing automated analysis tools to help avoid discretionary trading, while also enabling a rigorous approach to backtesting.
Here is a template for a small ChartScript that does a preliminary segmentation of a chart, based on a simple yet seemingly effective rule: a "market phase" stays the same as long as prices do not move too far away from a linear regression estimate.
When that happens, lines are drawn on the chart, showing the phase's average slope, and Dima Vonko's phase values are computed and placed above/below the last bar. And a new phase is started.
As simple as it is, one can already use this tool to have a visual feeling of how "tandems" would work.
From there on, adding actual tandem analysis should be (in principle) a simple task of collecting statistics on adjacent phase pairs, provided that this preliminary segmentation gives satisfactory results on the securities at hand.
See Figure 3.
FIGURE 3: WEALTH-LAB, TANDEM STUDIES ON MARKET MOVEMENT. Here is a visual rendering of a chart segmentation into market phases.WealthScript code: var Bar, FirstBar, b: integer; var UpPhaseValue: float = 0; var DownPhaseValue: float = 0; for Bar := 5 to BarCount - 1 do begin if Bar < FirstBar + 5 then continue; if (PriceAverage(Bar) < LinearReg(Bar - 1, #Average, Bar - FirstBar) + LinearRegSlope(Bar - 1, #Average, Bar - FirstBar) - 2 * StdError(Bar, #Average, Bar - FirstBar)) or (Bar = BarCount - 1) then begin if LinearRegSlope(Bar - 1, #Average, Bar - FirstBar) > 0 then begin DrawLine(FirstBar, LinearRegLine(#Average, FirstBar, Bar - 1, FirstBar), Bar - 1, LinearRegLine(#Average, FirstBar, Bar - 1, Bar - 1), 0, #Blue, #Thick); // UpPhaseValue calculation: var FirstBarLow: float = PriceLow(FirstBar); UpPhaseValue := 0; for b := FirstBar to Bar - 1 do UpPhaseValue := UpPhaseValue + PriceHigh(Bar) - FirstBarLow; AnnotateBar(FormatFloat('0.00', UpPhaseValue), Bar - 1, true, #Black, 8); end; FirstBar := Bar; end else if (PriceAverage(Bar) > LinearReg(Bar - 1, #Average, Bar - FirstBar) + LinearRegSlope(Bar - 1, #Average, Bar - FirstBar) + 2 * StdError(Bar, #Average, Bar - FirstBar)) or (Bar = BarCount - 1) then begin if LinearRegSlope(Bar - 1, #Average, Bar - FirstBar) < 0 then begin DrawLine(FirstBar, LinearRegLine(#Average, FirstBar, Bar - 1, FirstBar), Bar - 1, LinearRegLine(#Average, FirstBar, Bar - 1, Bar - 1), 0, #Red, #Thick); // DownPhaseValue calculation: var FirstBarHigh: float = PriceHigh(FirstBar); DownPhaseValue := 0; for b := FirstBar to Bar - 1 do DownPhaseValue := DownPhaseValue + FirstBarHigh - PriceLow(Bar); AnnotateBar(FormatFloat('0.00', DownPhaseValue), Bar - 1, false, #Black, 8); end; FirstBar := Bar; end; end;-- Giorgio BeltrameGO BACK
www.wealth-lab.com
AIQ: Tandem Studies On Market MovementHere, we'll discuss the AIQ code for analyzing tandem bullish phases as described by Dima Vonko in his article in this issue, "Tandem Studies on Market Movement." Vonko mentions but does not provide a mechanical method for identification of a bullish phase and related correction. Instead he relies on subjective chart reading to identify the turning points for the phase analysis.
Since I do not subscribe to subjective analysis and always base my trading on mechanical systems, I attempted to define a bullish phase by using pivot point strength and the special moving average that the author discusses (SMALMT). I used this moving average, which is equal to the length of the current bullish phase times 1.5, as a basis for gauging whether the bullish phase was still in place and where the bullish phase might have begun. When the price crosses above SMALMT, a new bullish phase has begun and the subsequent corrections must have lows that do not penetrate below SMALMT.
I first applied this analysis to the S&P 500 and adjusted the pivot strength so that the second pivot low back from the current date fell below SMALMT and the first pivot low back held above the SMALMT. In addition, the bullish phase definition that I defined requires that the first low pivot be greater than the second low pivot and the first high pivot be higher than the second pivot high.
When I applied all these rules to the S&P 500, I captured an overall bullish phase that began 6/14/06 and is still active as of 8/10/07. Within this major uptrend, there are two bullish sub-phases (06/14/06 to 02/22/07 and 03/14/07 to 07/16/07) and two corrective phases (02/22/07 to 03/14/07 and 07/16/07 to 08/10/07). As of 8/10/07, the second corrective phase was still ongoing. I then applied the same rules and settings to a list of the most active 2,000+ stocks to find those that were following the pattern of the S&P 500 index. Of these 2,000+ stocks, only 54 (2.5%) were still in the bullish phase that matched the S&P 500 pattern as of 8/10/07.
Figure 4 displays Apple Inc. (AAPL), which is in the top 10% of the 54 stocks with bullish chart patterns. Note that a smaller AccumulatedRangeRatioBull (ARRB) indicates a stronger tandem phase relationship. In the table in Figure 6, I show the comparison of AAPL to the S&P 500 (SPX) and to Activision Inc. (ATVI, Figure 5, which is in the bottom 10% of the 54 stocks with bullish chart patterns). AAPL is stronger than the SPX because both the prior ARRB (labeled ARRB1) and the current ARRB are smaller than the SPX ARRB. This table also shows that ATVI is weaker than both AAPL and the SPX ARRB in the current correction phase because the ARRB is larger than that of the SPX and AAPL. ATVI, in the prior tandem sub-phase, was stronger than the SPX but weaker than AAPL.
FIGURE 4: AIQ, ACCUMULATED RANGE RATIO BULL ON AAPL (TOP 10%). This demonstrates mechanical identification of the major phase and four subphases with the ARBB indicator computed for each subphase.The code can be downloaded from the AIQ website at www.aiqsystems.com and also from www.tradersedge systems.com/traderstips.htm. It can also be copied and pasted from the STOCKS & COMMODITIES website at www.Traders.com.FIGURE 5: AIQ, ACCUMULATED RANGE RATIO BULL ON ATVI (BOTTOM 10%). This demonstrates mechanical identification of the major phase and four subphases with the ARBB indicator computed for each subphase.
--Richard Denning
AIQ Systems
richard.denning@earthlink.net
STRATASEARCH: Tandem Studies On Market MovementTandem studies are an excellent idea, and author Dima Vonko has done a fine job of explaining their benefits in his article in this issue, "Tandem Studies On Market Movement."
It is indeed true that an indicator such as the relative strength index (RSI) may behave differently depending on the events that preceded the RSI signal. And while the use of supporting indicators within a trading system can help, supporting indicators are often adjusted to ignore noise and will therefore not provide sufficient data for analyzing those prior events.
Our tests of the AccumulatedRangeRatioBull showed it to be quite helpful. And while its benefits were primarily seen on position entry rather than position exit, its use clearly helped improve prediction of upcoming market conditions. Even further, after running a variety of tests, we also discovered this indicator can have multiple uses. For example, it can be used to identify a continuation of a trend, or it can be used to alert the trader to potential reversals.
As with all Traders' Tips, a plug-in containing the code for the AccumulatedRangeRatioBull can be downloaded from the Shared Area of our user forum. In addition, this month's plug-in contains a number of trading rules that can be included in your automated search for trading systems. Simply install the plug-in, start your search, and let StrataSearch identify whether this indicator can improve your trading systems.
//**************************************************************** // Primary Phase Value //**************************************************************** days = parameter("Days"); PrimaryPhaseValue = sum(high, days) - (ref(low, -(days+1)) * days); //**************************************************************** // Secondary Phase Value //**************************************************************** days = parameter("Days"); SecondaryPhaseValue = (ref(high, -(days+1)) * days) - sum(low, days); //**************************************************************** // Accumulated Range Ratio Bull //**************************************************************** shortdays = parameter("Short Days"); longdays = parameter("Long Days"); AccumulatedRangeRatioBull = SecondaryPhaseValue(shortdays) / ref(PrimaryPhaseValue(longdays), -shortdays);
FIGURE 7: STRATASEARCH, TANDEM STUDIES ON MARKET MOVEMENT. Since the price is staying above its long-term moving average, and the AccumulatedRangeRatioBull line is staying within the threshold, this indicates that the trend has not been broken.
--Pete RastGO BACK
Avarin Systems, Inc.
www.StrataSearch.com
SWINGTRACKER: Accumulated Range Ratio IndicatorWe have added Dima Vonko's accumulated range ratio bull indicator to SwingTracker 5.13 for Windows/Mac/Linux based on his article in this issue, "Tandem Studies On Market Movement." It uses the DMI for trend filtering. The only parameter for this indicator is the color. A sample chart is shown in Figure 8.
FIGURE 8: SWINGTRACKER, TANDEM STUDIES ON MARKET MOVEMENT. Here is an example of Dima Vonko's accumulated range ratio bull indicator in SwingTracker. It uses the DMI for trend filtering.To discuss this tool, please visit our forum at forum.mrswing.com. For support, our development staff will be happy to help at support.mrswing.com. To view the code, go to the Traders' Tips area of www.Traders.com.For more information on our free trial, visit www.swingtracker.com.
--Larry SwingGO BACK
281 968-2718, theboss@mrswing.com
www.mrswing.com
TD AMERITRADE'S STRATEGYDESK: Tandem Studies On Market MovementIn this issue, Dima Vonko discusses using tandem studies to assist in determining the strength of a new market phase. The formula for calculating a parameter value in TD Ameritrade's StrategyDesk is given here.
The following formula can be used for backtesting or program trading:
((Y * Bar[High,D,Y-1]) - (Y * MovingAverage[MA,Low,Y,0,D])) / ((X * MovingAverage[MA,High,X,0,D,Y]) - (X * Bar[Low,D,X+Y-1])) >= .382 AND Bar[High,D,Y-1] > MovingAverage[MA,Low,Y,0,D] AND MovingAverage[MA,High,X,0,D,Y] > Bar[Low,D,X+Y-1]
In this formula, the variable X refers to the number of periods in the initial trend, and Y refers to the number of periods in the correction. For example, if the trend lasted 20 periods and the correction lasted seven, the formula would read:
((7 * Bar[High,D,6]) - (7 * MovingAverage[MA,Low,7,0,D])) / ((20 * MovingAverage[MA,High,20,0,D,7]) - (20 * Bar[Low,D,26])) >= .382 AND Bar[High,D,6] > MovingAverage[MA,Low,7,0,D] AND MovingAverage[MA,High,20,0,D,7] > Bar[Low,D,26]
As Vonko suggests in the article, the threshold value of 0.382 is used in the above formula. This value can be changed to indicate a stronger or weaker move. The formula will be calculated as listed, based on daily intervals. StrategyDesk offers simple overrides for changing the intervals if you prefer to test a different period.See Figure 9 for a sample chart. Channels have been drawn to demonstrate the initial trend and correction. The buy signal is reflected on the day where the result of the formula above exceeds 0.382.
FIGURE 9: STRATEGYDESK, TANDEM STUDIES ON MARKET MOVEMENT. Channels have been drawn to demonstrate the initial trend and correction. The buy signal is reflected on the day where the result of the formula exceeds 0.382.To set up a custom indicator in a Level I window or a watchlist, we simply remove the comparison and calculate the parameter value based on the high/low ranges:
((Y * Bar[High,D,Y-1]) - (Y * MovingAverage[MA,Low,Y,0,D])) / ((X * MovingAverage[MA,High,X,0,D,Y]) - (X * Bar[Low,D,X+Y-1]))
Using the same 20 and seven daily periods from above, we've provided an example in a Level I window in Figure 10 (shown for illustrative purposes only). FIGURE 10: STRATEGYDESK, TANDEM STUDIES ON MARKET MOVEMENT. Using the same 20 and seven daily periods from Figure 9, here's an example in a Level I window.If you have questions about this formula or functionality, please call TD Ameritrade's StrategyDesk free help line at 800 228-8056, or access the Help Center via the StrategyDesk application. StrategyDesk is a downloadable application free for all TD Ameritrade clients. A brokerage account is required and regular commission rates apply. For more information, visit www.tdameritrade.com.TD Ameritrade and StrategyDesk do not endorse or recommend any particular trading strategy.
--Jeff Anderson
TD AMERITRADE Holding Corp.
www.tdameritrade.com
VT TRADER: Moving Average TriosFor this month's Traders' Tip, we will revisit the August 2007 issue of STOCKS & COMMODITIES and David Penn's article, "Moving Average Trios." In the article, Penn discusses several ways to use combinations of three moving averages to "find the sweet spot in a market move." We've adapted the bullish/bearish alignment with a price follow-through method for use with VT Trader.
The rules for this trading system are simple. Enter a long trade when the current market price crosses above the highest price obtained during the first bar when the moving averages entered bullish alignment (short MA > medium MA > long MA). Exit the long trade when the short MA crosses below the medium MA. Enter a short trade when the current market price crosses below the lowest price obtained during the first bar when the moving averages entered bearish alignment (short MA < medium MA < long MA). Exit the short trade when the short MA crosses above the medium MA.
We'll be offering two versions of the moving average trio trading system for download in our user forums. The VT Trader code and instructions for creating it are as follows (input variables are parameterized to allow customization):1. Navigator Window>Tools>Trading Systems Builder>[New] button 2. In the Indicator Bookmark, type the following text for each field: Name: TASC - 10/2007 - Moving Average Trios Short Name: vt_MAT Label Mask: TASC - 10/2007 - Moving Average Trios (Short MA: %pr1%,%tp1%,%mTp1% | Medium MA: %pr2%,%tp2%,%mTp2% | Long MA: %pr3%,%tp3%,%mTp3%) 3. In the Input Bookmark, create the following variables: [New] button... Name: pr1 , Display Name: Short MA Price , Type: price , Default: Close [New] button... Name: tp1 , Display Name: Short MA Periods , Type: integer , Default: 10 [New] button... Name: mTp1 , Display Name: Short MA Type , Type: MA Type , Default: Exponential [New] button... Name: pr2 , Display Name: Medium MA Price , Type: price , Default: Close [New] button... Name: tp2 , Display Name: Medium MA Periods , Type: integer , Default: 20 [New] button... Name: mTp2 , Display Name: Medium MA Type , Type: MA Type , Default: Exponential [New] button... Name: pr3 , Display Name: Long MA Price , Type: price , Default: Close [New] button... Name: tp3 , Display Name: Long MA Periods , Type: integer , Default: 50 [New] button... Name: mTp3 , Display Name: Long MA Type , Type: MA Type , Default: Exponential 4. In the Formula Bookmark, copy and paste the following formula: {Provided By: Capital Market Services, LLC & Visual Trading Systems, LLC (c) Copyright 2007} {Description: TASC, August 2007 - Moving Average Trios by David Penn} {vt_MAT Version 1.0} {Control Error} Err:= (tp1=0) or (tp2=0) or (tp3=0); {Moving Averages} ShortMA:= mov(pr1,tp1,mTp1); MediumMA:= mov(pr2,tp2,mTp2); LongMA:= mov(pr3,tp3,mTp3); {Define Final Trade Entry/Exit Criteria} LongEntryCond1:= ShortMA>MediumMA AND MediumMA>LongMA; LongEntryCond2:= LongTradeAlert=0 AND ShortTradeAlert=0 AND Cross(LongEntryCond1,0.5); LongEntryLevel:= valuewhen(1,LongEntryCond2,H); LongEntrySetup:= LongEntryCond1=1 AND Cross(C,LongEntryLevel); LongExitSetup:= Cross(MediumMA,ShortMA); ShortEntryCond1:= ShortMA<MediumMA AND MediumMA<LongMA; ShortEntryCond2:= LongTradeAlert=0 AND ShortTradeAlert=0 AND Cross(ShortEntryCond1,0.5); ShortEntryLevel:= valuewhen(1,ShortEntryCond2,L); ShortEntrySetup:= ShortEntryCond1=1 AND Cross(ShortEntryLevel,C); ShortExitSetup:= Cross(ShortMA,MediumMA); {Draw Entry/Exit Signals on Chart} LongEntrySignal:= (NOT Err AND LongTradeAlert=0 AND ShortTradeAlert=0 AND LongEntrySetup) OR (NOT Err AND LongTradeAlert=0 AND Cross(0.5,ShortTradeAlert) AND LongEntrySetup) OR (NOT Err AND LongTradeAlert=0 AND ShortExitSetup AND LongEntrySetup); LongExitSignal:= (LongTradeAlert=1 AND LongExitSetup); ShortEntrySignal:= (NOT Err AND ShortTradeAlert=0 AND LongTradeAlert=0 AND ShortEntrySetup) OR (NOT Err AND ShortTradeAlert=0 AND Cross(0.5,LongTradeAlert) AND ShortEntrySetup) OR (NOT Err AND ShortTradeAlert=0 AND LongExitSetup AND ShortEntrySetup); ShortExitSignal:= (ShortTradeAlert=1 AND ShortExitSetup); {Simulated Open Trade Determination and Trade Direction} LongTradeAlert:= SignalFlag(LongEntrySignal,LongExitSignal); ShortTradeAlert:= SignalFlag(ShortEntrySignal,ShortExitSignal); {Create Auto-Trading Functionality} OpenBuy:= LongEntrySignal and (eventCount('OpenBuy')=eventCount('CloseBuy')); CloseBuy:= LongExitSignal and (eventCount('OpenBuy')>eventCount('CloseBuy')); OpenSell:= ShortEntrySignal and (eventCount('OpenSell')=eventCount('CloseSell')); CloseSell:= ShortExitSignal and (eventCount('OpenSell')>eventCount('CloseSell')); 5. In the Output Bookmark, create the following variables: [New] button... Var Name: ShortMA Name: Short MA * Checkmark: Indicator Output Select Indicator Output Bookmark Color: blue Line Width: thin Line Style: solid Placement: Price Frame [OK] button... [New] button... Var Name: MediumMA Name: Medium MA * Checkmark: Indicator Output Select Indicator Output Bookmark Color: red Line Width: thin Line Style: solid Placement: Price Frame [OK] button... [New] button... Var Name: LongMA Name: Long MA * Checkmark: Indicator Output Select Indicator Output Bookmark Color: green Line Width: slightly thicker Line Style: solid Placement: Price Frame [OK] button... [New] button... Var Name: LongEntrySignal Name: LongEntrySignal Description: Long Entry Signal Alert * Checkmark: Graphic Enabled * Checkmark: Alerts Enabled Select Graphic Bookmark Font [...]: Up Arrow Size: Medium Color: Blue Symbol Position: Below price plot Select Alerts Bookmark Alerts Message: Long Entry Signal! Choose sound for audible alert [OK] button... [New] button... Var Name: LongExitSignal Name: LongExitSignal Description: Long Exit Signal Alert * Checkmark: Graphic Enabled * Checkmark: Alerts Enabled Select Graphic Bookmark Font [...]: Exit Sign Size: Medium Color: Blue Symbol Position: Above price plot Select Alerts Bookmark Alerts Message: Long Exit Signal! Choose sound for audible alert [OK] button... [New] button... Var Name: ShortEntrySignal Name: ShortEntrySignal Description: Short Entry Signal Alert * Checkmark: Graphic Enabled * Checkmark: Alerts Enabled Select Graphic Bookmark Font [...]: Down Arrow Size: Medium Color: Red Symbol Position: Above price plot Select Alerts Bookmark Alerts Message: Short Entry Signal! Choose sound for audible alert [OK] button... [New] button... Var Name: ShortExitSignal Name: ShortExitSignal Description: Short Exit Signal Alert * Checkmark: Graphic Enabled * Checkmark: Alerts Enabled Select Graphic Bookmark Font [...]: Exit Sign Size: Medium Color: Red Symbol Position: Below price plot Select Alerts Bookmark Alerts Message: Short Exit Signal! Choose sound for audible alert [OK] button... [New] button... Var Name: OpenBuy Name: OpenBuy Description: Automated Open Buy Trade Command * Checkmark: Trading Enabled Select Trading Bookmark Trade Action: Buy Traders Range: 5 Hedge: no checkmark EachTick Count: 1 [OK] button... [New] button... Var Name: CloseBuy Name: CloseBuy Description: Automated Close Buy Trade Command * Checkmark: Trading Enabled Select Trading Bookmark Trade Action: Sell Traders Range: 5 Hedge: no checkmark EachTick Count: 1 [OK] button... [New] button... Var Name: OpenSell Name: OpenSell Description: Automated Open Sell Trade Command * Checkmark: Trading Enabled Select Trading Bookmark Trade Action: Sell Traders Range: 5 Hedge: no checkmark EachTick Count: 1 [OK] button... [New] button... Var Name: CloseSell Name: CloseSell Description: Automated Close Sell Trade Command * Checkmark: Trading Enabled Select Trading Bookmark Trade Action: Buy Traders Range: 5 Hedge: no checkmark EachTick Count: 1 [OK] button... 6. Click the "Save" icon to finish building this trading system. To attach this trading system to a chart, right-click with the mouse within the chart window, select "Add Trading System" -> "TASC - 10/2007 - Moving Average Trios" from the list. Once attached to the chart the parameters can be customized by right-clicking with the mouse over the displayed trading system label and selecting "Edit Trading Systems Properties".
Once you've saved and attached the trading system to a chart (a more complete list of the steps and instructions for creating the system can be found at www.Traders.com), the parameters can be customized by right-clicking over the displayed trading system label and selecting "Edit Trading Systems Properties."A sample chart is shown in Figure 11. To learn more about VT Trader, visit www.cmsfx.com.
FIGURE 11: VT TRADER, MOVING AVERAGE TRIOS. Here is a EUR/USD 30-minute candlestick chart displaying the moving average trio trading system.--Chris Skidmore
Visual Trading Systems, LLC (courtesy of CMS Forex)
(866) 51-CMSFX, trading@cmsfx.com, www.cmsfx.com
GO BACK
Return to October 2007 Contents
Originally published in the October 2007 issue of Technical Analysis of STOCKS & COMMODITIES magazine. All rights reserved. © Copyright 2007, Technical Analysis, Inc.