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.
This month's tips include formulas and programs for:
OMEGA RESEARCH EASYLANGUAGE OMEGA RESEARCH EASYLANGUAGE METASTOCK NEUROSHELL TRADER TECHNIFILTER PLUS WAVEWI$E MARKET SPREADSHEET TRADINGSOLUTIONS or return to August 2000 Contents
OMEGA RESEARCH EASYLANGUAGE
In "Catching DJIA Breakouts" in this issue, I discuss the strategy of buying markets that are breaking out to new highs, and present the results of buying breakouts in the Dow Jones Industrial Average (DJIA).In EasyLanguage, you can create a Boolean variable or a ShowMe study to simply test whether the two conditions of a breakout are met. However, I thought it more useful to have the function return the number of bars since the last time a new high was achieved. The only time a number other than zero is returned is when it is a true breakout (the function will return a zero either when no new high is achieved or when a new high has been achieved, but it has not been a breakout of look_bak length or greater).
The EasyLanguage code for this function, which I have called Breakout_Range2, follows:
GO BACKIf this seems too complicated, don't worry. Simply cut and paste the code into TradeStation and then create the following system based on this function:{ *********** Function: Breakout_Range2 ****************** 1/26/2000 Mark Vakkur, M.D. if this bar is the highest bar of the last look_bak bars AND this has not occurred in look_bak bars, returns the number of bars, otherwise returns 0. ******************************************************} Inputs: price( numericseries), look_bak(numeric); Vars: bar_count(0), max_price(h); {number of bars since last high} If CurrentBar = 1 then Begin bar_count = 1; {bar_count counts the number of bars since a new high was made} End Else Begin If price > Highest(high, look_bak)[1] {if this bar is the highest high of the look_bak period} then Begin if bar_count >= look_bak then Begin Breakout_Range2 = bar_count; bar_count = 0; End Else {highest high but NOT since look_bak bars} Begin bar_count = 0; Breakout_Range2 = 0; End; End { of highestbar check } Else {this isn't the highest high } Begin bar_count = bar_count + 1; Breakout_Range2 = 0; End; End;Note that all of the work of the breakout system went into the breakout function. This is perhaps the best way to develop your ideas: first create a function, then use the function to create indicators, ShowMe studies, and systems. If later you change the function, all the studies on which it is based will be changed automatically, freeing you from the labor required to change each study.System Breakout, Simple: Input: look_bak(4), n_bars(4); If Breakout_Range2(h, look_bak) <> 0 then {this would only occur if a new high price occured after n_bars of no such new high} Buy ; If BarsSinceEntry >= n_bars then ExitLong;-- Mark Vakkur
OMEGA RESEARCH EASYLANGUAGE
In my article in this issue, "Trading Stochastic Pops," I present a technique for identifying breakouts in stock prices using stochastic pops, which refers to a pop, or breakout, in price that leads to a high reading on the stochastics oscillator.My stochastic pop technique was introduced to the Market Technicians Association in autumn 1999. One of my MTA colleagues promptly dubbed it the "PopSteckle." Matt Samojeden, president of the St. Louis Omega Users Group, was of invaluable assistance in writing this TradeStation code for the technique.
The code shown is for a ShowMe study, a TradeStation 2000i feature that places a marker above or below a bar based on a conditional expression. It is common to use ShowMe studies to visually identify key price events in preparation for using the idea in a trading system.
A trading system is more than just an entry strategy; it includes both an exit strategy and a stop-loss strategy as well. Exits may be based on any number of conditions, such as achieving a predetermined profit objective (dollars or percentage), the passing of a defined number of days or weeks, or the crossing of a moving average, and so forth. The choices are almost endless. Likewise, there are any number of different stop-loss strategies you may choose to integrate in your system.
The PopSteckle ShowMe study is not in and of itself a backtestable trading system. The study code may be utilized as an entry condition in a trading system that may be backtested. To backtest a system, the trader/investor must select entry, exit and stop-loss strategies. The code is as follows:
The code uses fixed input values to look for a 14-day ADX below 15, an eight-day daily slow stochastic %K above 70, an eight-week (40-day) weekly slow stochastic %K above 50, and volume greater than 1.5 times the 50-day average daily volume. EasyLanguage allows the substitution of variable inputs in key indicator lookback settings in place of fixed input values to allow optimization of the settings for backtesting purposes. I encourage the reader to experiment with variable inputs.Inputs: ADXLev(15), DStocLev(70), WStocLev(50), ADXLen(14), StocLenD(8),StocLenW(40),VolLength(50),VolFilter(true); Condition1 = ADX(ADXLen) < ADXLev; Condition2 = SlowK(StocLenD) > DStocLev and SlowK(StocLenD) > SlowK(StocLenD)[1]; Condition3 = SlowK(StoclenW) > WstocLev and SlowK(StoclenW) > SlowK(StoclenW)[3]; {Weekly Data setup} Condition4 = Volume > 1.5*Average(Volume, VolLength); {Check for above average volume} If condition1 and condition2 and condition3 and condition4 and VolFilter then plot1(High, "Setup"); {Volume Filter is Active with true as the setting} If condition1 and condition2 and condition3 and condition4 and VolFilter = False then plot2(High, "Setup"); {Volume Filter is Inactive with false as the setting}Entry setup condition 3 at the beginning of my article explained that the daily stochastic must be above 70 and rising. ShowMe Condition2 is that today's daily stochastic value must be greater than 70 and greater than yesterday's stochastic value.
ShowMe Condition3 requires explanation. A weekly chart plotting end-of week bars ordinarily shows the weekly range, open, and close ending on a Friday. When using a real-time datafeed, TradeStation 2000i plots the latest bar on a tick-by-tick basis even if today isn't Friday. All previous weekly bars are plotted on a Friday close only, but the latest bar will be plotted regardless of the day of the week. On a Wednesday, for example, the weekly bar will be plotting and the end-of-day weekly stochastic value might be 55. Assuming the other entry setup conditions are met, that might be sufficient to trigger an entry signal.
If the PopSteckle code had used weekly bars to evaluate the weekly slow stochastic, historical ShowMe or trade system calculations would not show any signals for Monday through Thursday. ShowMe alerts or trades would only show on Friday if all the entry conditions were met. This code attempts to compensate for this limitation by equating one week with five days, hence the use of a 40-day stochastic as a substitute for the eight-week stochastic (StocLenW(40)).
Entry setup condition 4 requires the weekly stochastic value to be greater than 50 and rising. ShowMe Condition3 requires that today's "weekly" stochastic value be greater than 50 and greater than the stochastic value three days ago.
Why three days? Chartists use longer time intervals to reduce the noise inherent in shorter time intervals. Weekly charts will not reveal daily price fluctuations intraweek. This three-day comparison period is intended to minimize the noise of the daily stochastic; my experience using the PopSteckle technique is that if today's stochastic value is greater than the value of three days ago, then today's weekly stochastic is rising. I encourage the reader to experiment with other time intervals.
As part of testing this code, I compared an eight-week stochastic with a 40-day stochastic on numerous charts. While not identical, values between the two were very close.
ShowMe Condition4 requires that volume be much higher than the average daily volume. Heavy volume frequently accompanies a stock breaking out of a congestion range that continues higher in price over the following days or weeks. The volume condition may be turned on or off, at the reader's choosing.
GO BACK-- David Steckler
METASTOCK
Here's the MetaStock code to implement the Breakout_Range2 system given by Mark Vakkur in this issue's "Catching DJIA Breakouts." In the article, Vakkur discusses buying breakouts in the Dow Jones Industrial Average.
To create the custom indicator, select Indicator Builder from the Tools menu, click New, and enter the following code:Name: Breakout_Range2 Formula: lb:=4; { number of periods in look back } event:=H > HHV(Ref(H,-1),lb); If(event AND (Ref(BarsSince(event),-1)>=lb), Ref(BarsSince(event),-1), 0 ) To create the system, select System Tester from the Tools menu, click New, and enter the following code: Name: Breakout_Range2 System Enter Long: lb:=OPT1; { number of periods in look back } event:=H > HHV(Ref(H,-1),lb); If(event AND (Ref(BarsSince(event),-1)>=lb),1, 0 ) Stops: Inactivity: Positions: Longs Method: Percent Minimum Change: 10000 Periods: OPT1 Optimization: Name: OPT1 Minimum: 2 Maximum: 20 Step: 1
Note: To remove the optimization, replace Opt1 in the formula and in the inactivity stop with your desired lookback period.
GO BACK-- Cheryl C. Abram, Equis International, Inc.https://www.equis.com
NEUROSHELL TRADER
The system that Mark Vakkur describes in "Catching DJIA Breakouts" in this issue can be easily built in NeuroShell Trader by implementing the rules in the Long Entry portion of the Trading Strategy Wizard. However, we have simplified his rules into a single custom indicator that users of the NeuroShell Trader can download from the STOCKS & COMMODITIES section of the NeuroShell Trader free technical support Website.FIGURE 1: NEUROSHELL TRADER. Here is the Long Entry condition to use in NeuroShell Trader to implement Mark Vakkur.s breakout system.
After downloading the custom indicator, you can insert it into your chart, prediction, or trading strategy using the Indicator Wizard and selecting the Custom Indicators category.To create the system that Vakkur describes, select "New Trading Strategy É" from the Insert menu and enter the following entry/exit conditions in the appropriate locations of the Trading Strategy Wizard:
Long Entry (Figure 1) Generate a buy long MARKET order if ALL of the following are true: Breakout Range2(High,4) - This is the custom indicator you need to download. Long Exit (Figure 2) Generate a sell long MARKET order if ALL of the following are true: Bars Since Fill >= X(Trading Strategy, 4)
FIGURE 2: NEUROSHELL TRADER. Here is the Long Exit condition to use in NeuroShell Trader to implement Mark Vakkur's breakout system.
If you have either NeuroShell Trader Professional or NeuroShell DayTrader Professional, you can now use the genetic optimizer to optimize the parameters of the function. The genetic optimizer is able to optimize all parameters simultaneously in a fraction of the time that a brute force optimizer takes.In addition, using the optimization features of the NeuroShell Trader, you can optimize on one set of data and apply that optimized trading strategy to a future set of data (Figure 3). This will help you determine if the optimization is overfitting the data that it is optimized on or if the optimized parameters (or even the Trading Strategy in general) are robust and can be applied to future data.
FIGURE 3: NEUROSHELL TRADER. This is how you define what dates you want to optimize and backtest over. The backtest data is not included in the optimization data so you can see if the optimization holds true in the future. In this example, the backtest is performed over the last year of data and the optimization occurs on data for the two years prior to the backtest.
For more information on the NeuroShell Trader, visit www.NeuroShell.com.
GO BACK-- Marge Sherald, Ward Systems Group, Inc.301 662-7950, E-mail sales@wardsystems.com
https://www.neuroshell.com
GO BACKTECHNIFILTER PLUS
Here is a TechniFilter Plus formula that returns the number of days since the previous n-day new high, provided: 1) today is a new n-day high, and 2) the time period from the previous n-day high is at least n-days. If either of these conditions fail, the formula returns zero. This formula is the same as the BreakOut_Range2 formula given by Mark Vakkur.The formula consists of three pieces multiplied together. The first piece is 1 if today is a new n-day high. The second piece is 1 if the number of days since the previous high is greater than the parameter, 4. And the final piece is the number of days since that previous high. When these values are multiplied together, the returned value is either zero, or the number of days since the previous high provided today is a new high, and the previous high was early enough.
Number of days since a 4-day high NAME: BreakOut_Range2 PARAMETERS: 4 FORMULA: (H>HY1M&1) * ((H>HY1M&1)Y1U51>&1) * ((H>HY1M&1)Y1U51 + 1)Visit RTR's Website at https://www.rtrsoftware.com to download these formulas as well as program updates. Release 8.3 is now available for download.-- Clay Burch, RTR Software919 510-0608, E-mail: rtrsoft@aol.com
https://www.rtrsoftware.com
GO BACKWAVEWI$E MARKET SPREADSHEET
The following WaveWi$e formulas show how to compute the breakout system. The WaveWi$e built-in function @ROWOF is used to determine the position of the highest-high and greatly reduces formula complexity.A: DATE @TC2000(C:\TC2000V3\Data,SP-500,Standard & Poors 500,DB) B: HIGH C: LOW D: CLOSE E: OPEN F: VOL G: LookBack 14 ÔSet lookback perion H: HiRow @ROWOF(@MAX(HIGH,LOOKBACK)) ÔGet position of high I: HiNow @IF(HIROW=@ROW(),1,0) ÔMark high if today J: Breakout @IF(HINOW=1 & @ADD(HINOW[-1],LOOKBACK)=0,1,0) ÔNew breakout K: Holding 20 ÔSet holding period L: SigBuy @SIGNAL(CLOSE,BUY,BREAKOUT=1, @ROW() > @SIGEROW() +HOLDING) ÔCompute trading system M: SigSell N: Profit @PROFIT(SIGBUY,SIGSELL,LONG ÔComput profit ==========End Formulas-- Peter Di Girolamo, Jerome Technology908 369-7503
E-mail: jtiware@aol.com
https://members.aol.com/jtiware
GO BACKTRADINGSOLUTIONS
FIGURE 4: TRADINGSOLUTIONS. Here's a sample TradingSolutions chart displaying the trading signals for a four-month segment of Coca-Cola's data using Mark Vakkur's breakout range system. The dialog at the bottom shows the profitability of the system for that time frame.
The implementation of Mark Vakkur's breakout system in TradingSolutions is quite straightforward. It requires the addition of two user-defined functions and one exit/entry system:To save you from having to enter these formulas by hand, these functions are available as a trading solution that can be downloaded from our Website (www.tradingsolutions.net) in the Solution Library section of the Customer Center. To import the solution into TradingSolutions, select "Import Trading SolutionÉ" from the File menu. To apply the system to a stock or a group of stocks, select "Add New FieldÉ" from the context menu for the stock or group, select the "Use a complete trading solutionÉ" button, then select "Breakout Range Solution."Function: Breakout Bar Count Abbreviation: BarCount Inputs: Look Back Period, High, Price If (LE (Bar# (), Look Back Period), Bar# (), If (GT (Price, Lag (Highest (High, Look Back Period), 1)), 0, Add (Prev (1), 1))) Function: Breakout Range Abbreviation: Range Inputs: Bar Count, Look Back Period If (EQ (Bar Count, 0), If (GE (Lag (Bar Count, 1), Add (Look Back Period, 1)), Lag (Bar Count, 1), 0), 0) Exit/Entry System: Breakout Range System Inputs: High, Price, Look Back Period, Hold Period Enter Long GT (Range (BarCount (Look Back Period, High, Price), Look Back Period), 0) Exit Long GE (BarsWhileFalse (Range (BarCount (Look Back Period, High, Price), Look Back Period)), Hold Period)-- Gary Lynn, Software EngineerNeuroDimension, Inc.
800 634-3327, 352 377-5144
https://www.tradingsolutions.net