March  2003
TRADERS' TIPS 

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.

This month's tips include formulas and programs for:


TRADESTATION: FIBONACCI RETRACEMENTS AND THE RSI
TRADESTATION: MULITPLE INDICATORS
AMIBROKER: FIBONACCI RETRACEMENTS AND THE RSI
AMIBROKER: MULTIPLE INDICATORS
eSIGNAL: FIBONACCI RETRACEMENTS AND THE RSI
NEUROSHELL TRADER: FIBONACCI RETRACEMENTS AND THE RSI
NEUROSHELL TRADER: MULTIPLE INDICATORS
Wealth-Lab: FIBONACCI RETRACEMENTS AND THE RSI
Wealth-Lab: MULTIPLE INDICATORS
NeoTicker: FIBONACCI RETRACEMENTS AND THE RSI
Investor/RT: FIBONACCI RETRACEMENTS AND THE RSI
Investor/RT: MULTIPLE INDICATORS
TECHNIFILTER PLUS: FIBONACCI RETRACEMENTS AND THE RSI
SMARTRADER: FIBONACCI RETRACEMENTS AND THE RSI
or return to March 2003 Contents


TRADESTATION: FIBONACCI RETRACEMENTS AND THE RSI

Ingo Bucher's article in this issue, "Fibonacci Retracements and the RSI," describes the advantages of considering Fibonacci retracement levels for use with the classic RSI indicator. Bucher reviews six charts, each displaying Fibonacci retracement levels for the RSI associated with each chart. The EasyLanguage code given here will allow you to automatically recreate these charts for any security available in TradeStation.

Bucher calculated his retracement levels by picking the RSI high and low for a given time window. In his examples, these were generally six months to a year's worth of data. Once the high and low were picked, he calculated retracement levels based on the well-known Fibonacci numbers (23.6%, 38.2%, 50%, 61.8%).

Our code does the same thing. We use a "LookbackLength" (default: 400 bars), which represents a sliding data window that is used to determine the RSI high and low. The second input value controls the RSI period (default: 14 bars). The next three inputs select the retracement levels.

A total of eight different lines need to be drawn: the RSI itself, the 50% line, two retracements above the 50% point, two retracements below, and the zero and 100% lines. TradeStation will create four plotlines per indicator, so we advise inserting the Fibonacci RSI twice. The first time it is inserted, leave the PlotRSI input with its default value, true. True tells TradeStation to plot the RSI itself. The second copy should have the input "Plot RSI" set to false. This will put the 50% line on your chart. Also, adjust the Fib1, Fib2, and Fib3 input values to be sure you get all five retracement levels marked on the chart.

Unlike the charts displayed in Bucher's article, the retracement levels are displayed as somewhat jagged lines (Figure 1). This occurs whenever the EasyLanguage code discovers a new RSI high or low within the given day's data window. Displaying the retracements in this manner ensures the retracement value plotted is what the trader would have seen on the day in question based on the information available at the time.

FIGURE 1: TRADESTATION, FIBONACCI RETRACEMENT LEVELS AND RSI. Here's a sample TradeStation chart demonstrating the combination of RSI and Fibonacci retracements. Eight lines are plotted: the RSI itself, the 50% line, two retracements above the 50% point, two retracements below, and the zero and 100% lines. The retracement lines are somewhat jagged because it shows RSI highs and lows throughout the day.


The code presented here will also be available for download at the TradeStation 6 EasyLanguage Worldwide Exchange, www.TradeStationWorld.com. Look for the file "Fibonacci Rsi.eld."
 

Indicator: Fibonacci RSI
inputs:
 LookbackLength( 400 ),
 RSILength( 14 ),
 Fib1( 23.6 ),
 Fib2( 31.1 ),
 Fib3( 100 ),
 PlotRSI( "Yes" ) ;
variables:
 RawRSI( 0 ),
 RangeHigh( 0 ),
 RangeLow( 100 ),
  ChartRange( 0 ),
 Trendline1( 0 ),
 Trendline2( 0 ),
 Trendline3( 0 ) ;
RawRSI= RSI( Close, RSILength ) ;
if BarNumber > LookbackLength then
 begin
 RangeHigh = Highest(RawRSI,LookbackLength ) ;
 RangeLow = Lowest(RawRSI, LookbackLength ) ;
 ChartRange = RangeHigh - RangeLow ;
 Trendline1 = Fib1/100*ChartRange + RangeLow ;
 Trendline2 = Fib2/100*ChartRange + RangeLow ;
 Trendline3 = Fib3/100*ChartRange + RangeLow ;
  if PlotRSI = "Yes" or PlotRSI = "yes" then
  Plot1( RawRSI )
 else
  Plot1( RangeLow + ChartRange / 2 ) ;
 Plot2( TrendLine1 );
 Plot3( TrendLine2 ) ;
 Plot4( Trendline3 ) ;
 end ;
-- Mark Mills
EasyLanguage Specialist
MarkM@TSTech at www. TradeStationWorld.com,
EasyLanguage Questions Forum
TradeStation Technologies, Inc.
A subsidiary of TradeStation Group, Inc.
GO BACK


TRADESTATION: MULTIPLE INDICATORS

Dennis Peterson's article in this issue, "Trading Systems Using Multiple Indicators," presents an optimized strategy for QQQ based on a breadth momentum and CCI signal.

The following code translates those strategies into TradeStation 6 EasyLanguage code. Two case studies are presented: one using only momentum and the other using both momentum and a CCI index.

Both strategies were tested using the NYSE advancing issues ($Adv) and NYSE declining issues ($Decl) for a market breadth indicator. The traded security was QQQ. TradeStation allows the code to work with any number of securities and market indices.

The CCI/breadth momentum code and published parameters were used to produce the simulated trading history shown in Figure 2. The test covered the period from 5/25/99 to 1/16/03. Each trade invested $10,000. After the test period was over, the simulated result was about a $20,000 profit. Of course, profit figures without corresponding information on risk, or drawdown, is not very useful. TradeStation reports include extensive risk statistics also.

FIGURE 2: TRADESTATION, CCI & BREADTH MOMENTUM. Here's a sample trading history from 5/25/99 to 1/16/03 based on the parameters given in Peterson's article for the CCI/breadth momentum as implemented on the QQQ. Each trade invested $10,000. After the test period was over, the simulated result was about a $20,000 profit.


The code presented here will also be available for download at the TradeStation 6 EasyLanguage Worldwide Exchange, www.TradeStationWorld.com. Look for the file "Cci-Breadth Momentum.eld."
 

Strategy: Breadth Momentum
{ Based on Trading Systems Using Multiple Indicators
by Dennis Peterson, Case #1, Momentum Test }
inputs:
 Opt1( 7 ),
 Opt2( 16 ),
 Opt3( 2 ),
 Opt4( 0.4 ),
 Opt5( 1 ),
 Opt6( 0.3 ),
 Opt7( 0.6 ) ;
variables:
 NH( 0 ),
 NL( 0 ),
 Ratio( 0 ),
 Diff( 0 ),
 Signal( 0 ) ;
NH = Close data2 ; { Advancing Issues }
NL = Close data3 ; { Declining Issues }
Ratio = NH / ( NH + NL ) ;
Diff = XAverage( Ratio, Opt1 )
 - XAverage( Ratio, Opt2 ) ;
Signal = XAverage( Diff, Opt3 ) ;
{Long Entry}
if Ratio > Opt4 and Signal > Diff then
 Buy next bar at market ;
{Long Exit}
if Ratio < Opt6 and Signal < Diff then
 Sell next bar at market ;
{Short Entry}
if Ratio < Opt5 and Signal < Diff then
 SellShort next bar at market ;
{Exit Short }
if Ratio > Opt7 and Signal < Diff then
 BuyToCover next bar at market ;
Strategy: CCI ? Breadth Momentum
{ Based on Trading Systems Using Multiple Indicators
by Dennis Peterson, Case #2, Momentum combined with CCI }
inputs:
 Opt1( 6 ),
 Opt2( 6 ),
 Opt4( 9 ),
 Opt5( -140 ),
 Opt6( 4 ),
 Opt7( 30 ),
 Opt8( 180 ),
 Opt9( -130 ) ;
variables:
 NH( 0 ),
 NL( 0 ),
 Ratio( 0 ),
 Diff( 0 ),
 Signal( 0 ),
 LongCCI( 0 ),
 ShortCCI( 0 ) ;
NH = Close data2 ; { Advancing Issues }
NL = Close data3 ; { Declining Issues }
Ratio = NH / ( NH + NL ) ;
LongCCI = CCI( Opt1 ) ;
ShortCCI = CCI( Opt2 ) ;
Diff = XAverage( Ratio, 7 ) - XAverage( Ratio, 16 ) ;
Signal = XAverage( Diff, 2 )  ;
{ Long Entry }
if ( Ratio > .4
 and Lowest( LongCCI, Opt4 ) < Opt5 )
 or  ( Signal > Diff
 and Lowest( LongCCI, Opt4 ) < Opt5 )
then
 Buy next bar at market ;
{ Long Exit }
if  Ratio < .6
 and Signal < Diff
 and LongCCI > Opt8
then
 Sell next bar at market ;
{Short Entry}
if  Highest( ShortCCI, Opt6 ) > Opt7 then
 SellShort next bar at market ;
{Short Exit}
if Ratio > .6
 and Signal > Diff
 and ShortCCI < Opt9
then
 BuyToCover next bar at market ;


-- Mark Mills
EasyLanguage Specialist
MarkM@TSTech at www. TradeStationWorld.com,
EasyLanguage Questions Forum
TradeStation Technologies, Inc.
A subsidiary of TradeStation Group, Inc.
GO BACK


AMIBROKER: FIBONACCI RETRACEMENTS AND THE RSI

In "Combining Fibonacci Retracements and the RSI" in this issue, Ingo Bucher suggests using well-known Fibonacci retracement levels of 23.6%, 38.2%, and 61.8% to find important support/resistance levels on an RSI chart. The calculations presented in the article could be relatively simply reproduced in AmiBroker using its native AFL language.

Listing 1 shows the code that plots RSI along with Fibonacci retracement levels. Local high and low levels of RSI are automatically found in the current visible range.

LISTING 1
barvisible = Status("barvisible");
r = RSI( 14 );
maxr = LastValue( Highest( IIf( barvisible, r, 0 ) ) );
minr = LastValue( Lowest( IIf( barvisible, r, 100 ) ) );
ranr = maxr - minr;
Plot( r, "RSI(14)", colorRed );
Plot( maxr , "0%", colorGrey50 );
Plot( maxr - 0.236 * ranr, "-23.6%", colorPaleGreen );
Plot( maxr - 0.382 * ranr, "-38.2%", colorPaleBlue );
Plot( maxr - 0.50 * ranr, "-50.0%", colorOrange );
Plot( maxr - 0.618 * ranr, "-61.8%", colorPaleBlue );
Plot( minr , "-100%", colorGrey50 );
GraphXSpace = 3;


A downloadable version of the formula is available from AmiBroker's website. A sample chart is in Figure 3.

FIGURE 3: AMIBROKER, FIBONACCI RETRACEMENT AND RSI. This AmiBroker chart shows a weekly chart of AT&T [T] and replicates the chart presented in the article. RSI high and low levels are calculated automatically based on visible range. The 38.2% level seems to be the most significant in this case.


--Tomasz Janeczko, AmiBroker.com
www.amibroker.com
 

GO BACK


AMIBROKER: MULTIPLE INDICATORS

Implementation of the trading system presented by Dennis Peterson in his article this issue, "Trading Systems Using Multiple Indicators," is straightforward and simple in AmiBroker.

AmiBroker has a built-in ability to reference multiple symbols' data from a single formula by means of Foreign() function. This enables us to use QQQ and new highs/new lows data in the trading system. Various data vendors use different symbols for new highs/new lows; in our sample code, we will be using the QP2 database, which uses !NQ-NH and !NQ-NL symbols.

Listing 1 shows the code that implements the system presented in Peterson's article. The default values included in the formula are taken from the article, but the user can rerun the optimization at any time.

LISTING 1
Opt1 = 6;//Optimize("Opt1", 6, 4, 8, 1 );
Opt2 = 6;//Optimize("Opt2", 6, 4, 8, 1 );
Opt4 = Optimize("Opt4", 9, 8, 12, 1 );
Opt5 = Optimize("Opt5", -140, -150, -100, 10 );
Opt6 = Optimize("Opt6", 4, 3, 5, 1 );
Opt7 = Optimize("Opt7", 30, 20, 40, 5 );
Opt8 = Optimize("Opt8", 180, 150, 200, 10 );
Opt9 = Optimize("Opt9", -130, -150, -100, 10 ); 0
nh = Foreign("!NQ-NH", "C" );
nl = Foreign("!NQ-NL", "C" );
ratio = nh/( nh + nl );
diff = EMA( ratio, 7 ) - EMA( ratio, 16 );
sig = EMA( diff, 2 );
Buy = ( ratio > Opt4 AND Hold( CCI( Opt1 )< Opt5, Opt4 ) )
OR (sig > diff AND Hold( CCI( Opt1 )< Opt5, Opt4 ) );
Sell = ratio < 0.6 AND sig < diff AND CCI(Opt1)>Opt8;
Short = ( NOT Buy AND Hold( CCI(Opt2)>Opt7, Opt6 ) );
Cover = ratio > 0.6 AND sig > diff AND CCI(Opt2)<Opt9;


A downloadable version of this formula is available from AmiBroker's website.

--Tomasz Janeczko, AmiBroker.com
www.amibroker.com
 

GO BACK


eSIGNAL: FIBONACCI RETRACEMENTS AND THE RSI

This eSignal formula is based on "Combining Fibonacci Retracements and the RSI" by Ingo Bucher in this issue.

One note: In the article, Bucher uses a visual method to determine when the maximal and minimal values of the RSI occur, and this is based on the part of the indicator plotted on the chart. Unfortunately, we can't see how many bars are displayed on a user's chart. To solve the problem, we created a second input, nbars, for the user to define the period for which the maximal and minimal RSI values should be sought. The other input, Length, is just the RSI length.

/************************************************************************
Description: Fibonacci Retracements And The RSI
Provided by: TS Support, LLC for eSignal. (c) Copyright 2002
************************************************************************/
rsi = null;
function preMain()
{
    setStudyTitle("Fibonacci Retracements And The RSI");
    setCursorLabelName("RSI", 0);
    setDefaultBarFgColor(Color.blue, 0);
    setCursorLabelName("0%", 1);
    setDefaultBarFgColor(Color.lightgrey, 1);
    setCursorLabelName("23.6%", 2);
    setCursorLabelName("38.2%", 3);
    setCursorLabelName("50%", 4);
    setCursorLabelName("61.8%", 5);
    setCursorLabelName("100%", 6);
 
}
function main(Length,nbars) {
 if(Length == null)
  Length = 14;
 if(nbars == null)
  nbars = 50;
 if(rsi == null)
  rsi = new RSIStudy(Length, "Close");
 
 var i = 0, max = 0, min = 0, dif = 0;
 
 for(i = - nbars; i <= 0; i++){
  if(i == - nbars)
   min = rsi.getValue(RSIStudy.RSI,i);
  max = Math.max(max,rsi.getValue(RSIStudy.RSI,i));
  min = Math.min(min,rsi.getValue(RSIStudy.RSI,i));
 }
 dif = max - min;
 return new Array(rsi.getValue(RSIStudy.RSI), max, max - (dif * .236),
    max - (dif * .382), max - (dif * .5), max - (dif * .618),  min);
}


 A sample chart is in Figure 4.

FIGURE 4: eSIGNAL, FIBONACCI LEVELS AND RSI. This eSignal chart displays the RSI and Fibonacci retracements.


--eSignal, a division of Interactive Data Corp.
800 815-8256, www.esignal.com
 

GO BACK


NEUROSHELL TRADER: FIBONACCI RETRACEMENTS AND THE RSI

Implementing Ingo Bucher's technique of combining Fibonacci retracements with RSI can be easily implemented in NeuroShell Trader Professional by using Fibonacci retracement indicators from the NeuroShell Turning Points extra cost add-on in addition to standard indicators included with NeuroShell Trader. The Turning Points add-on provides a dynamic and customizable identification of peaks and valleys.

First, insert the standard RSI indicator by doing the following:

1. Select "New Indicator ..." from the Insert menu.
2. Select the "Price Momentum" category.
3. Select the RSI indicator.
4. Set the time series and window you desire.
5. Select the Finished button.
Next, plot the turning points as follows:
1. Select "New Indicator ..." from the Insert menu.
2. Select the "Turning Points" category.
3. Select the TPlot indicator.
4. Change the default time series to the RSI previously plotted.
5. Set the neighborhood parameter for the system of turning points you desire.
6. Select the Finished button.


Next, insert the Fibonacci retracement indicator:

1. Select "New Indicator ..." from the Insert menu.
2. Select the "Turning Points" category.
3. Select the "FibRetr" indicator.
4. Select the previously plotted RSI as the time series
5. Set the desired neighborhood, retracement index, and retracement level.
6. Select the Finished button.


If you decide to use your indicator in a trading strategy, the coefficients may be optimized by the Genetic Algorithm built into NeuroShell Trader Professional. This can provide you with the parameters that maximize profitability.

Users of NeuroShell Trader can go to the STOCKS & COMMODITIES section of the NeuroShell Trader free technical support website to download a sample chart implementing this tip (Figure 5).

FIGURE 5: NEUROSHELL TRADER, FIBONACCI RETRACEMENT. This is a NeuroShell Trader weekly chart of AT&T displaying the dynamic Fibonacci retracement lines superimposed on a graph of the RSI of the close.


--Marge Sherald, Ward Systems Group, Inc.
301 662-7950, sales@wardsystems.com
www.neuroshell.com

GO BACK


NEUROSHELL TRADER: MULTIPLE INDICATORS

To implement the multiple-indicator trading system described in Dennis Peterson's article in this issue, you should first create the new high/low ratio, difference, and signal indicators in a chart, and then create a NeuroShell Trading Strategy based on those indicators (Figure 6).

FIGURE 6: NEUROSHELL TRADER, MULTIPLE-INDICATOR SYSTEM. Here's a sample NeuroShell Trader chart demonstrating the use of multiple indicators in a trading system.
To create ratio, difference, and signal indicators, select "New Indicator ..." from the Insert menu and use the Indicator Wizard to create each of the following:
RATIO:
     Divide ( nh, Add2(nh,nl ) )
          Where
               nh = New Highs
               nl = New Lows
DIFF:
     Expavg1-Expavg2 ( RATIO, 7, 16 )
SIGNAL:
     ExpAvg ( DIFF, 2 )


To create the multiple indicator trading system, select "New Trading Strategy ..." from the Insert menu and enter the following long/short entry/exit conditions in the appropriate locations of the Trading Strategy Wizard:

  Generate a buy long MARKET order if ALL of the following are true:
        A=B( MaximumValue ( A<B( CCI(High,Low,Close,6,0.015), -140 ), 9 ), 1 )
        OR2 ( A>B ( RATIO, 0.4 ), A>B ( SIGNAL, DIFF ) )
  Generate a sell long MARKET order if ALL of the following are true:
        A<B ( RATIO, 0.6 )
        A<B ( SIGNAL, DIFF )
        A>B ( CCI(High,Low,Close,6,0.015), 180 )
  Generate a sell short MARKET order if ALL of the following are true:
A=B( MaximumValue ( A>B( CCI(High,Low,Close,6,0.015), 30 ), 4 ), 1 )
  Generate a cover short MARKET order if ALL of the following are true:
        A>B ( RATIO, 0.6 )
        A>B ( SIGNAL, DIFF )
        A<B ( CCI(High,Low,Close,6,0.015), -130 )
If you have NeuroShell Trader Professional version, 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 multiple indicator system.

Users of NeuroShell Trader can go to the Stocks & Commodities section of the NeuroShell Trader free technical support website to download the sample chart, which includes the multiple indicator trading system.

For more information on NeuroShell Trader, visit www.NeuroShell.com.

--Marge Sherald, Ward Systems Group, Inc.
301 662-7950, sales@wardsystems.com
www.neuroshell.com
 

GO BACK


WEALTH-LAB: FIBONACCI RETRACEMENTS AND THE RSI

You can program the Fibonacci retracement and RSI study discussed by Ingo Bucher in his article this issue very easily in Wealth-Lab Developer 2.1.

There is a distinct advantage of programming the study over relying on manually drawing the Fibonacci levels on the chart. By having a fully programmed study, you can quickly apply the script to numerous charts one after another, and quickly see which markets have RSI values that are reaching Fibonacci support or resistance levels.

Our script given here first establishes an anchor point that is 100 bars from the right edge of the chart. It then finds the highest RSI value that occurred within a 200-bar window of this point. Finally, it locates the lowest RSI value within a 200-bar window from the highest point. The script draws a line on the chart between these two points.

Next, the script calculates the various Fibonacci retracement levels from the RSI low to high. The retracement levels are plotted as dotted lines on the chart. You can now use this script to browse through a series of stocks or futures to find trading candidates. All of the parameters of the script could be modified, including the Fibonacci retracement levels. You could also enhance the script to trigger a signal when the RSI is close to one of the levels.

The script could then be used to automatically scan a universe of historical data. The Wealth-Lab chart shown in Figure 7 displays the Fibonacci retracement levels for the RSI indicator on Cisco Systems. Note how the RSI bounces off resistance three times at the 23.6% retracment level.

FIGURE 7: Wealth-Lab, FIBONACCI RETRACEMENT LEVELS AND RSI. This sample Wealth-Lab chart displays the Fibonacci retracement levels for the Rsi indicator on Cisco Systems. Note how the RSI bounces off resistance three times at the 23.6% retracement level.
{ Declare  Variables }
var Diff, HiVal, LoVal, FibLevel: float;
var i, RSIPane,  RSISer, HiBar, LoBar: integer;
var FibLevels: array[1..4] of float;
var  FibValues: array[1..4] of float;
{ Initialize array  of Fib values }
FibValues := [23.6, 38.2, 50.0, 61.8];
{ Plot the RSI  }
RSIPane := CreatePane( 200, true, false );
SetPaneMinMax( RSIPane, 0,  100 );
RSISer := RSISeries( #Close, 14 );
PlotSeries( RSISer, RSIPane,  #Navy, #Thin );
{ Find the recent  high and previous low of RSI }
HiBar := HighestBar( BarCount - 100, RSISer,  200 );
HiVal := @RSISer[HiBar];
LoBar := LowestBar( HiBar, RSISer, 200  );
LoVal := @RSISer[LoBar];
DrawLine( LoBar, LoVal, HiBar, HiVal, RSIPane,  204, #Thick );
{ Plot the Fib  Levels on the RSI Chart }
Diff := HiVal - LoVal;
for i := 1 to 4  do
begin
  FibLevels[i] := Diff * ( FibValues[i] / 100 );
   FibLevels[i] := HiVal - FibLevels[i];
  DrawLine( LoBar, FibLevels[i],  BarCount - 1, FibLevels[i], RSIPane,
#Blue, #Dotted );
  AnnotateChart(  FormatFloat( '#0.0%', FibValues[i] ), RSIPane, LoBar,
FibLevels[i], 204, 8  );
end;


--Dion Kurczek, Wealth-Lab, Inc.
www.wealth-lab.com

GO BACK


WEALTH-LAB: MULTIPLE INDICATORS

In his article "Trading Systems Using Multiple Indicators" in this issue, Dennis Peterson optimizes the parameters of a trading system for the Qqq.

In Wealth-Lab Developer, you have two choices when optimizing parameters. The first choice is to perform an exhaustive optimization. This method executes the system with every combination of parameters you define. When dealing with a large number of parameters, the optimization can be very lengthy.

The second choice is to use the "Monte Carlo" optimization method. This method selects different random parameter values and records the best-performing values for each optimization pass. It then narrows the windows around the parameters, centering each parameter on the previously detected best value. During each pass through the optimization, the windows shrink around the best values detected so far.

The end result is one range of profitable parameters. The Monte Carlo method will not always find the most profitable range, but it can find a profitable range very quickly. In the sample script given here, we optimized seven system parameters in 15 seconds (Figure 8).

FIGURE 8: WEALTH-LAB, MULTIPLE INDICATORS. This sample Wealth-Lab chart shows an optimized indicator.


Figure 9 displays a chart showing the system results on the QQQ. The optimization selected a range of profitable parameters, but there's no guarantee that these parameters will perform well going forward. One way to deal with this problem is to perform a walk-forward optimization. That is, you optimize on one period of history, and then see how the optimized parameters performed in a future period. This can help you develop robust trading systems that perform well in real-world trading as well as backtesting (Figure 8).

Using the Wealth-Lab Developer Optimization controls, you select the optimization variables, as well as their default, start, stop, and step values. You can optimize on a single symbol or a complete list of symbols (Figure 9). The optimized system shows many profitable trades on the QQQ.

FIGURE 9: WEALTH-LAB, MULTIPLE INDICATORS. This sample Wealth-Lab chart shows the system results on the QQQ. You can optimize on a single symbol or a complete list of symbols. The optimized system shows many profitable trades on the QQQ.
{#OptVar1  12;5;14;1}
{#OptVar2 72;70;110;1}
{#OptVar3 83;70;110;1}
{#OptVar6  12;1;10;1}
{#OptVar7 11;1;10;1}
{#OptVar8 50;50;80;1}
{#OptVar9  20;20;50;1}
{ Declare  Variables }
var NH, NL, RATIO, RPANE, EMA7, EMA16, DIFF, SIGNAL, DPANE, BAR: integer;
var BarOversold,  BarOverbought: integer;
{ Use the updated  EMA formula (MetaStock compatable) }
UseUpdatedEMA(  true );
{ Obtain Nasdaq  new highs and new lows }
nh :=  GetExternalSeries( 'X.NASD-H', #Close );
nl := GetExternalSeries( 'X.NASD-L',  #Close );
{ Obtain the ratio of new highs/new lows }
ratio :=  DivideSeries( nh, AddSeries( nh, nl ) );
RPane := CreatePane( 80, true, true  );
PlotSeries( ratio, RPane, #Teal, #Thick );
DrawLabel( 'New High/New Low  Ratio', RPane );
{ Create the  "MACD" of new highs/new lows }
ema7 := EMASeries(  ratio, 7 );
ema16 := EMASeries( ratio, 16 );
diff := SubtractSeries( ema7,  ema16 );
signal := EMASeries( diff, 2 );
DPane := CreatePane( 100, true,  true );
PlotSeries( diff, DPane, 844, #ThickHist );
PlotSeries( signal,  DPane, #Black, #Thin );
DrawLabel( 'EMA(Ratio,7) - EMA(Ratio,16) and Signal  Line', DPane );
{ Plot the CCI  }
var CCIPane:  integer;
CCIPane := CreatePane( 80, true, true );
PlotSeries( CCISeries(  #OptVar1 ), CCIPane, 520, #Thick );
DrawLabel( 'CCI(' + IntToStr( #OptVar1 )  + ')', CCIPane );
{ Trading system  rules }
BarOversold :=  0;
BarOverbought := 0;
for Bar := 40 to BarCount - 1 do
begin
   if CCI( Bar, #OptVar1 ) < -#OptVar2 then
    BarOversold :=  Bar;
  if CCI( Bar, #OptVar1 ) > #OptVar3 then
     BarOverbought := Bar;
{ Exit Long }
  if MarketPosition = 1  then
  begin
    if @ratio[Bar] < 0.6  then
      if @signal[Bar] < @diff[Bar]  then
        if CCI( Bar, #OptVar1 ) >  #OptVar3 then
           SellAtMarket( Bar + 1, LastPosition, '' );
  end
{ Exit Short  }
  else if MarketPosition = -1 then
   begin
    if @ratio[Bar] > #OptVar8 / 100  then
      if @signal[Bar] > @diff[Bar]  then
        if CCI( Bar, #OptVar1 ) <  -#OptVar2 then
           CoverAtMarket( Bar + 1, LastPosition, '' );
  end;
{ Enter Long  }
  if MarketPosition = 0 then
  begin
    if  Bar - BarOversold <= #OptVar6 then
      if (  @ratio[Bar] > #OptVar9 / 100 ) or ( @signal[Bar] > @diff[Bar] )
then
        BuyAtMarket( Bar + 1, ''  );
  end;
{ Enter Short }
  if MarketPosition = 0  then
  begin
    if Bar - BarOverbought <= #OptVar7  then
      ShortAtMarket( Bar + 1, '' );
   end;
end;


--Dion Kurczek, Wealth-Lab, Inc.
www.wealth-lab.com
 

GO BACK


NEOTICKER: FIBONACCI RETRACEMENTS AND THE RSI

In this tip, we will provide two examples of how to implement in NeoTicker the concept presented in "Fibonacci Retracements And The Rsi" by Ingo Bucher.

First, create the weekly AT&T chart by creating a new chart. Then add a new data series with the symbol "T" to the chart and set the time frame to weekly. Right-click on the chart and select "Days of data to load" from the popup menu. Specify the first date you would like to load the data series from. In this case, change the date to 1/1/1999, which will force the chart to load weekly data from 1/1/1999.

Next, add RSI indicator to the chart. Right-click on the data series and select "Add indicator" from the popup menu. When the "Add indicator" window opens up, choose "Relative strength index modified" in the indicator selection area. RSI will show up in another pane after you press the Apply button.

The next step is to add the Fibonacci retracements lines to the RSI indicator. Click on the Fib button on the toolbar to select the Fib drawing tool. You can now draw the Fib lines by left-clicking and then dragging the Fib lines onto the chart. NeoTicker's Fibonacci lines default to ratios between 0% and 100%. Drawing it toward the right will make it go from 0%, showing at the top, down to 100%, which will show at the bottom.

To add the 23.6% ratio, right-click on the Fibonacci lines object and select "Edit." The edit window for the Fib tool will show up. Click on the "Fib" tab, enter the number 0.236, and press the [+] button to add the additional Fibonacci ratio line.

Repeat the same steps to add other Fibonacci lines to the data series. The resulting chart should look similar to Figure 10. Another example applying the same technique on Dcx is shown in Figure 11.

FIGURE 10: NEOTICKER, FIBONACCI RETRACEMENTS & RSI. Here's an example of adding Fibonacci lines to the data series.
 


FIGURE 11: NEOTICKER, FIBONACCI RETRACEMENTS & RSI. Here's an example of adding Fibonacci lines to a chart of DCX.


--Kenneth Yuen, TickQuest Inc.
www.tickquest.com
 

GO BACK


Investor/RT: FIBONACCI RETRACEMENTS AND THE RSI

In "Combining Fibonacci Retracements and the RSI" in this issue, Ingo Bucher combines Fibonacci retracements with the RSI to help identify significant support and resistance levels.

In Investor/RT, Fibonacci retracement lines can be added not only to instrument data, but also to any technical indicator. In the middle pane of Figure 12, the RSI indicator is overlaid with Fibonacci retracement lines. The trendline on which the Fibonacci retracement is based is drawn between extreme highs and lows of the RSI.

To make the Fibonacci retracement indicator work properly when drawn on top of technical indicators, it must be set up to the "user price" for both the "begin" and "end" points. In addition, in the scale preferences, "Use multiple scales" must be turned off (unchecked).

Also in Figure 12, the lower pane shows the stochastic RSI. The stochastic RSI can be coded using a custom indicator with the following syntax:

FASTD(RSI)
In this case, a Fastd period of 100 was used. This stochastic RSI represents the current position of the RSI in relation to the range over the past 100 periods. A value of "0" means that the RSI is currently at the low of the range of values over the past 100 periods, while a value of 100 means it is currently at the high of that period. The Investor/RT stochastics indicator also has a "Retracement-based" checkbox, which forces the indicator to consider which came first, the high or the low, and then to calculate the retracement of the current price level based on this order.

FIGURE 12: INVESTOR/RT DAILY CANDLESTICK CHART OF INTC. The middle pane shows the RSI overlaid with the Fibonacci retracement indicator. The lower pane shows the stochastic of RSI indicator.


--Chad Payne, Linn Software
800-546-6842, info@linnsoft.com
www.linnsoft.com

GO BACK


INVESTOR/RT: MULTIPLE INDICATORS

The difference and signal indicators discussed in Dennis Peterson's article in this issue, "Trading Systems Using Multiple Indicators," can be coded with Investor/RT custom indicators using the following syntax:

Difference
MAb(CL(YRHI.NQ)/(CL(YRHI.NQ) + CL(YRLO.NQ))) - MAc(CL(YRHI.NQ)/(CL(YRHI.NQ) + CL(YRLO.NQ)))
Signal
MAa(MAb(CL(YRHI.NQ)/(CL(YRHI.NQ) + CL(YRLO.NQ))) - MAc(CL(YRHI.NQ)/(CL(YRHI.NQ) + CL(YRLO.NQ))))
FIGURE 13: INVESTOR/RT, MULTIPLE INDICATORS. Here is an Investor/RT daily continuous line chart of YRHI.NQ (green) and YRLO.NQ (red). The bottom pane shows the difference (blue line) and signal (red/green histogram) custom investors.
 

Figure 13 shows a daily continuous line chart of both the Nasdaq highs (Yrhi.NQ) in green and the Nasdaq lows (Yrlo.NQ) in red. In the lower pane, the difference and signal custom indicators are plotted. The difference indicator is plotted as a blue line overlaying the signal histogram.

These custom indicators can be used in conjunction with Investor/RT backtesting facility to test any combinations of options using signals with the syntax:

RATIO > OPT AND SIGNAL > DIFF
or
RATIO < OPT AND SIGNAL < DIFF
where Ratio, Signal, and Diff are simply custom indicator tokens renamed, and Opt is whatever constant you choose to use in your test. The Ratio custom indicator would be coded using the following syntax:
CL(YRHI.NQ)/(CL(YRHI.NQ)
--Chad Payne, Linn Software
800-546-6842, info@linnsoft.com
www.linnsoft.com

GO BACK


TECHNIFILTER PLUS: FIBONACCI RETRACEMENTS AND THE RSI

Here is a TechniFilter Plus formula that will display the RSI with overlaid Fibonacci levels, which is similar to the charts shown in Ingo Bucher's article in this issue, "Fibonacci Levels And The RSI." The formula uses chart directives to set the color and label the level values for each level.
 

RSI with Fibonacci Levels Overlaid
NAME: RSI_FIB
SWITCHES: multiline
FORMULA:
[1]: CG14 {nc} {c}{nRSI}   {rgb#16711680}
[2]: 100 - 23.6 {a}  {c}{n23.6%} {rgb#255}
[3]: 100 - 38.2 {a}  {c}{n38.2%} {rgb#255}
[4]: 100 - 50 {a}  {c}{n50%}   {rgb#255}
[5]: 100 - 61.8 {a}  {c}{n61.8%} {rgb#255}
[6]: 100 - 100 {a}  {c}{n0%}    {rgb#255}


Visit RTR's website to download this formula as well as program updates.

--Clay Burch, RTR Software
919 510-0608, rtrsoft@aol.com
www.rtrsoftware.com
 

GO BACK


SMARTrader: FIBONACCI RETRACEMENTS AND THE RSI

For this Traders' Tip, we elected to replicate the example shown in Figure 2 of Ingo Bucher's article, "Fibonacci Retracements And The RSI."

The SmarTrader specsheet for this study is shown in Figure 14. After loading the 10-year note yield, we added the RSI 14 study in row 9. Rows 10 and 11 are coefficients where we place the relative high and relative low values of the RSI.

FIGURE 14: SMARTRADER, SPECSHEET FOR FIBONACCI RETRACEMENTS & RSI. Here's a SmarTrader specsheet for calculating retracement values.


Rows 12 through 15 are coefficients that contain the traditional Fibonacci retracement percentages.

Rows 16 through 19 are user rows where we calculate the retracement values. This is done by taking the difference of relative high minus relative low, then multiply that difference by the retracement percentage (divided by 100) and finally subtract the result from the relative high. This is repeated for each of the retracement percentages. A sample chart showing the result is in Figure 15.

FIGURE 15: SMARTRADER, FIBONACCI RETRACEMENTS & RSI. Here's a sample SmarTrader chart plotting the RSI with Fibonacci retracements.


CompuTrac Snap users can use this system with no changes.

- Jim Ritter, Stratagem Software
504 885-7353, Stratagem1@aol.com
GO BACK



All rights reserved. © Copyright 2003, Technical Analysis, Inc.


Return to March 2003 Contents