August 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: STOCHASTICS AND PRICE RANGE DYNAMICS
  METASTOCK: STOCHASTICS AND PRICE RANGE DYNAMICS
  AIQ EXPERT DESIGN STUDIO: STOCHASTICS AND PRICE RANGE DYNAMICS
  WEALTH-LAB: STOCHASTICS AND PRICE RANGE DYNAMICS
  NEUROSHELL TRADER: STOCHASTICS AND PRICE RANGE DYNAMICS
  AMIBROKER: STOCHASTICS AND PRICE RANGE DYNAMICS
  eSIGNAL: STOCHASTICS AND PRICE RANGE DYNAMICS
  INVESTOR/RT: STOCHASTICS AND PRICE RANGE DYNAMICS
  TRADING SOLUTIONS: STOCHASTICS AND PRICE RANGE DYNAMICS
  TECHNIFILTER PLUS: STOCHASTICS AND PRICE RANGE DYNAMICS
  NEOTICKER: STOCHASTICS AND PRICE RANGE DYNAMICS
  TRADE NAVIGATOR: STOCHASTICS AND PRICE RANGE DYNAMICS
  BULLCHARTS: STOCHASTICS AND PRICE RANGE DYNAMICS

or return to August 2005 Contents



TRADESTATION: STOCHASTICS AND PRICE RANGE DYNAMICS

Andrew Tomlinson's article in this issue, "Stochastics And Price Range Dynamics: Home, Home On The Range," reviews two techniques for evaluating price ranges: price bands and stochastics. In addition, he compares the use of current-day and previous-day price ranges for both price bands and stochastics.

Figure 1: TRADESTATION, Stochastics And Price Range Dynamics, MCK DAILY BARS. The upper three subgraphs display Tomlinson's indicators using the highest high as of one bar ago (set the input "Displacement" to 1). The lower three subgraphs show the same indicators using the highest high, including this bar (set the input "Displacement" to zero).

The EasyLanguage code for performing these studies may be downloaded from the TradeStation Support Center, which is accessible from TradeStation.com. Look for the file "Tomlinson.eld." The code is also shown here.
 

Indicator: _AB_Stochastics
inputs:
 Length( 14 ),
 Displacement( 0 ) ;
variables:
 HighBand( 0 ),
 LowBand( 0 ),
  RangeValue( 0 ),
 PositionValue( 0 ),
 SummRange( 0 ),
 SummPos( 0 ),
 Raw( 0 ),
 Quick( 0 ),
 Slow( 0 ) ;
HighBand = Highest( High[Displacement], Length ) ;
LowBand = Lowest( Low[Displacement], Length ) ;
RangeValue = HighBand - LowBand ;
PositionValue = Close - LowBand ;
SummRange = Summation( RangeValue, 3 ) ;
SummPos = Summation( PositionValue, 3 ) ;
if RangeValue <> 0 then
 Raw = 100 * PositionValue / RangeValue ;
if SummRange <> 0 then
 Quick = 100 * SummPos / SummRange ;
Slow = Average( Quick, 3 ) ;
Plot1( Quick, "Quick" ) ;
Plot2( Slow, "Slow" ) ;
Plot3( 100, "100" ) ;
Plot4( 0, "0" ) ;
//Plot5( Raw, "Raw" ) ; { optional plot - comment in if
// desired }
Indicator: _AT_PriceBandOsc
inputs:
 Length( 14 ),
 Displacement( 1 ) ;
variables:
 HighBand( 0 ),
 LowBand( 0 ),
 PositionValue( 0 ),
  RangeValue( 0 ),
 PBOsc( 0 ) ;
HighBand = Highest( High[Displacement], Length ) ;
LowBand = Lowest( Low[Displacement], Length ) ;
PositionValue = Close - LowBand ;
RangeValue = HighBand - LowBand ;
if RangeValue <> 0 then
 PBOsc = 100 * PositionValue / RangeValue ;
 Plot1( PBOsc, "PBOsc" ) ;
Indicator: _AT_PriceBands
inputs:
 Length( 14 ),
 Displacement( 1 ) ;
variables:
 HighBand( 0 ),
 LowBand( 0 ) ;
HighBand = Highest( High[Displacement], Length ) ;
LowBand = Lowest( Low[Displacement], Length ) ;
Plot1( HighBand, "HighBand" ) ;
Plot2( LowBand, "LowBand" ) ;
--Mark Mills
TradeStation Securities, Inc.
A subsidiary of TradeStation Group, Inc.
 www.TradeStationWorld.com
GO BACK

METASTOCK: STOCHASTICS AND PRICE RANGE DYNAMICS

Editor's note: MetaStock formulas for Andrew Tomlinson's article were provided by Tomlinson in his article. See pages 70-73 of this issue.

GO BACK


AIQ EXPERT DESIGN STUDIO: STOCHASTICS AND PRICE RANGE DYNAMICS

This code is based on Andrew Tomlinson's article in this issue, "Home, Home On The Range."
 

!! Stochastics And Price Range Dynamics
!! Author: Andrew Tomilinson, TASC August 2005
!! Coded by: Richard Denning 6/09/05
!CODING ABREVIATIONS:
H is [high].
H1  is val([high],1).
L is [low].
L1  is val([low],1).
C is [close].
C1 is val([close],1).
O is [open].
! DONCHIAN PRICE CHANNEL BANDS
DonH14 is highresult(H,14,1).
DonL14 is lowresult(L,14,1).
! DONCHIAN PRICE BAND OSCILLATOR
DonPBO is 100 * (C - DonL14) / (DonH14 - DonL14).
! STOCHASTIC RAW CHANNEL
StoH14 is highresult(H,14,0).
StoL14 is lowresult(L,14,0).
! STOCHASTIC RAW OSCILATOR or %K
StoRO is (C - StoL14) / (StoH14 - StoL14).
! SMOOTHED STOCHASTIC OSCILATOR USING
! HARRY SCHIRDING SMOOTHING TECHNIQUE
! Quick Stochastic or %D or Slow %K
StoQ is 100 * sum(C - StoL14,3)/sum(StoH14 - StoL14,3).
! Slow Stochastic or Slow %D
StoS is simpleavg(StoQ,3).


--Richard Denning
richard.denning@earthlink.net
AIQ Systems
www.aiqsystems.com

GO BACK


WEALTH-LAB: STOCHASTICS AND PRICE RANGE DYNAMICS

For Andrew Tomlinson's article, "Home, Home On The Range," we prepared a WealthScript code template that can be used for further investigation of the ideas presented. The ChartScript includes a basic stochastic trading system with a small modification in the logic to exit if the price band oscillator has an excessive movement downward, which acts effectively as a stop-loss. For the symbol MCK, the strategy saved the system money in four out of the five cases in which it triggered since 1995 (Figure 2).

Figure 2: WEALTH-LAB, Stochastics And Price Range Dynamics. The price band oscillator can help trigger an action if the stochastic is already clipping along in oversold territory.
WealthScript code:
HideVolume;
const PER = 14;
const SMOOTH = 3;
var Bar, p, hH, hL, hHo, hLo, hPosition, hPBOsc, hRaw, hPosition2, hRawStoK, hSlowK, hSlowD: integer;
var StoPane2: integer = CreatePane( 100, false, true );
var PBPane: integer = CreatePane( 100, false, true );
var StoPane: integer = CreatePane( 100, false, true );
var sPer: string = IntToStr( PER );
var sSmth: string = IntToStr( SMOOTH ) + ')';
{ Price Bands; plot offsets }
hH:= HighestSeries( #High, PER );
hL := LowestSeries( #Low, PER );
hHo:= OffsetSeries( hH, -1 );
hLo := OffsetSeries( hL, -1 );
PlotSeries( hHo, 0, #Red, #Thin );
PlotSeries( hLo, 0, #Red, #Thin );
{ Price Band Oscillator }
hPosition := SubtractSeries( #Close, hLo );
hPBOsc := MultiplySeriesValue( DivideSeries ( hPosition, SubtractSeries( hHo, hLo ) ), 100 );
PlotSeriesLabel( hPBOsc, PBPane, #Maroon, #Thick, 'PBOsc' );
{ Native %K indicator }
hRawStoK := StochKSeries( PER );
PlotSeriesLabel( hRawStoK, StoPane, 950, #Thick, 'FastK(' + sPer + ')' );
{ Calculated %K = Stochastic K = 100 * ( C - LLn ) / ( HHn - LLn ) }
hPosition2 := SubtractSeries( #Close, hL );
hRaw := MultiplySeriesValue( DivideSeries ( hPosition2, SubtractSeries( hH, hL ) ), 100 );
PlotSeriesLabel( hRaw, StoPane, #Black, #Dotted, 'RawK (calculated)' );
hSlowK := StochDSeries( PER, 3 );
hSlowD := SMASeries( hSlowK, 3 );
PlotSeriesLabel( hSlowK, StoPane2, #Green, #Thick, 'SlowK(' + sPer + ',' + sSmth );
PlotSeriesLabel( hSlowD, StoPane2, #Blue, #Dotted, 'SlowD(' + sSmth );
{ Stochastic trading system }
for Bar := PER to BarCount - 1 do
begin
  if LastPositionActive then
  begin
    p := LastPosition;
    if ( ( @hSlowK[Bar - 1] > 80 ) and CrossUnder( Bar, hSlowK, hSlowD ) ) then
      SellAtMarket( Bar + 1, p, '' )
    else if  CrossUnderValue( Bar, hPBOsc, -40 ) then
    begin
      SellAtMarket( Bar + 1, p, 'PBOsc' );
      SetBackgroundColor( Bar, #RedBkg );
    end;
  end
  else      { Entry Rules }
  begin
    if ( @hSlowK[Bar - 1] < 20 )
    and CrossOver( Bar, hSlowK, hSlowD ) then
      BuyAtMarket( Bar + 1, '' );
  end;
end;


--Robert Sucher
www.wealth-lab.com

GO BACK


NEUROSHELL TRADER: STOCHASTICS AND PRICE RANGE DYNAMICS

The stochastic and price range indicators described by Andrew Tomlinson in his article in this issue can be easily implemented in NeuroShell Trader by combining a few of NeuroShell Trader's 800-plus indicators. To implement the indicators, select "New Indicator ..." from the Insert menu and use the Indicator Wizard to create the following indicators:

Figure 3: NEUROSHELL TRADER, Stochastics And Price Range Dynamics. Here is a price and oscillators chart in NeuroShell Trader.
Price Bands:
 PriceHigh ( Lag(High,1), 14)
 PriceLow( Lag(Low,1), 14)
Price Band Oscillator:
 Stochastic%K( Lag(High,1), Lag(Low,1), Close, 14 )
Raw Stochastic Channel:
 PriceHigh( High, 14 )
 PriceLow( Low, 14 )
Raw Stochastic Oscillator:
 Stochastic%K( High, Low, Close, 14 )
Harry Schirding's Slow %D Stochastic:
MovAvg( Multiply ( 100, Divide ( Sum( PriceRange(High, Low, 14), 3),
 Sum( Subtract( Close, PriceLow(Low,14), 3) ) ), 3 )


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

GO BACK


AMIBROKER: STOCHASTICS AND PRICE RANGE DYNAMICS

In "Stochastics And Price Range Dynamics: Home, Home On The Range," Andrew Tomlinson discusses modifications of a classic stochastic oscillator that work better when price breakouts occur. Coding all indicator flavors presented in the article is easy and straightforward in AmiBroker Formula Language (AFL). Ready-to-use code is presented in Listing 1. We decided to use a single formula for all indicator types presented in the article; the user can switch between them using "combo-box" in the Parameters dialog.

FIGURE 4: AMIBROKER, Stochastics And Price Range Dynamics. Price bands, the price band oscillator, and the stochastic channel raw stochastic are shown on a sample AmiBroker chart.
LISTING 1
Type = ParamList("Chart Type",
    "Price Bands|Price Band Oscillator|Stochastic Channel|Raw Stochastic");
Periods = Param("Periods", 14, 2, 100, 1 );
Smoothed = ParamToggle("Smoothed", "No|Yes", 1 );
IsStochType = ( Type == "Stochastic Channel" OR Type == "Raw Stochastic" );
// if stochastic - include today's bar
PH = IIf( IsStochType, H, Ref( H, -1 ) );
PL = IIf( IsStochType, L, Ref( L, -1 ) );
if( Type == "Price Bands" OR Type == "Stochastic Channel" )
{
 // plot price chart
 Plot( C, "Price", colorBlack, styleCandle );
 Plot( HHV( PH, Periods ), Type + " (Top)", colorBlue );
 Plot( LLV( PL, Periods ), Type + " (Bot)", colorBlue );
}
else
{
 // plot oscillator
 Range = HHV( PH, Periods ) - LLV( PL, Periods );
 Position = C - LLV( PL, Periods );
 if( Smoothed )
 {
   Slow = 100 * Sum( Position, 3 ) / Sum( Range, 3 );
   Plot( Slow, "Smoothed " + Type, colorRed );
 }
 else
 {
   Raw = 100 * ( Position / Range );
   Plot( Raw, Type, colorRed );
 }
}
--Tomasz Janeczko, AmiBroker.com
www.amibroker.com
 

GO BACK


eSIGNAL: STOCHASTICS AND PRICE RANGE DYNAMICS

For this month's article by Andrew Tomlinson, "Home, Home On The Range,"  we've provided the following indicators: PriceBandOscillator.efs, PriceBands.efs, StochRawChannel.efs, StochRawOscillator.efs and SchirdingStoch.efs.
 

/***************************************

Provided By : eSignal (c) Copyright 2005

Description:  Price Band Oscillator
 
 

Version 1.0  6/09/2005
 
 

Notes:

August 2005 Issue - "Stochastics and Price Range Dynamics

                     What Flavor Smoothing would you like."

    by Andrew Tomlinson

 

This study uses EFS2 functionality available in eSignal

version 7.9 or later.
 
 

Formula Parameters:                 Defaults:

Number of Periods                   14

Line Thickness                      2

Line Color                          maroon

***************************************/
 
 

function preMain() {

    setStudyTitle("Price Band Oscillator ");

    setShowTitleParameters(false);

    setCursorLabelName("Price Band Osc", 0);

    setDefaultBarFgColor(Color.maroon, 0);

    setDefaultBarThickness(2, 0);

 

    var fp1 = new FunctionParameter("nLength", FunctionParameter.NUMBER);

        fp1.setName("Number of Periods");

        fp1.setLowerLimit(1);

        fp1.setDefault(14);

    var fp2 = new FunctionParameter("nThick", FunctionParameter.NUMBER);

        fp2.setName("Line Thickness");

        fp2.setLowerLimit(1);

        fp2.setDefault(2);

    var fp3 = new FunctionParameter("cColor", FunctionParameter.COLOR);

        fp3.setName("Line Color");

        fp3.setDefault(Color.maroon);

}
 
 

var bVersion = null;

var bInit = true;

var xHhv = null;

var xLlv = null;
 
 

function main(nLength, nThick, cColor) {

    if (bVersion == null) bVersion = verify();

    if (bVersion == false) return;

 

    if (bInit == true) {

        xHhv = upperDonchian(nLength, high());

        xLlv = lowerDonchian(nLength, low());

        setDefaultBarThickness(nThick, 0);

        setDefaultBarFgColor(cColor, 0);

        bInit = false;

    }

 

    if (getCurrentBarCount() < nLength+1) return;

 

    var Range = xHhv.getValue(-1) - xLlv.getValue(-1);

    var Position = close(0) - xLlv.getValue(-1);

    var PBOsc = 100 * (Position/Range);
 
 

    return PBOsc;

}
 
 
 
 

/***** Support Functions *****/
 

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;

}
 
 
 
 

/***************************************

Provided By : eSignal (c) Copyright 2005

Description:  Price Bands
 
 

Version 1.0  6/09/2005
 
 

Notes:

August 2005 Issue - "Stochastics and Price Range Dynamics

                     What Flavor Smoothing would you like."

    by Andrew Tomlinson

 

This study uses EFS2 functionality available in eSignal

version 7.9 or later.
 
 

Formula Parameters:                 Defaults:

Number of Periods                   14

Line Thickness                      2

Line Color                          maroon

***************************************/
 
 

function preMain() {

    setPriceStudy(true);

    setStudyTitle("Price Bands ");

    setShowTitleParameters(false);

    setCursorLabelName("Upper Price Band", 0);

    setCursorLabelName("Lower Price Band", 1);

    setDefaultBarFgColor(Color.maroon, 0);

    setDefaultBarFgColor(Color.maroon, 1);

    setDefaultBarThickness(2, 0);

    setDefaultBarThickness(2, 1);

 

    var fp1 = new FunctionParameter("nLength", FunctionParameter.NUMBER);

        fp1.setName("Number of Periods");

        fp1.setLowerLimit(1);

        fp1.setDefault(14);

    var fp2 = new FunctionParameter("nThick", FunctionParameter.NUMBER);

        fp2.setName("Line Thickness");

        fp2.setLowerLimit(1);

        fp2.setDefault(2);

    var fp3 = new FunctionParameter("cColor", FunctionParameter.COLOR);

        fp3.setName("Line Color");

        fp3.setDefault(Color.maroon);

}
 
 

var bVersion = null;

var bInit = true;

var xHhv = null;

var xLlv = null;
 
 

function main(nLength, nThick, cColor) {

    if (bVersion == null) bVersion = verify();

    if (bVersion == false) return;

 

    if (bInit == true) {

        xHhv = upperDonchian(nLength, high());

        xLlv = lowerDonchian(nLength, low());

        setDefaultBarThickness(nThick, 0);

        setDefaultBarThickness(nThick, 1);

        setDefaultBarFgColor(cColor, 0);

        setDefaultBarFgColor(cColor, 1);

        bInit = false;

    }

 

    return new Array(xHhv.getValue(-1), xLlv.getValue(-1));

}
 
 
 

/***** Support Functions *****/
 
 

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;

}
 
 
 
 
 

/***************************************

Provided By : eSignal (c) Copyright 2005

Description:  Stochastics Raw Channel
 
 

Version 1.0  6/09/2005
 
 

Notes:

August 2005 Issue - "Stochastics and Price Range Dynamics

                     What Flavor Smoothing would you like."

    by Andrew Tomlinson

 

This study uses EFS2 functionality available in eSignal

version 7.9 or later.
 
 

Formula Parameters:                 Defaults:

Number of Periods                   14

Line Thickness                      2

Line Color                          green

***************************************/
 
 

function preMain() {

    setPriceStudy(true);

    setStudyTitle("Stochastics Raw Channel ");

    setShowTitleParameters(false);

    setCursorLabelName("Upper Channel", 0);

    setCursorLabelName("Lower Channel", 1);

    setDefaultBarFgColor(Color.green, 0);

    setDefaultBarFgColor(Color.green, 1);

    setDefaultBarThickness(2, 0);

    setDefaultBarThickness(2, 1);

 

    var fp1 = new FunctionParameter("nLength", FunctionParameter.NUMBER);

        fp1.setName("Number of Periods");

        fp1.setLowerLimit(1);

        fp1.setDefault(14);

    var fp2 = new FunctionParameter("nThick", FunctionParameter.NUMBER);

        fp2.setName("Line Thickness");

        fp2.setLowerLimit(1);

        fp2.setDefault(2);

    var fp3 = new FunctionParameter("cColor", FunctionParameter.COLOR);

        fp3.setName("Line Color");

        fp3.setDefault(Color.green);

}
 
 

var bVersion = null;

var bInit = true;

var xHhv = null;

var xLlv = null;
 
 

function main(nLength, nThick, cColor) {

    if (bVersion == null) bVersion = verify();

    if (bVersion == false) return;

 

    if (bInit == true) {

        xHhv = upperDonchian(nLength, high());

        xLlv = lowerDonchian(nLength, low());

        setDefaultBarThickness(nThick, 0);

        setDefaultBarThickness(nThick, 1);

        setDefaultBarFgColor(cColor, 0);

        setDefaultBarFgColor(cColor, 1);

        bInit = false;

    }

 

    return new Array(getSeries(xHhv), getSeries(xLlv));

}
 
 
 

/***** Support Functions *****/
 
 

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;

}
 
 
 
 

/***************************************

Provided By : eSignal (c) Copyright 2005

Description:  Stochastic Raw Oscillator
 
 

Version 1.0  6/09/2005
 
 

Notes:

August 2005 Issue - "Stochastics and Price Range Dynamics

                     What Flavor Smoothing would you like."

    by Andrew Tomlinson

 

This study uses EFS2 functionality available in eSignal

version 7.9 or later.
 
 

Formula Parameters:                 Defaults:

Number of Periods                   14

Line Thickness                      2

Line Color                          maroon

***************************************/
 
 

function preMain() {

    setStudyTitle("Stochastic Raw Oscillator ");

    setShowTitleParameters(false);

    setCursorLabelName("Stoch Osc", 0);

    setDefaultBarFgColor(Color.green, 0);

    setDefaultBarThickness(2, 0);

 

    var fp1 = new FunctionParameter("nLength", FunctionParameter.NUMBER);

        fp1.setName("Number of Periods");

        fp1.setLowerLimit(1);

        fp1.setDefault(14);

    var fp2 = new FunctionParameter("nThick", FunctionParameter.NUMBER);

        fp2.setName("Line Thickness");

        fp2.setLowerLimit(1);

        fp2.setDefault(2);

    var fp3 = new FunctionParameter("cColor", FunctionParameter.COLOR);

        fp3.setName("Line Color");

        fp3.setDefault(Color.green);

}
 
 

var bVersion = null;

var bInit = true;

var xHhv = null;

var xLlv = null;
 
 

function main(nLength, nThick, cColor) {

    if (bVersion == null) bVersion = verify();

    if (bVersion == false) return;

 

    if (bInit == true) {

        xHhv = upperDonchian(nLength, high());

        xLlv = lowerDonchian(nLength, low());

        setDefaultBarThickness(nThick, 0);

        setDefaultBarFgColor(cColor, 0);

        bInit = false;

    }

 

    if (getCurrentBarCount() < nLength) return;

 

    var PBOsc = efsInternal("calcPBOsc", getSeries(xHhv), getSeries(xLlv));
 
 

    return PBOsc;

}
 
 
 
 

/***** Support Functions *****/
 
 

function calcPBOsc(h, l) {

    var Range = h.getValue(0) - l.getValue(0);

    var Position = close(0) - l.getValue(0);

    return (100 * (Position/Range));

}
 
 

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;

}
 
 
 
 

/***************************************

Provided By : eSignal (c) Copyright 2005

Description:  Harry Schirding Stochastic
 
 

Version 1.0  6/09/2005
 
 

Notes:

August 2005 Issue - "Stochastics and Price Range Dynamics

                     What Flavor Smoothing would you like."

    by Andrew Tomlinson

 

This study uses EFS2 functionality available in eSignal

version 7.9 or later.
 
 

Formula Parameters:                 Defaults:

Number of Periods                   14

%K Smoothing Periods                3

%D Smoothing Periods                3

Line Thickness                      2

%K Color                            red

%D Color                            blue

***************************************/
 
 

function preMain() {

    setStudyTitle("Harry Schirding Stochastic ");

    setShowTitleParameters(false);

    setCursorLabelName("Slow \%K", 0);

    setCursorLabelName("Slow \%D", 1);

    setDefaultBarFgColor(Color.red, 0);

    setDefaultBarFgColor(Color.blue, 1);

    setDefaultBarThickness(2, 0);

    setDefaultBarThickness(2, 1);

    setDefaultBarStyle(PS_DASH, 1);

 

    var fp1 = new FunctionParameter("nLength", FunctionParameter.NUMBER);

        fp1.setName("Number of Periods");

        fp1.setLowerLimit(1);

        fp1.setDefault(14);

    var fp2 = new FunctionParameter("nK", FunctionParameter.NUMBER);

        fp2.setName("\%K Smoothing Periods");

        fp2.setLowerLimit(1);

        fp2.setDefault(3);

    var fp3 = new FunctionParameter("nD", FunctionParameter.NUMBER);

        fp3.setName("\%D Smoothing Periods");

        fp3.setLowerLimit(1);

        fp3.setDefault(3);

    var fp4 = new FunctionParameter("nThickK", FunctionParameter.NUMBER);

        fp4.setName("\%K Thickness");

        fp4.setLowerLimit(1);

        fp4.setDefault(2);

    var fp5 = new FunctionParameter("nThickD", FunctionParameter.NUMBER);

        fp5.setName("\%D Thickness");

        fp5.setLowerLimit(1);

        fp5.setDefault(2);

    var fp6 = new FunctionParameter("cColorK", FunctionParameter.COLOR);

        fp6.setName("\%K Line Color");

        fp6.setDefault(Color.red);

    var fp7 = new FunctionParameter("cColorD", FunctionParameter.COLOR);

        fp7.setName("\%D Line Color");

        fp7.setDefault(Color.blue);

}
 
 

var bVersion = null;

var bInit = true;

var xHhv = null;

var xLlv = null;

var Range = null;

var Position = null;

var Quick = null;

var Slow = null;
 
 

function main(nLength, nK, nD, nThickK, nThickD, cColorK, cColorD) {

    if (bVersion == null) bVersion = verify();

    if (bVersion == false) return;

 

    if (bInit == true) {

        xHhv = upperDonchian(nLength, high());

        xLlv = lowerDonchian(nLength, low());

        setDefaultBarThickness(nThickK, 0);

        setDefaultBarFgColor(cColorK, 0);

        setDefaultBarThickness(nThickD, 1);

        setDefaultBarFgColor(cColorD, 1);

        bInit = false;

    }

 

    if (getCurrentBarCount() < (nLength + nK)) return;

 

    if (Range == null) Range = efsInternal("calcRange", getSeries(xHhv), getSeries(xLlv));

    if (Position == null) Position = efsInternal("calcPosition", getSeries(xLlv));

    if (Quick == null) Quick = efsInternal("calcQuick", nK, getSeries(Range), getSeries(Position));  // Slow %K

    if (Quick.getValue(-1*(nK + nD) +1) != null && Slow == null) {

        Slow = sma(nD, getSeries(Quick));  // Slow %D

    }

 

    if (Slow == null) {

        return new Array(Quick.getValue(0), null);

    } else {

        return new Array(Quick.getValue(0), Slow.getValue(0));

    }

}
 
 
 

/***** Support Functions *****/
 
 

function calcSlow(len, q) {

    var nSum = 0;

    for (var i = 0; i < len; i++) {

        nSum += q.getValue(-i);

    }

    return nSum/len;

}
 
 

function calcQuick(len, r, p) {

    var nSumP = 0;

    var nSumR = 0;

 

    for (var i = 0; i < len; i++) {

        if (p.getValue(-i) != null) nSumP += p.getValue(-i);

        if (r.getValue(-i) != null) nSumR += r.getValue(-i);

    }

 

    if (nSumR == 0) return null;

 

    return 100*(nSumP/nSumR);

}
 
 

function calcPosition(l) {

    return (close(0) - l.getValue(0));

}

 

function calcRange(h, l) {

    return (h.getValue(0) - l.getValue(0));

}
 
 
 
 

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;

}
 
 




Figure 5A: eSIGNAL, Stochastics And Price Range Dynamics. Here is a sample eSignal chart showing the Harry Schirding stochastic along with a stochastic raw channel.


Figure 5B: eSIGNAL, Stochastics And Price Range Dynamics. Here is a sample eSignal chart showing the Stochastic Raw Oscillator along with Stochastic Raw Channel.

 
Figure 5C: eSIGNAL, Stochastics And Price Range Dynamics. Here is a sample eSignal chart showing the Price Band Oscillator along with Price Bands.


The studies all have options for changing the period lengths and format for the indicator lines that may be modified through the Edit Studies options.

To discuss this study or download a complete copy of the formulas, please visit the EFS Library Discussion Board forum under the Bulletin Boards link at www.esignalcentral.com.

--Jason Keck
eSignal, a division of Interactive Data Corp.
800 815-8256, www.esignalcentral.com
 

GO BACK


INVESTOR/RT: STOCHASTICS AND PRICE RANGE DYNAMICS

In "Stochastics And Price Range Dynamics," the modified stochastic calculation that Andrew Tomlinson refers to as the price band oscillator is actually a built-in option of the Investor/RT stochastic indicator. This option is implemented as a checkbox labeled "Unbounded" and refers to the fact that the values can exceed the zero-to-100 boundaries of the standard stochastic. The standard RawK is calculated as:

100 * (CL - MIN(LO, 14)) / (MAX(HI 14) - MIN(LO, 14)))
Checking the "Unbounded" checkbox essentially shifts the MaxHI and MinLO values left one bar, forcing it to exclude the current bar from consideration, and resulting in the following calculation:
100 * (CL - MIN(LO.1, 14)) / (MAX(HI.1 14) - MIN(LO.1, 14)))
This allows the closing price to step outside that range, and thus produce values below zero and above 100, thereby alerting the user to the existence and strength of upward or downward breakouts. The price band oscillator can be seen charted in pane 2 of Figure 6. The unbounded stochastic in pane 2 of Figure 6 was charted using the preferences seen in preferences dialog image [not shown here but shown at www.Traders.com--Editor].


 

Figure 6: Investor/RT, Stochastics, And Price Range Dynamics. This Investor/RT 15-minute candlestick chart of IBM is overlaid with a 14-period Donchian channel. The second pane shows an unbounded 14-period stochastic (in red) along with a three-period FastD (in blue). The third pane also shows a standard bounded stochastic with the same settings.


More information on the Investor/RT stochastic indicator can be found at: https://www.linnsoft.com/tour/techind/stoc.htm.

 
--Chad Payne, Linn Software
www.linnsoft.com, info@linnsoft.com
GO BACK

TRADING SOLUTIONS: STOCHASTICS AND PRICE RANGE DYNAMICS

In his article "Home, Home On The Range," Andrew Tomlinson describes an adjusted stochastic oscillator that can be used to detect breakouts.

This code can be entered into TradingSolutions as follows.
 

Name: Price Band Oscillator (PBOsc)
Inputs: Close, High, Low, Period
Mult (100, Div (Sub (Close, Lowest (Lag (Low,1),Period)), Sub (Highest
 (Lag (High,1), Period), Lowest (Lag (Low,1), Period))))


This function 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
https://www.tradingsolutions.com


GO BACK


TECHNIFILTER PLUS: STOCHASTICS AND PRICE RANGE DYNAMICS

Here are the Technifilter formulas based on Andrew Tomlinson's article in this issue.
 

NAME: CPStochasticBand
SWITCHES: multiline
FORMULA:
[1]: HM14 {c}  {rgb#16711680}  {topBand}
[2]: LN14 {c}  {rgb#16711680}  {BottomBand}
NAME: CP PriceBandOscillator
SWITCHES: multiline
FORMULA:
[1]: Hy1M14-Ly1N14     {range}
[2]: C-Ly1N14          {position}
[3]: 100*([2]/[1]){c}{nc}     {PBOsc}   {rgb#255}
NAME: CP Stochastic
SWITCHES: multiline
FORMULA:
[1]: HM14-LN14                        {range}
[2]: C-Ly1N14                        {position}
[3]: 100* ([2]F3/[1]F3){c}{nc}{rgb#255}    {Quick}
[4]: [3]A3 {c} {rgb#16711680}
NAME: CP RawStochastic
SWITCHES: multiline
FORMULA:
[1]: HM14-LN14     {range}
[2]: C-Ly1N14      {position}
[3]: 100*([2]/[1]) {Raw} {c}{nc}   {rgb#255}
NAME: CP Pricebands
SWITCHES: multiline
PARAMETERS: 14
FORMULA:
[1]: HY1M&1 {c}   {rgb#255}
[2]: LY1N&1 {c}   {rgb#255}


Visit the home of Technifilter Plus website at https://www.technifilter.com to download these formulas.

--Benzie Pikoos, Brightspark
+61 8 9375-1178 , sales@technifilter.com
www.technifilter.com


GO BACK


NEOTICKER: STOCHASTICS AND PRICE RANGE DYNAMICS

In his article in this issue, Andrew Tomlinson introduces two indicators as an example of creating variations on the classic stochastic indicator.

The two indicators are very simple and can be implemented with just a few lines of formula. The first indicator is called "Price Band" (Listing 1) and the second one is called "Price Band Oscillator" (Listing 2).

When these two indicators are plotted side-by-side with the original stochastic raw channel and the stochastic raw (also know as FastK), you will notice that the stochastic raw channel is never supposed to be penetrated, while the Price Band does penetrate. The arrows shown in Figure 7 illustrate this point clearly.

Figure 7: NEOTICKER, Stochastics And Price Range Dynamics. Here, Tomlinson's price band and price band oscillator are plotted along with the original indicators, the stochastic raw channel and the stochastic raw (also know as FastK).


Due to the nature of the original stochastic indicators, the price band indicator always ranges from zero to 100, while the price band oscillator is not really range-bound.
 

Listing 1: Price Band Indicator
plot1 := hhv (1, h, param1);
plot2 := llv (1, l, param1);
Listing 2: Price Band Oscillator Indicator
$range := hhv (1, h, param1) - llv (1, l, param1);
$pos := c - llv (1, l, param1);
plot1 := 100 * ($pos / $range)


 These indicators and charts are available for download from the NeoTicker Yahoo! user group site.

-- Lawrence Chan, TickQuest Inc.
www.tickquest.com


GO BACK


TRADE NAVIGATOR: STOCHASTICS AND PRICE RANGE DYNAMICS

In Trade Navigator Gold and Platinum versions, you can create custom functions to display on the chart as indicators and save multiple indicators on a chart as a template for easy application to any chart.

Figure 7: TRADE NAVIGATOR, Stochastics And Price Range Dynamics. Here is the formula for the price band oscillator function in Trade Navigator.
To recreate Andrew Tomlinson's indicators and templates for stochastics and price range dynamics smoothing in Trade Navigator, follow these steps:

First, create the functions. The templates are dependent on these functions, so the functions should be created first.
 

Price band oscillator
100 * ((Close - Lowest Low (14).1) / (Highest High (14).1 - Lowest Low (14).1))
1. Go to the Edit menu and click on Functions. This will bring up the Trader's
   Toolbox already set to the Functions tab.
2. Click on the New button.
3. Type the formula 100 * ((Close - Lowest Low (14).1) / (Highest High (14).1 -
   Lowest Low (14).1)) into the Function window.
4. Click on the Verify button.
5. Click on the Save button, type in "Price Band Oscillator" as the name for the
   function and then click the OK button.
Stochastic raw
100 * ((Close - Lowest Low (14)) / (Highest High (14) - Lowest Low (14)))
1. Go to the Trader's Toolbox and the Functions tab.
2. Click on the New button.
3. Type the formula 100 * ((Close - Lowest Low (14)) / (Highest High (14) - Lowest
   Low (14))) into the Function window.
4. Click on the Verify button.
5. Click on the Save button, type in Stochastic Raw as the name for the function
   and then click the OK button.
Creating the templates
1. Get your Trade Navigator chart set up the way you want to see it.
2. Click on the Templates button in the toolbar above the chart.
3. Select <Manage Chart Templates>. This will bring up the Manage Chart Templates
   window.
4. Click the New button.
5. Type in the name that you wish to use for the template that you are creating and
   then click the OK button.


For your convenience, we have created a file that you can download, which will add the stochastics and price range dynamics smoothing functions and templates to Trade Navigator. Simply download the free file "SandC004" in Trade Navigator and follow the upgrade prompts.

--Michael Herman
Genesis Financial Technologies
https://www.GenesisFT.com


GO BACK


BULLCHARTS: STOCHASTICS AND PRICE RANGE DYNAMICS

In this issue, Andrew Tomlinson discusses the behavior of the stochastic oscillator when a breakout occurs. He presents a case that the inclusion of the current day in the range limits the stochastics ability to respond to breakouts.

Figure 8: BULLCHARTS, Stochastics And Price Range Dynamics. Here is a sample BullCharts chart of the price band oscillator on Merck.


BullCharts includes the standard price bands (called "High Low Channel" in BullCharts) and stochastic indicators in its suite of more than 300 built-in indicators. The price band oscillator, as presented by Tomlinson, can be added to BullCharts by following these steps:
 

1. Select "Indicator Builder," located in the Tools menu
2. Press the New button to create a new indicator
3. Enter the formula name "Price band oscillator"
4. Enter the BullScript shown below and press OK.
{The Price Band Oscillator indicator}
[citation="Stocks & Commodities, Aug 05 - Stochastics And Price Range Dynamics by A. Tomlinson"]
[category=Oscillators]
[horzline=0,100]
n := Input("Time periods", 14, 1);
Range := Hist(HHV(H,n) - LLV(L,n),1);
Position := C - Hist(LLV(L,n),1);
PBOsc:=100*(Position/Range);
PBOsc;


Note the category=Oscillators attribute that is included in the script. This will allow you to easily locate this indicator when you are filtering your indicator list to only show oscillators. Horizontal lines are also declared at 100 and zero, which indicate when the price is at the top and bottom of the range, respectively.

--Peter Aylett, BullSystems
www.bullsystems.com


GO BACK


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


Return to August 2005 Contents