December 2005
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: OVERHAULING MARKET BREADTH
  METASTOCK: OVERHAULING MARKET BREADTH
  WEALTH-LAB: OVERHAULING MARKET BREADTH
  AMIBROKER: OVERHAULING MARKET BREADTH
  eSIGNAL: OVERHAULING MARKET BREADTH
  NEUROSHELL TRADER: OVERHAULING MARKET BREADTH
  NEOTICKER: OVERHAULING MARKET BREADTH
  TRADING SOLUTIONS: OVERHAULING MARKET BREADTH
  AIQ TRADINGEXPERT: OVERHAULING MARKET BREADTH
  FINANICAL DATA CALCULATOR: OVERHAULING MARKET BREADTH

or return to December 2005 Contents



TRADESTATION: OVERHAULING MARKET BREADTH

Jacobus van den Brink's article in this issue, "Overhauling Market Breadth," presents a modified version of the Arms index (Figure 1). To download the code for this indicator, search for the file "Brin.eld" at the TradeStation Support Center at TradeStation.com in the "TradeStation and EasyLanguage Support" discussion forum.
 


FIGURE 1: TRADESTATION, BRIN. Here is a sample implementation of Jacobus van den Brink's transformed Arms index indicator, or BRIN. Subgraph 1 (top of chart) contains $NDX.X (NASDAQ 100 index) one-minute bars. Directly beneath the price bars is the BRIN indicator (in subgraph 2). Subgraph 3, below BRIN, shows $TRINQ (NASDAQ TRIN). Subgraph 4 is of $ADVQ (NASDAQ advancing issues) and $DECLQ (NASDAQ declining issues). Subgraph 5 shows $UVOLQ (NASDAQ advancing volume) and $DVOLQ (NASDAQ declining volume).
Indicator:   _BRIN
inputs:
 Advn( Close Data2 ), { Advancing issues }
 Decl( Close Data3 ), { Declining issues }
 UpVol( Close Data4 ), { Advancing volume }
 DnVol( Close Data5 ) ; { Declining volume }
variables:
 DURatio( 0 ),
 SqrDU( 0 ),
 ADRatio( 0 ),
 SqrAD( 0 ),
 Brin( 0 ),
 ILine( 0 ),
 VLine( 0 ) ;
if UpVol <> 0 then
 DURatio = DnVol / UpVol ;
SqrDU = Square( DURatio ) ;
if Decl <> 0 then
 ADRatio = Advn / Decl ;
SqrAD = Square( ADRatio ) ;
Brin = ( 1 - DURatio * ADRatio ) / MaxList( 1,
 DURatio * ADRatio ) ;
ILine = ( 1 - SqrAD ) / MaxList( 1, SqrAD ) ;
Vline = ( 1 - SqrDU ) / MaxList( 1, SqrDU ) ;
Plot1( Brin, "Brin" ) ;
Plot2( ILine, "ILine" ) ;
Plot3( VLine, "VLine" ) ;
Plot4( 0, "Zero" ) ;
--Mark Mills, EasyLanguage Engineer
TradeStation Securities, Inc.
www.TradeStationWorld.com


GO BACK


METASTOCK: OVERHAULING MARKET BREADTH

Jacobus van den Brink's article, "Overhauling Market Breadth," describes two alternative methods of calculating the TRIN, or Arms index. While most of his article focuses on method 2, both formulas are included below.

The TRIN requires broad market data for the number of advancing issues, declining issues, advancing volume, and declining volume. This data and the basic Trin calculation is installed with all versions of MetaStock since 8.0. The formulas below use the Reuters Datalink version of the broad market data. It is possible to use other sources for the data. You would just need to adjust the path and ticker symbols listed in the security data functions.

To enter these indicators into MetaStock, follow these steps:
 

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 following formula:
Name:  BRIN (method 1)
Formula:
ADI:=Security("C:\MetaStock Data\BM Data\X.NYSE-A",C);
USV:=Security("C:\MetaStock Data\BM Data\X.NYSE-A",V);
DCI:=Security("C:\MetaStock Data\BM Data\X.NYSE-D",C);
DSV:=Security("C:\MetaStock Data\BM Data\X.NYSE-D",V);
trin:=(ADI/DCI)/(USV/DSV);
(trin-1)/max(1,trin)
5. Click OK to close the Indicator Editor.
6. Repeat steps 2-5 for the second indicator.
Name:  BRIN (method 2)
Formula:
ADI:=Security("C:\MetaStock Data\BM Data\X.NYSE-A",C);
USV:=Security("C:\MetaStock Data\BM Data\X.NYSE-A",V);
DCI:=Security("C:\MetaStock Data\BM Data\X.NYSE-D",C);
DSV:=Security("C:\MetaStock Data\BM Data\X.NYSE-D",V);
trin:=(ADI/DCI)/(USV/DSV);
(1-trin)/max(1,trin)
--William Golson
MetaStock Support Representative
Equis International (A Reuters Company)
801 265-9998, www.metastock.com


GO BACK


WEALTH-LAB: OVERHAULING MARKET BREADTH

We created a Chartscript based on the BRIN indicator described by Jacobus van den Brink in his article in this issue, "Overhauling Market Breadth." Both the BRIN and the TRIN are now part of the code library.

As the BRIN is based on the TRIN, we designed the system according to entry/exit rules originally suggested by Richard Arms, author of the TRIN, or Arms index. He considered the market to be overbought when the 10-day moving average of the TRIN declines below 0.8 and oversold when it moves above 1.2. Consequently, our system uses a 10-day simple moving average of the BRIN and goes long in the selected symbol when the indicator falls below -0.17 (oversold market) and exits the position as soon it rises above 0.2 (overbought market). See Figure 2.
 


FIGURE 2: WEALTH-LAB, BREADTH INDEX (BRIN). The upper pane shows the 10-day SMA of the BRIN indicator, which itself is based on the (one-minute) intraday data of the 30 Dow Jones industrial average stocks. As you can see, Microsoft (lower pane) made similar movements intraday, and it is possible to take advantage of these moves using the BRIN. Just before MSFT makes a move, the market as a whole exits its overbought/oversold situation.
WealthScript code:
{$I 'BRIN'}
var Bar: integer;
var BrinSMA, brinpane:integer;
// Creating the SMA of the BRIN indicator
BrinSMA := SMASeries( Brin, 10 );
// Plotting the indicator
brinpane:= Createpane( 100, true, true );
DrawHorzLine( 0, brinpane, #black, #thin );
DrawHorzLine( -0.17, brinpane, #green, #thin );
DrawHorzLine( 0.2, brinpane, #green, #thin );
SetPaneMinMax( brinpane, -0.5, 0.5 );
PlotSeriesLabel( BrinSMA, brinpane, #red, #thin, 'SMA(BRIN, 10)' );
for Bar := 1 to BarCount - 1 do
begin
  if not LastPositionActive then
    begin
    if @BRINSMA[Bar] < -0.17 then BuyAtMarket( Bar+1, 'Market oversold' );
    end
  else
    begin
    if @BRINSMA[Bar] > 0.2 then SellAtMarket( Bar+1, LastPosition, 'Market overbought' );
    end;
end;


--José Cruset
www.wealth-lab.com


GO BACK


AMIBROKER: OVERHAULING MARKET BREADTH

In "Overhauling Market Breadth" in this issue, Jacobus van den Brink presents a transformation of the Arms index that makes it more useful for everyday trading. The resulting BRIN indicator is bounded and symmetrical.

To compute BRIN and the other market breadth indicators presented in the article, we need data for volume and the number of advancing/declining issues in a given market. Most data sources provide such statistics, but symbols used are data-source dependent. In the code shown here, we have presented AmiBroker's BRIN implementation using eSignal data symbology as an example (Figure 3). Readers wanting to use this code with other data providers would need to adjust the symbols used in foreign function calls to match the data provider's symbology.
 


FIGURE 3: AMIBROKER, BREADTH INDICATOR. Here is a sample AmiBroker one-minute NASDAQ composite chart with BRIN, ILine, and VLine using eSignal data.
AmiBroker code:
function BrinTransform( x )
{
  return ( 1 - x )/Max( 1, x );
}
// data-source dependent symbols
dnvol= Foreign("$DVOLQ", "C");
upvol= Foreign("$UVOLQ", "C");
advn = Foreign("$ADVQ", "C" );
decl = Foreign("$DECLQ", "C");
Trinx = (dnvol/ upvol ) * ( advn / decl );
BRINx = BrinTransform( Trinx );
ILine = BrinTransform( (advn/decl)^2 );
VLine = BrinTransform( (dnvol/upvol)^2 );
//Plot( Trinx, "Trinx", colorRed );
Plot( BRINX, "BRIN", colorBlack );
Plot( ILine , "ILine", colorBlue );
Plot( VLine , "VLine", colorViolet );


 This code can be copied and pasted from the Stocks & Commodities website at www.traders.com.

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


eSIGNAL: OVERHAULING MARKET BREADTH

For Jacobus van den Brink's article in this issue, "Overhauling Market Breadth," we've developed the following eSignal code. The study plots the BRIN, ILine, and VLine indicators (Figure 4). The study has one formula parameter that will set the base index for the indicator calculations between the NYSE and NASDAQ exchanges. This parameter is set to NASDAQ by default. To change the parameter, use the "Edit Studies" option of the Advanced Chart.
 


FIGURE 4: eSIGNAL, BREADTH INDICATOR. Here are sample results of the eSignal study plotting the BRIN, ILine, and VLine indicators on the NASDAQ index.


To discuss this study or download a complete copy of the formula, please visit the EFS Library Discussion Board forum under the Bulletin Boards link at www.esignalcentral.com. Look for the eSignal formula script (EFS) file named "Brin.efs."

The code is also posted as text at the STOCKS & COMMODITIES website at www.Traders.com.
 

/***************************************
Provided By : eSignal (c) Copyright 2005
Description:  Overhauling Market Breadth - by Jacobus R. van den Brink
Version 1.0  10/11/2005
Notes:
December 2005 issue of Stocks & Commodities magazine
* Study requires version 7.9 or higher.
Formula Parameters:   Defaults:
Index                               NASDAQ
    [NYSE, NASDAQ]
***************************************/
function preMain() {
    setStudyTitle("BRIN");
    setShowTitleParameters(false);
    setCursorLabelName("Brin", 0);
    setCursorLabelName("ILine", 1);
    setCursorLabelName("VLine", 2);
    setDefaultBarFgColor(Color.black, 0);
    setDefaultBarFgColor(Color.blue, 1);
    setDefaultBarFgColor(Color.purple, 2);
    setDefaultBarThickness(2, 0);
    setDefaultBarThickness(2, 1);
    setDefaultBarThickness(2, 2);
    setStudyMax(1.3);
    setStudyMin(-1.3);
    addBand(0, PS_SOLID, 1, Color.black, "0");
    addBand(1, PS_SOLID, 1, Color.black, "1+");
    addBand(-1, PS_SOLID, 1, Color.black, "1-");
 
    var fp1 = new FunctionParameter("Index", FunctionParameter.STRING);
        fp1.setName("Index");
        fp1.addOption("NASDAQ");
        fp1.addOption("NYSE");
        fp1.setDefault("NASDAQ");
 
}
var bVersion = null;
var bInit = false;
var Brin = null;
var ILine = null;
var VLine = null;
function main(Index) {
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return;
    if (bInit == false) {
        Brin = efsInternal("calcLine", "Brin", Index);
        ILine = efsInternal("calcLine", "ILine", Index);
        VLine = efsInternal("calcLine", "VLine", Index);
        bInit = true;
    }
 
    return new Array(getSeries(Brin), getSeries(ILine), getSeries(VLine));
}
/***** Support Functions *****/
var bInitcalcLine = false;
var xDnVol = null;
var xUpVol = null;
var xAdvn = null;
var xDecl = null;
function calcLine(line, i) {
    if (bInitcalcLine == false) {
        if (i == "NYSE") {
            xDnVol = close(sym("$DVOL"));
            xUpVol = close(sym("$UVOL"));
            xAdvn = close(sym("$ADV"));
            xDecl = close(sym("$DECL"));
        } else {
            xDnVol = close(sym("$DVOLQ"));
            xUpVol = close(sym("$UVOLQ"));
            xAdvn = close(sym("$ADVQ"));
            xDecl = close(sym("$DECLQ"));
        }
        bInitcalcLine = true;
    }
    if (xDnVol == null || xUpVol == null || xAdvn == null || xDecl == null) return;
 
    var DnVol = xDnVol.getValue(0);
    var UpVol = xUpVol.getValue(0);
    var Advn = xAdvn.getValue(0);
    var Decl = xDecl.getValue(0);
    var retVal = null;
 
    switch(line) {
        case "Brin":
            retVal = (1 -(DnVol/UpVol)*(Advn/Decl)) / Math.max(1, (DnVol/UpVol)*(Advn/Decl));
            break;
        case "ILine":
            retVal = (1-Math.pow((Advn/Decl), 2)) / Math.max(1, Math.pow((Advn/Decl), 2));
            break;
        case "VLine":
            retVal = (1-Math.pow((DnVol/UpVol), 2)) / Math.max(1, Math.pow((DnVol/UpVol), 2));
            break;
    }
    return retVal;
}
function verify() {
    var b = false;
    if (getBuildNumber() < 700) {
        drawTextAbsolute(5, 35, "This study requires version 7.9 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


GO BACK


NEUROSHELL TRADER: OVERHAULING MARKET BREADTH

The BRIN, ILine, and VLine indicators described by Jacobus van den Brink in his article in this issue can be easily implemented in NeuroShell Trader by combining a few of NeuroShell Trader's 800-plus  indicators. The DNVOL, UPVOL, ADVN, and DECL data are inserted into the chart as "other instrument data." The names may vary depending on the data vendor and index.

To implement these indicators, select "New Indicator ..." from the Insert menu and use the Indicator Wizard to create the following indicators:
 

DNVOL/UPVOL: Divide ( DNVOL, UPVOL )
ADVN/DECL: Divide ( ADVN, DECL )
(These are created as the basis of other indicators)
BRIN: Divide ( ( Subtract (1, Multiply ( DNVOL/UPVOL, ADVN/DECL ) ) ) ,
 ( Max ( Multiply ( DNVOL/UPVOL, ADVN/DECL ), 1 )  )
 )
ILine: Divide ( ( Subtract ( 1, Multiply ( ADVN/DECL, ADVN/DECL ) ) ) ,
 ( Max ( Multiply ( ADVN/DECL, ADVN/DECL ), 1 ) )
 )
VLine:  Divide ( ( Subtract ( 1, Multiply ( DNVOL/UPVOL, DNVOL/UPVOL ) ) ) ,
 ( Max ( Multiply ( DNVOL/UPVOL, DNVOL/UPVOL ), 1 ) )
 )


 For more information on NeuroShell Trader, visit www.NeuroShell.com. A sample chart is shown in Figure 5.
 


FIGURE 5: NEUROSHELL, BREADTH INDEX (BRIN). Here is a sample NeuroShell chart demonstrating the BRIN with ILine and VLine.
 
 

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

GO BACK


NEOTICKER: OVERHAULING MARKET BREADTH

The three revised market breadth statistics described by Jacobus van den Brink in his article can be done in one line using NeoTicker formula language indicators.

  • TASC BRIN indicator (Listing 1): Requires four data series as inputs: advancing issues, declining issues, up volume, and down volume. The result plots a chart line showing values of BRIN, which is the overhauled market breadth.
  • TASC issue line (Listing 2): Requires two data series as inputs: advancing issues and declining issues. The result plots a chart line for values of ILine.
  • TASC volume line (Listing 3): Requires two data series as input: up volume and down volume. The result plots a chart line for values of VLine.
  • To help users further pursue this concept of overhauling market breadth, NeoTicker offers two relevant features: user-defined symbols and NeoBreadth. User-defined symbols allow users to build tick-by-tick custom market statistics. Using this feature, users can build tick-by-tick statistics based on custom symbol lists or exchange-broadcast market statistics. NeoBreadth can handle more complex formula-based statistics such as a moving average of a group of symbols or relative strength index (RSI) of a group of symbols.
     


    FIGURE 6: NEOTICKER, BRIN. Here is a sample intraday chart showing Jacobus van den Brink's market breadth indicator (BRIN), issue line (ILine), and volume line (VLine). Also shown is the original TRIN.


    Visit the TickQuest website for more information on these two customizable market breadth features in NeoTicker.
     

    LISTING 1
    'TASC Brin indicator
    $DNVOL := data1;
    $UPVOL := data2;
    $ADVN  := data3;
    $DECL  := data4;
    $Denom := ($DNVOL/$UPVOL)*($ADVN/$DECL);
    plot1 := if($Denom=0, 0, if($Denom>1, (1-$Denom), (1-$Denom)/$Denom));
    LISTING 2
    $ADVN := data1;
    $DECL := data2;
    $Denom := ($ADVN/$DECL);
    plot1 := if($Denom=0, 0, (1-$Denom)/$Denom);
    LISTING 3
    $UPVOL := data1;
    $DNVOL := data2;
    plot1 := 1-($DNVOL/$UPVOL);


     A downloadable version of the indicators will be available through the NeoTicker Yahoo! User Group.

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


    TRADING SOLUTIONS: OVERHAULING MARKET BREADTH

    In the article "Overhauling Market Breadth," Jacobus van den Brink provides a transformation for displaying the Arms index and its components in a compact space.

    These functions can be entered into TradingSolutions using the following code:
     

    Function Name: Breadth Index
    Short Name: BRIN
    Inputs: Advancing Issues, Declining Issues, Advancing Volume, Declining Volume
    Div (Sub (1,Arms (Advancing Issues, Declining Issues, Advancing Volume, Declining Volume)),
     Max (1,Arms (Advancing Issues, Declining Issues, Advancing Volume, Declining Volume)))
    Function Name: Issues Line
    Short Name: ILine
    Inputs: Advancing Issues, Declining Issues
    Div (Sub (1,Pow (Div (Advancing Issues, Declining Issues),2)),Max (1,Pow (Div (Advancing
     Issues, Declining Issues),2)))
    Function Name: Volume Line
    Short Name: VLine
    Inputs: Advancing Volume, Declining Volume
    Div (Sub (1,Pow (Div (Declining Volume, Advancing Volume),2)),Max (1,Pow (Div (Declining
     Volume, Advancing Volume),2)))


     This code is also available as a function file that can be downloaded from the TradingSolutions website (www.tradingsolutions.com) in the Solution Library section.

    --Gary Geniesse
    NeuroDimension, Inc.
    800 634-3327, 352 377-5144
    www.tradingsolutions.com


    GO BACK


    AIQ TRADINGEXPERT: OVERHAULING MARKET BREADTH

    The AIQ code is shown here for the indicators described by Jacobus van den Brink in his article in this issue, "Overhauling Market Breadth." In generating the indicators, I added a scaling factor and smoothed them over a 10-day period with exponential averaging, which is the usual smoothing for the TRIN. In Figure 7, the indicators are plotted for the NASDAQ just before and after the market low of October 10, 2002.
     


    FIGURE 7: AIQ, BRIN INDICATOR. Here is a sample chart of BRIN in AIQ TradingExpert Pro.


    The AIQ program is capable of generating custom markets using any list of stocks. For example, a market can be created for the Russell 2000, the NASDAQ 100 and/or the Standard & Poor's 500, and the BRIN, ILine, and VLine indicators can be displayed for each of these. Because of this feature, the program is not limited to only those markets for which the data can be downloaded from an exchange.
     

    !! TRIN & BRIN: Overhauling Market Breadth by J van den Brink, TASC Dec 2005
    !  Coded by: Rich Denning 10/10/05
    !  Note: the indicators are scaled and smoothed for display purposes [not in the article].
    TRIN is expavg(iff(market(),([Dec Volume] / [Dec Issues])
     / ([Adv Volume] / [Adv Issues]),-9999) * 100,10).
    BRIN is expavg(iff(market(),(1 - ([Dec Volume] / [Adv Volume]) * ([Adv Issues] / [Dec Issues]))
     / Max(1,([Dec Volume] / [Adv Volume]) * ([Adv Issues] / [Dec Issues])),-9999)*1000,10).
    ILine is expavg(iff(market(),(1 - Power(([Adv Issues] / [Dec Issues]),2))
     / max(1,Power(([Adv Issues] / [Dec Issues]),2)),-9999)*1000,10).
    VLine is expavg(iff(market(),(1 - Power(([Dec Volume] / [Adv Volume]),2))
     / max(1,Power(([Dec Volume] / [Adv Volume]),2)),-9999)*1000,10).


     This AIQ code can be downloaded from AIQ's website at www.aiqsystems.com.

    --Richard Denning, Aiq Systems
    richard.denning@earthlink.net


    GO BACK


    FINANICAL DATA CALCULATOR: OVERHAULING MARKET BREADTH

    The article "Overhauling Market Breadth" by Jacobus van den Brink modifies the Arms index (TRIN) and introduces three new functions: BRIN, ILine, and VLine.

    We will assume that you have the following four daily datasets:
     

    decl (total number of declining issues each day)
    dnvol (total daily volume of declining issues)
    advn (total number of advancing issues each day)
    upvol (total daily volume of advancing issues)
    
    For BRIN, open the macro wizard, choose "new macro," and enter the following code into the definition window:
     
    volratio : dnvol/upvol
    numratio : advn/decl
    trin : volratio * numratio
    (1 - trin) / (1 max trin)


    Save this macro under the name "brin." It takes no explicit arguments and it outputs the BRIN dataset.

    For ILine, open the macro wizard, choose "new macro," and enter the following code into the definition window:
     

    numratio : advn/decl
    (1 - numratio^2) / 1 max numratio^2


    then save as "iline."

    For VLine, open the macro wizard, choose new macro, and enter the following code into the definition window:
     

    volratio : dnvol/upvol
    (1 - volratio ^2) / 1 max volratio ^2
    
    then save as "vline."
    --William Rafter
    Mathematical Investment Decisions, Inc.
    www.mathinvestdecisions.com
    GO BACK

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


    Return to December 2005 Contents