Traders Tips September 2007
Post on: 16 Март, 2015 No Comment
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.
You 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.
METASTOCK: TRADING TRENDLINE BREAKS
For the MetaStock code to implement the techniques discussed in Sylvain Vervoort’s article in this issue, Trading Trendline Breaks, Part 2, see the sidebar in the article on page 24 for code provided by Vervoort. —Editor
TRADESTATION: TRADING TRENDLINE BREAKS
Sylvain Vervoort’s articles in his two-part series, Trading Trendline Breaks, describe the use of trendline breaks in trading. The articles include code that approximates the author’s trading style. Vervoort’s code identifies zigzag peaks and troughs in the present by looking at future price data. Obviously, this cannot be done in actual trading. The code given here identifies zigzag peaks and troughs in the present without looking at price data in the future.
FIGURE 1: TRADESTATION, TRADING TRENDLINE BREAKS. The strategy ZigZag Percent, applied to a daily chart of IBM, is displayed in the upper panel. The yellow trendlines are drawn by one of TradeStation’s built-in indicators, ZigZag %. Both the strategy and the indicator use a 5% reversal to identify peaks and troughs. The lower pane displays the built-in TrendLines Automatic indicator, again applied to a daily chart of IBM. TradeStation has a number of built-in studies for creating and trading trendlines. For example, the indicator Trendlines Automatic creates trendlines much like those described in the articles. The built-in strategies TrendLine LE and TrendLine SE provide long and short entries that are based on manually drawn trendlines. The EasyLanguage Library in TradeStation’s online Support Forum contains other trendline-based strategies, including TL_Entry, TL_ProfitTarget, and TL_StopLoss. Each of these strategies uses a manually drawn trendline to control trades. See, for example, the code at the following link: Code for a strategy named ZigZag Percent is shown here. To download this code, go to the Support Center at TradeStation.com. Search for the file ZigZag_Percent.Eld.
TradeStation does not endorse or recommend any particular strategy.
—Mark Mills
TradeStation Securities, Inc.
A subsidiary of TradeStation Group, Inc.
www.TradeStation.com
eSIGNAL: TRADING TRENDLINE BREAKS
For this month’s Traders’ Tip, we’ve provided the eSignal formula code named Trendline_Breaks.efs, based on the code given in Sylvain Vervoort’s article in this issue, Trading Trendline Breaks, Part 2.
The eSignal formula is a modified version of eSignal’s RealTimeSwings.efs, which contains the code for reproducing the zigzag indicator.
There are several formula parameters that may be configured through the Edit Studies option in the Advanced Chart to change the definition of the swing points for the indicator, which include options for number of bars, wave type, wave percentage, swing high price source, swing low price source, colors, line thickness, the display of swing labels, and a percent retracement label.
The study is a price study configured for backtesting in the Strategy Analyzer with parameter defaults set to the zigzag definitions outlined in Vervoort’s article. The study displays the zigzag indicator as well as the PU and PD price levels used for the trade signals, which are highlighted on the chart with long and short labels accompanied by up/down arrows. A sample chart is shown in Figure 2.
FIGURE 2: eSIGNAL, TRADING TRENDLINE BREAKS. The study displays the zigzag indicator as well as the PU and PD price levels used for the trade signals, which are highlighted on the chart with long and short labels accompanied by up/down arrows. One difference between this EFS study and the logic used in Vervoort’s article is that the forward-looking aspect of the signals has been removed. To create realistic signals that may be evaluated in real time, the trade conditions are evaluated on the bars that confirm the previous swing points by the appropriate price action as defined by the formula parameters. 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 Traders.com. —Jason Keck
eSignal, a division of Interactive Data Corp.
800 815-8256, www.esignalcentral.com GO BACK
AMIBROKER: TRADING TRENDLINE BREAKS
Here is a direct translation of the MetaStock code provided in Sylvain Vervoort’s article, Trading Trendline Breaks, Part 2, to AmiBroker Formula Language.
The code has been expanded to include price and zigzag charts as well as buy/sell arrows. As Vervoort notes in his article, his formula is looking into the future and therefore is provided for illustration purposes only, and not for objective, computer-based trading. For trading, the author uses discretionary evaluation of trendlines drawn manually on the chart.
A sample chart is shown in Figure 3.
FIGURE 3: AMIBROKER, TRENDLINES. This screenshot shows a daily chart of Boeing (BA), with a 7% zigzag line, and buy (green)/sell (red) arrows generated by the AmiBroker formula listing. —Tomasz Janeczko, AmiBroker.com
www.amibroker.com
WEALTH-LAB: TRADING TRENDLINE BREAKS
I’m guilty of being a fan of trendlines, but while lines drawn on historical charts may look useful — as they do in Sylvain Vervoort’s article in this issue, Trading Trendline Breaks, Part 2 — it’s unlikely that many of them would have been drawn precisely as shown without the benefit of looking at future data. Repetitive data-processing tasks, such as drawing trendlines, can and are accomplished more easily and quantitatively by computer programs; in other words, without the subjectivity that accompanies drawing trendlines by hand.
Therefore, instead of translating the article’s MetaStock code into WealthScript, we’ve done something much more interesting by creating a trendline study that approaches Vervoort’s subjective technique, and you can actually use it for trading in any time frame.
Since programming requirements must be precise, the main problem to resolve is when to start drawing a trendline. Waiting for peaks and troughs may be too long after a trend is already apparent. Not waiting for peak and troughs can cause you to draw a trend too early before a pullback occurs. A timely pullback may not occur, again delaying drawing a trendline.
For sure, you can’t draw a trendline unless some amount of data indicates that a trend exists. I used a weighted moving average (WMA) of a user-specified period to determine the direction of prices to narrow the search for a trend. Simply, if the WMA of the specified period was monotonically increasing for four bars, we search for an upward trendline (and vice versa). The origin of the line is chosen to be the previous lowest low (highest high) for the same period that matched a market structure low (high), which is a TurnUp (TurnDown) signal in Wealth-Lab. The trendline is then defined by the bar that generates a line with the least slope between the current bar and the origin. Once a trendline is established, it is extended until crossed by a user-specified series, but then extended a few more bars to show the crossing effect. In addition, accelerated lines are drawn after price diverges a user-specified percentage from the most-recent trendline.
The cherry-picked chart of AA in Figure 4 shows just how well the study can actually work. It’s quite common, however, to see the phenomenon shown on the HPQ chart inset, in which a trendline is drawn, crossed, redrawn, crossed, and so on. Note that a trendline is not attempted to be redrawn in the same direction after a crossing until a specified number of bars have passed.
FIGURE 4: WEALTH-LAB, AUTOMATIC TRENDLINE DRAWING. The trendlines study draws lines automatically without the use of future information based on specifications that can be optimized in a trading strategy. Note that the time at which a trendline is defined is indicated by a small dot on the line. — Robert Sucher
NEUROSHELL TRADER: TRADING TRENDLINE BREAKS
The strategy described by Sylvain Vervoort in Trading Trendline Breaks, Part 2 can be easily implemented in NeuroShell Trader by combining a few of NeuroShell Trader’s 800+ indicators into a trading strategy.
To recreate the strategy, select New Trading Strategy. from the Insert menu and enter the following entry and exit conditions in the appropriate locations of the Trading Strategy Wizard:
Generate a buy long MARKET order if ALL of the following are true:
If you have NeuroShell Trader Professional, you can also choose whether the system parameters should be optimized. After backtesting the trading strategy, use the Detailed Analysis. button to view the backtest and trade-by-trade statistics for the trendline breaks strategy.
Note that the strategy described here is based on the zigzag indicator, which is a custom indicator that NeuroShell Trader users can download for free from www.ward.net. Since, as the author states in the article, the zigzag indicator looks into the future, this system is not tradable into the future. In addition, historical backtest results based on the zigzag indicator should be viewed as unrealistic.
A sample chart is shown in Figure 5. For more information on NeuroShell Trader, visit www.NeuroShell.com.
FIGURE 5: NEUROSHELL, TRENDLINE BREAK STRATEGY —Marge Sherald, Ward Systems Group, Inc.
301 662-7950, sales@wardsystems.com
www.neuroshell.com
AIQ: TRADING TRENDLINE BREAKS
AIQ recently introduced a chart pattern service with the ability to recognize classic chart patterns and alert the user to emerging as well as completed formations. The patterns are stored historically back to about February 2006, and the history bank will grow as time marches forward. In addition, the completed patterns can be accessed via the EDS code, thereby allowing a backtest to be performed for the patterns.
Since all of the completed pattern signals involve a breakout from a trendline, I decided to put most of the pattern signals together into one rule and then trade all the signals for the NASDAQ 100 list of stocks. I traded only in the direction of the breakout: long for upward breaks of a trendline and short for downward breaks of a trendline. Positions were entered the next day at the open after the trendline break and were exited after being held for three days without any other stops. Three positions maximum were held with one-third of capital allocated to each. The signals were chosen based on relative strength: strongest for long positions, weakest for short positions. I deducted three cents per share for commission and slippage for a round-trip trade. The types of breakouts included are: channel, flag, pennant, triangles, wedges, double bottoms and tops, and rectangles.
In addition, I devised some simple market timing filters using the NDX. In Figures 6 and 7, I show a comparison of trading with and without market timing filters. Because of the limited history currently available, I ran the test from February 10, 2006, to July 12, 2007. The best results come from the long signals with the market timing filter, which showed a 19% annualized return with an 8% maximum drawdown. The short side also showed improved results with the market timing filter, but overall, both short side tests were net losers for the test period.
FIGURE 6: AIQ, TRADING TRENDLINE BREAKS, LONG. Here is an equity curve comparison for trading trendline breaks long related to classic chart patterns with and without a market timing filter.
FIGURE 7: AIQ, TRADING TRENDLINE BREAKS, SHORT. Here is an equity curve comparison for trading trendline breaks short related to classic chart patterns with and without a market timing filter. The AIQ code for completed chart pattern breakouts including the code for individual chart pattern signals is shown here. This code can be downloaded from the AIQ website at www.aiqsystems.com and also from www. tradersedgesystems.com/traderstips.htm. It can also be copied and pasted from the STOCKS & COMMODITIES website at www.Traders.com.
—Richard Denning
AIQ Systems
richard.denning@earthlink.net
STRATASEARCH: TRADING TRENDLINE BREAKS
Trendlines can be an excellent way to evaluate historical patterns, and they can also be quite helpful in identifying future support and resistance. But they have their limitations when it comes to actual trading. In the sample MetaStock code given by Sylvain Vervoort in his article in this issue, Trading Trendline Breaks, Part 2, it’s noted that the zigzag formula contains forward-looking values and therefore cannot be used in real trading. Indeed, trendlines cannot easily be drawn from their starting point without knowledge of the ending point.
With the above in mind, we still ran a backtest on the provided system and found it to be quite effective. Using a range of parameters and run against the NASDAQ 100, the annual returns were often more than 100% with percentage profitability over 90%. However, since the system contains forward-looking values and cannot be used for real trading, the results have limited practical value. We hope the author will offer tips for getting around this issue in the third part of his series.
In the meantime, StrataSearch contains a free plug-in that can create trendlines without forward-looking references. This is done by generating the trendline only after its placement and direction have been established. StrataSearch users can obtain this, as well as a plug-in to use the article’s code, from the Shared Area of the StrataSearch User Forum.
A sample Stratasearch chart is in Figure 8.
FIGURE 8: STRATASEARCH, TRADING TRENDLINE BREAKS. While the Zig() formula provides the pivot points, the buy and sell signals themselves are triggered after a percentage movement away from the pivot. —Pete Rast
Avarin Systems, Inc.
www.StrataSearch.com
NINJATRADER: TRADING TRENDLINE BREAKS
We’ve developed an automatic trendline detection indicator based on Sylvain Vervoort’s article in this issue, Trading Trendline Breaks, Part 2. This indicator will detect and plot the prevailing trend, and will generate a visual and audio alert on a break of a trendline. (See Figure 9.) This indicator can be embedded in a NinjaScript strategy to create an automated trading system.
FIGURE 9: NINJATRADER, TRENDLINE BREAKS. This sample NinjaTrader chart shows the AutoTrendLine indicator applied to a one-minute S&P emini data series. We created this indicator based on finding swing low or high points to generate a trendline. The sample code shown below demonstrates how the swing indicator can be used to scan for pivot points that will anchor a trendline.
This indicator can be downloaded from www.ninjatrader.com/SC/AutoTrendLine.zip. Once downloaded, from within the NinjaTrader Control Center window, select the menu File > Utilities > Import NinjaScript and select the downloaded file.
You can review the indicator’s source code by selecting the menu Tools > Edit NinjaScript > Indicator from within the NinjaTrader Control Center window and selecting the indicator AutoTrendLine.
NinjaScript indicators are compiled DLLs that run native, not interpreted, which provides you with the highest performance possible. —Raymond Deux, NinjaTrader
TRADECISION: TRADING TRENDLINE BREAKS
In his article Trading Trendline Breaks, Part 2, Sylvain Vervoort demonstrates techniques on how to apply breaks in trendlines to your market analysis and trading.
Tradecision’s Strategy Builder enables you to recreate the trading trendline breaks system based on the concept explained by Vervoort in his article. A sample chart is in Figure 10. FIGURE 10: TRADECISION, TRENDLINE BREAKS. Here, Sylvain Vervoort’s trendline breaks strategy is applied to a Google daily chart along with the auto-trends study. Entry Long
var
To implement this strategy in Tradecision, visit the area Traders’ Tips from Tasc magazinetradecision.com/support/tasc_tips/tasc_traders_tips.htm or copy the code from the STOCKS & COMMODITIES website at www.Traders.com. —Alex Grechanowski, Alyuda Research, Inc.
sales@tradecision.com, 510 931-7808
www.tradecision.com
TRADE NAVIGATOR: TRADING TRENDLINE BREAKS
Trendlines can be a very valuable trading tool. You can use the power of Trade Navigator to automatically draw trendlines based on supplied thresholds.
Sylvain Vervoort’s article in this issue, Trading Trendline Breaks, Part 2, discusses how to trade trendline breakouts. Here, we’ll show how to add these functions to your Trade Navigator software. Please note that because the zigzag function relies on future data, it can’t be tested or traded in real time.
You can either follow the step-by-step instructions we’ll provide to recreate all the functions yourself, or you can simply download the file SC0907, which will give you access to all of the functions described here.
We’ll be creating 11 functions that build on one another. Our final result will be two highlighted bars that mark the buy and sell points.
The steps are the same for creating each function, so we’ll walk you through the first and include the syntax for the rest. Just replace the syntax and the name to set up the other functions. Because they build on each other, it is important to enter them in the order given.
To create new functions, first click on the Edit menu and select Functions. You will be taken to the Trader’s Toolbox feature of the Functions section. Click New. Type the following into the New Function window: The syntax for our first function is zz0. Click Save. You will be prompted for a name. Type zz0 and click OK.
To return to the function manager, just click the toolbox button.
Click New again to create a new function. Repeat the above steps for the following functions, making sure to give the exact name specified. The last two functions are really at the heart of Vervoort’s article. They are actually highlighted bars that you can apply to your chart. They should indicate blue buys and red sells (Figure 11). To apply these highlight bars to your chart, follow these steps: Click on the Charts menu and then select Add to Chart. Click Highlight Bars.
FIGURE 11: TRADE NAVIGATOR, TRENDLINE BREAK STRATEGY. Highlighted bars indicate buys (blue) and sells (red). Please note that because the zigzag function relies on future data, it can’t be tested or traded in real time. The list will be sorted alphabetically, so scroll down toward the bottom and locate the two highlighted bars we created (Trading Trendline Breaks Buy and Trading Trendline Breaks Sell). You can select them both by holding down the Ctrl key on your keyboard and clicking on their names. After they are both selected, just click the Add button to add them to your charts.
For your convenience, we have created a file that you can download through Trade Navigator that will add the two highlight bars and their components to Trade Navigator for you. Download this free file named SC0907 from within Trade Navigator and follow the upgrade prompts. —Michael Herman
Genesis Financial Technologies
VT TRADER: TRONGONE MOVING AVERAGES
For this month’s Traders’ Tip, we will revisit the May 2007 issue of STOCKS & COMMODITIES and the article by Anthony Trongone, Moving Averages: Long On Talk, Short On Action. In the article, Trongone presents a simple 34-day simple moving average system with a few additional conditions (such as volume) used to filter trades.
Trongone advocates trading with a long market bias and exiting the market at the end of the day. Since the forex marketplace differs somewhat from the stock market, we’ve taken the opportunity to modify Trongone’s original system rules slightly. In the stock market, volume typically represents the number of shares traded over a given period; however, there is no central exchange in the forex marketplace to provide such information. Therefore, forex volume is often measured as the number of price changes (that is, ticks) in a given period at a given broker. Although they are very different, both methods of calculating volume provide a measurement of market participation and interest in the given trading instrument.
We’ll be using the tick-volume method to provide the volume element for this trading system. We’ve further modified the system’s rules to allow the user to choose his or her own market bias: long trades, short trades, or long & short trades. See Figure 12 for a sample charts.
FIGURE 12: VT TRADER, TRONGONE MOVING AVERAGE FOR FOREX. Here is a GBP/JPY daily candlestick chart with the TMA trading system displayed. The Inspect Window displays some basic profit/loss statistics produced by the TMA system over the last 500 days. We’ll be offering our modified Trongone MA trading system for download in our user forums. The VT Trader code and instructions for creating it are as follows (the input variables are parameterized to allow customization):
To learn more about VT Trader, visit www.cmsfx.com. —Chris Skidmore
Visual Trading Systems, LLC (courtesy of CMS Forex)
(866) 51-CMSFX, trading@cmsfx.com