April 2006
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: AVERAGE PEAK EXCURSION (APE)
  METASTOCK: AVERAGE PEAK EXCURSION (APE)
  WEALTH-LAB: AVERAGE PEAK EXCURSION (APE)
  AMIBROKER: AVERAGE PEAK EXCURSION (APE)
  eSIGNAL: AVERAGE PEAK EXCURSION (APE)
  NEUROSHELL TRADER: AVERAGE PEAK EXCURSION (APE)
  NEOTICKER: AVERAGE PEAK EXCURSION (APE)
  TRADING SOLUTIONS: AVERAGE PEAK EXCURSION (APE)
  AIQ SYSTEMS: AVERAGE PEAK EXCURSION (APE)
  TECHNIFILTER PLUS: AVERAGE PEAK EXCURSION (APE)
  TRADECISION: AVERAGE PEAK EXCURSION (APE)
  BIOCOMP DAKOTA: AVERAGE PEAK EXCURSION (APE)
  TRADE NAVIGATOR/TradeSense: AVERAGE PEAK EXCURSION (APE)
  VTTRADER: AVERAGE PEAK EXCURSION (APE)

or return to April 2006 Contents



TRADESTATION: AVERAGE PEAK EXCURSION (APE)

Chris Young's article in this issue, "The Average Peak Excursion," describes techniques for calculating average peak excursion and the tendency-to-trend parameter, alpha. The following indicator code implements Young's calculations and allows TradeStation users to apply the code to both charts and RadarScreen (Figure 1).

Figure 1: TRADESTATION AND RADARSCREEN, AVERAGE PEAK EXCURSION. RadarScreen displays the top 50 alpha calculations for the S&P 500. The chart displays GDT (daily bars). The indicator displays values of the AveragePeakExcursion indicator and alpha over the last four years.


To download the TradeStation code for this article, search for the file "AvgPeakEx.Eld" in the TradeStation Support Center at TradeStation.com.

Indicator:   _AvgPeakEx
inputs:
 Period( 20 ) ;
variables:
 APELength( 250 ),
 TestOpen( 0 ),
 OneDayPE( 0 ),
 PE( 0 ),
 APE1( 0 ),
 APEN( 0 ),
 Count( 0 ) ;
array:
 OneDayPEArray[ 250 ]( 0 ),
 PEArray[ 250 ]( 0 ) ;
TestOpen = Open[ Period - 1 ] ;
OneDayPE = MaxList( High - Open, Open - Low ) / Open ;
PE = MaxList( TestOpen - Lowest( Low, Period ),
 Highest( High, Period ) - TestOpen) / TestOpen ;
for Count = 250 downto 2
   begin
   OneDayPEArray[ Count ] =  OneDayPEArray[ Count - 1 ];
   PEArray[ Count ] = PEArray[ Count - 1 ] ;
   end ;
OneDayPEArray[ 1 ] = OneDayPE ;
PEArray[ 1 ] = PE ;
if CurrentBar > 250 then
 begin
 APEN = AverageArray( PEArray, APELength ) ;
 APE1 = AverageArray( OneDayPEArray, APELength ) ;
 Plot1( APE1, "APE-1" ) ;
 Plot2( APEN, "APE-N" ) ;
 end ;
if APE1 > 0 and Log( Period ) > 0 then
 Plot3( Log( APEN /APE1 ) / Log( Period ), "Alpha" );
 
--Mark Mills
TradeStation Securities, Inc.
www.TradeStationWorld.com
BACK 

METASTOCK: AVERAGE PEAK EXCURSION (APE)

Chris Young's article in this issue, "The Average Peak Excursion," includes three formulas for calculating the rate of return. These formulas are listed below as indicators.

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 formula.
5. Click OK to close the Indicator Editor.
Name:  Average Peak Excursion
Formula:
x:=Input("number of periods for APE",1,200,1);
Max( Abs(HHV(H, x) - Ref(O, -(x-1))), Abs(LLV(L, x) - Ref(O, -(x-1))) )
Name:  APE ratio
Formula:
x:=Input("number of periods for APE ratio",2,200,25);
ax:= Max( Abs(HHV(H, x) - Ref(O, -(x-1))), Abs(LLV(L, x) - Ref(O, -(x-1))) );
a1:= Max( Abs(H - O), Abs(L - O) );
ax / a1
Name:  APE Alpha
Formula:
x:=Input("number of periods for APE",2,200,25);
ax:= Max( Abs(HHV(H, x) - Ref(O, -(x-1))), Abs(LLV(L, x) - Ref(O, -(x-1))) );
a1:= Max( Abs(H - O), Abs(L - O) );
Log( ax / a1 ) / Log( x )


These formulas can also be used in explorations, but the first line will need to be changed first. The Input() function only works in indicators. For the explorations, replace this line:
 

 x:=Input("number of periods for APE",2,200,25);
with this line:
 x:= 25;


 The number typed in after x is the number of periods used for the long-term Ape calculation and can be any value desired.
 

--William Golson
MetaStock Support Representative
Equis International (A Reuters Company)
801 265-9998, www.metastock.com
BACK 

WEALTH-LAB: AVERAGE PEAK EXCURSION (APE)

We created a ChartScript based on the Ape indicator described in Chris Young's article, "The Average Peak Excursion." The Ape indicator is now part of the Wealth Lab Code Library.

As described in the article, we will use the relative (normalized) Ape to define the weight we apply to stocks in our basket. Our system uses a standard moving average (SMA) crossover approach, which goes long as soon as the 20-day SMA crosses the 40-day SMA, and which exits once the opposite crossover occurs.

The position sizing is in inverse proportion to the value of the Ape. As we want to calculate the position size based on the combined equity using a basket of stocks, we will calculate the final position size in a SimuScript, which is executed after the main script, although the Ape values are calculated in the main script. Thus, the position size is based on the combined basket equity and not on one stock only.

SimuScripts are an advanced feature of Wealth-Lab that let you experiment with your own, perhaps complex, position-sizing rules (Figure 2).

Figure 2: WEALTH-LAB, AVERAGE PEAK EXCURSION. The upper pane shows the 10-day APE indicator. As you can see, Microsoft (lower pane) made sideways movements at the beginning of April, when the system entered following the SMA crossover signal. Consequently, APE was low and the position size has been calculated to 197 shares. This trade was exited at the end of June. On the next entry signal in July, MSFT was very volatile and APE therefore much higher. This resulted in a position size of 100 shares, significantly lower than in the previous trade.
WealthScript code:
{$I 'APE'}
var Bar, sma1, sma2, APEPane, APE1, RelAPE: integer;
//Defining indicators
APE1 := APESeries( 10 );
RelAPE := DivideSeries(APE1, #Close );
SMA1 := SMASeries( #Close, 20 );
SMA2 := SMASeries( #Close, 40 );
//Plotting the indicators
APEPane := CreatePane( 75, true, true );
PlotSeriesLabel( APE1, APEPane, 009, #ThickHist, 'APE(10)' );
PlotSeriesLabel( SMA1, 0, #Red, #Thick, 'SMA(20)' );
PlotSeriesLabel( SMA2, 0, #Green, #Thick, 'SMA(40)' );
for Bar := 40 to BarCount - 1 do
begin
  if not LastPositionActive then
  begin
  If Crossover( Bar, SMA1, SMA2 ) then
    begin
    BuyAtMarket( Bar + 1, 'Entering long');
    //store the position size of this position relative to portfolio equity
    SetPositionData( LastPosition, ( 1 / @RelAPE[ Bar ] / 1000 ));
    end;
  end
  else
  begin
  If Crossunder( Bar, SMA1, SMA2 ) then
    begin
    SellAtMarket( Bar + 1, lastposition, 'Exiting long' );
    end;
  end;
end;
Simuscript Code:
// Sets the position size according to the ratio stored in the Chartscript
SetPositionSizeFixed( GetPositionData( #Current ) * Equity( Barcount - 1 ) );


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


AMIBROKER: AVERAGE PEAK EXCURSION (APE)

In "The Average Peak Excursion," Chris Young presents a method to select stocks that tend to yield higher results by evaluating their peak price excursion over a given period of time.

Ready-to-use code for AmiBroker is provided here. It should be used in Automatic Analysis--Exploration mode. After running an exploration, you can click on the "alpha" column to identify stocks that tend to trend more than other stocks (Figure 3). Note that average peak excursions are not directional, and high values of alpha may signify strong upward or downward trends.

FIGURE 3: AMIBROKER, AVERAGE PEAK EXCURSION. Here are sample exploration results sorted by alpha values. In the first spot is MCLD, which experienced very strong downtrends. In second position is AAPL, which was in a strong uptrend.
LISTING 1
N = 20;
NumBarsPerYear = 253; // approx. number of bars per year (EOD data)
PE0 = 100 * Max( H - O, O - L )/O;
// orig. formulation (as in the article
// looks into the future bars
PEN = 100 * Max( HHV( Ref( H, N ), N ) - O, O - LLV( Ref( L, N ), N ) )/O;
// you may prefer to use modified formula
// that does not look into future
// (just uncomment the line below)
// PEN = 100 * Max( HHV( H, N ) - O, O - LLV( L, N ) )/O;
APE0 = MA( PE0, NumBarsPerYear );
APEN = MA( PEN, NumBarsPerYear );
Alpha = ln( APEN/APE0 ) / ln ( N );
AddColumn( APE0, "A0" );
AddColumn( Alpha, "Alpha" );
AddColumn( APEN/APE0, "APEN/APE0" );
Filter = Status("lastbarinrange");


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

BACK 


eSIGNAL: AVERAGE PEAK EXCURSION (APE)

For this month's article by Chris Young, "The Average Peak Excursion," we've provided two formulas for use in eSignal: Ape.efs and Ape_alpha.efs. The Ape.efs study plots the n-period Ape, n-period peaks, and the one-period Ape series as a nonprice study. The Ape_alpha.efs study is also a nonprice study that plots the Ape alpha as described in the article. A sample chart is shown in Figure 4.

Figure 4: eSIGNAL, AVERAGE PEAK EXCURSION. Here is a demonstration of the average peak excursion indicator in eSignal.


Please note that the Ape_alpha.efs formula directly calls Ape.efs to perform its calculations. Thus, both formulas need to be saved to the same folder. Through the Edit Studies option in the Advanced Chart, there is one study parameter that can be customized for both studies. This parameter is the number of periods for the n-day average peak excursion.

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. These eSignal formula scripts (EFS) are also available for copying and pasting from the Stocks & Commodities website at Traders.com.
 

Ape.efs study:
/***************************************
Provided By : eSignal (c) Copyright 2006
Description:  The Average Peak Excursion - by Chris Young
Version 1.0  02/06/2006
Notes:
* Apr 2006 Issue of Stocks and Commodities Magazine
* Study requires version 7.9.1 or higher.
Formula Parameters:                 Defaults:
n-Day Avg Peak Excursion            20
***************************************/
function preMain() {
    setStudyTitle("Average Peak Excursion");
    setCursorLabelName("1-Day APE", 0);
    setCursorLabelName("Peak", 1);
    setCursorLabelName("APE", 2);
    setDefaultBarThickness(2, 0);
    setDefaultBarThickness(3, 1);
    setDefaultBarThickness(2, 2);
    setPlotType(PLOTTYPE_LINE, 0);
    setPlotType(PLOTTYPE_HISTOGRAM, 1);
    setDefaultBarFgColor(Color.navy, 0);
    setDefaultBarFgColor(Color.red, 1);
    setDefaultBarFgColor(Color.green, 2);
 
    var fp1 = new FunctionParameter("nDayAPE", FunctionParameter.NUMBER);
        fp1.setName("n-Day Avg Peak Excursion");
        fp1.setLowerLimit(1);
        fp1.setDefault(20);
}
var bVersion = null;
var bInit = false;
var xAPE = null;    // APE series
var xAPEMA = null;
var xA0 = null;     // 1-Day Peak series
function main(nDayAPE) {
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return;
    if (bInit == false) {
        xAPE = efsInternal("calcPeak", nDayAPE);
        xAPEMA = sma(nDayAPE,xAPE);
        xA0 = efsInternal("calcPeak", 1);
        xA0MA = sma(nDayAPE,xA0);
        setCursorLabelName(nDayAPE + "-Day Peak", 1);
        setCursorLabelName(nDayAPE + "-Day APE", 2);
        bInit = true;
    }
 
    return new Array(xA0MA.getValue(0), xAPE.getValue(0), xAPEMA.getValue(0));
}
var xHighest = null;
var xLowest = null;
function calcPeak(nDay) {
    if(xHighest==null) xHighest = highest(nDay, high());
    if(xLowest==null) xLowest = lowest(nDay, low());
    var nO = open(-nDay+1);
    if (nO == null) return null;
 
    var nH = Math.abs((xHighest.getValue(0) - nO) / nO)*100;
    var nL = Math.abs((xLowest.getValue(0)  - nO) / nO)*100;
 
    return Math.max(nH, nL);
}
function verify() {
    var b = false;
    if (getBuildNumber() < 730) {
        drawTextAbsolute(5, 35, "This study requires version 7.9.1 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;
}
Ape_alpha.efs study:
/***************************************
Provided By : eSignal (c) Copyright 2006
Description:  The Average Peak Excursion Alpha - by Chris Young
Version 1.0  02/06/2006
Notes:
* Apr 2006 Issue of Stocks and Commodities Magazine
* This study must reside in the same folder as APE.efs.
    Or add the path information to APE.efs within the efsExternal()
    functions if APE.efs is to be located in another folder.
* Study requires version 7.9.1 or higher.
Formula Parameters:                 Defaults:
n-Day Avg Peak Excursion            20
***************************************/
function preMain() {
    setStudyTitle("Average Peak Excursion Alpha");
    setCursorLabelName("APE Alpha", 0);
    setDefaultBarThickness(2, 0);
 
    var fp1 = new FunctionParameter("nDayAPE", FunctionParameter.NUMBER);
        fp1.setName("n-Day Avg Peak Excursion");
        fp1.setLowerLimit(1);
        fp1.setDefault(20);
}
var bVersion = null;
var bInit = false;
var xAPE_n = null;
function main(nDayAPE) {
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return;
    var nAlpha = null;
 
    if (bInit == false) {
        if (xAPE_n == null) xAPE_n = efsExternal("APE.efs", nDayAPE);
        bInit = true;
    }
    var nAPE1 = getSeries(xAPE_n, 0);
    var nAPEn = getSeries(xAPE_n, 2);
 
    if (nAPEn == null || nAPE1 == null) return;
    nAlpha = Math.log( (nAPEn/nAPE1) ) / Math.log(nDayAPE);
 
    return nAlpha;
}
/***** Support Functions *****/
function verify() {
    var b = false;
    if (getBuildNumber() < 730) {
        drawTextAbsolute(5, 35, "This study requires version 7.9.1 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
BACK 

NEUROSHELL TRADER: AVERAGE PEAK EXCURSION (APE)

The average peak excursion indicators described by Chris Young in his article "The Average Peak Excursion" can be easily implemented in NeuroShell Trader by combining a few of NeuroShell Trader's 800+ indicators. To implement the excursion indicators, select "New Indicator ..." from the Insert menu and use the Indicator Wizard to create the following indicators:
 

N-day peak excursion:
Max2(Subtract(PriceHigh(High,N), PriceOpen(Open,N)), Subtract (PriceOpen(Open,N), PriceLow(Low,N)))
Average peak excursion (Ape):
Avg ( PeakExcursion, X )
Ape alpha:
Divide ( Ln( Divide( AvgPeakExcursion(N), AvgPeakExcursion(1) ) ), Ln ( N ) )


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

Figure 5: NeuroShell, AVERAGE PEAK EXCURSION. Here is an example of using the portfolio view in NeuroShell Trader to compare average peak excursions and APE alphas across different stocks.
--Marge Sherald, Ward Systems Group, Inc.
301 662-7950, sales@wardsystems.com
www.neuroshell.com
BACK 

NEOTICKER: AVERAGE PEAK EXCURSION (APE)

To implement in NeoTicker the ideas presented in "The Average Peak Excursion" by Chris Young, first write an indicator name "average peak excursion" (Listing 1). This indicator has one integer parameter named period, which allows the user to vary the period when calculating the Ape.

Next, to get an alpha value, we use the formula indicator in NeoTicker and enter the code shown in Listing 2. Then, both Ape and Ape alpha can be plotted on the chart (Figure 6).

Figure 6: NEOTICKER, AVERAGE PEAK EXCURSION. Here, the Ape and Ape alpha are plotted on a chart.

Finally, write another indicator name "average peak excursion print" (Listing 3). This indicator automates the process of generating the Ape with different periods using a period parameter. The average peak excursion print indicator will print the Ape number in a report window from 1 to period.

A downloadable version of the indicators and chart group will be available at the NeoTicker Yahoo! User Group.
 

LISTING 1
$Nperiod  := param1;
$hdiff := if($Nperiod=1, absvalue(open-high),
              absvalue(open($Nperiod-1)-hhv(high, $Nperiod)));
$ldiff := if($Nperiod=1, absvalue(open-low),
              absvalue(open($Nperiod-1)-llv(low,  $Nperiod)));
Azero := if($hdiff>$ldiff, $hdiff, $ldiff);
plot1 := if($Nperiod=1, Azero, average(Azero, $Nperiod));
LISTING 2
ln(tasc_APE(data1,20)/tasc_APE(data1,1))/ln(20)
LISTING 3
function tasc_printAPE : double;
var i, ape_num : integer;
    this_apename : string;
    this_ape : variant;
begin
   if not data1.valid [0] then
   begin
      itself.success := false;
      exit;
   end;
   if not data1.islastbar then
   begin
      itself.success := false;
      exit;
   end;
   ape_num := param1.int;
   for i := 1 to ape_num do
   begin
      this_apename := 'myape' + ntlib.integer2str(i);
      this_ape := itself.makeindicator( this_apename, 'tasc_ape',
                         ['1'], [ntlib.integer2str(i)]);
      report.addline ( '', 'APE period ' + ntlib.integer2str(i) +
                           ' APE value ' +
                           ntlib.double2str(this_ape.value[0]));
   end;
   result := Data1.Value [0];
end;
--Kenneth Yuen, TickQuest Inc.
www.tickquest.com

BACK 


TRADING SOLUTIONS: AVERAGE PEAK EXCURSION (APE)

In "The Average Peak Excursion" in this issue, Chris Young introduces the average peak excursion indicator (Ape), as well as the calculation of its alpha.

These functions can be entered into TradingSolutions as follows:
 

Function Name: Peak Excursion
Short Name: PE
Inputs: Open, High, Low, Period
Max (Sub (LagVL (Open, Sub (Period, 1), Period), Lowest (Low, Period)),
     Sub (Highest (High, Period), LagVL (Open, Sub (Period, 1), Period)))
Function Name: Average Peak Excursion
Short Name: APE
Inputs: Open, High, Low, Peak Period, Average Period
MA (PE (Open, High, Low, Peak Period), Average Period)
Function Name: Average Peak Excursion Alpha
Short Name: APEAlpha
Inputs: Open, High, Low, Sample Peak Period, Average Period
Div (Ln (Div (APE (Open, High, Low, Sample Peak Period, Average Period),
     APE (Open, High, Low, 1, Average Period))), Ln (Sample Peak Period))


These functions are also available as a function file that can be downloaded from the TradingSolutions website (www.tradingsolutions.com) in the Solution Library section. As with many indicators, these functions could make good inputs to neural network predictions. In this case, they would typically be combined with the RSI.
 

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

AIQ SYSTEMS: AVERAGE PEAK EXCURSION (APE)

The AIQ code for Chris Young's indicators as described in his article "The Average Peak Excursion" is shown below. These indicators, once coded, can be applied to an Aiq chart as custom indicators.

In Figure 7, we show the 20-day average peak excursion (APE) and the 20-day Ape alpha for the stocks AZN and QQQQ.

Figure 7: AIQ, AVERAGE PEAK EXCURSION. Here is a chart of AZN and QQQQ with the average peak excursion (APE) and APE alpha for n=20, and averaging set to 250 days.
The code for the Ape indicators can be downloaded from Aiq's website at https://www.aiqsystems.com/S&C1.htm.
 
!! AVERAGE PEAK EXCURSION (APE), TASC  April 2006
!! Author: Chris Young
!! Coded by: Rich Denning 02/06/06
! HIGHEST HIGH OVER N PERIODS
HH2 is hival([high],2).
HH5 is hival([high],5).
HH10 is hival([high],10).
HH20 is hival([high],20).
HH25 is hival([high],25).
! LOWEST LOW OVER N PERIODS
LL2 is loval([low],2).
LL5 is loval([low],5).
LL10 is loval([low],10).
LL20 is loval([low],20).
LL25 is loval([low],25).
! OVER N PERIODS AGO
O1 is val([open],1).
O5 is val([open],5).
O10 is val([open],10).
O20 is val([open],20).
O25 is val([open],25).
! PEAK EXCURSION OVER N PERIODS
PE1 is max(abs([high] - [open]),abs([open] - [low])).
PE2 is max(abs(HH2 - O1),abs(O1 - LL2)).
PE5 is max(abs(HH5 - O5),abs(O5 - LL5)).
PE10 is max(abs(HH10 - O10),abs(O10 - LL10)).
PE20 is max(abs(HH20 - O20),abs(O20 - LL20)).
PE25 is max(abs(HH25 - O25),abs(O25 - LL25)).
!AVERAGE PEAK EXCURSION OVER N PERIODS
avgP is 250.
APE1 is simpleavg(PE1,avgP).
APE2 is simpleavg(PE2,avgP).
APE5 is simpleavg(PE5,avgP).
APE10 is simpleavg(PE10,avgP).
APE20 is simpleavg(PE20,avgP).
APE25 is simpleavg(PE25,avgP).
!RATIOS BETWEEN TIME PERIODS
APEr5_1 is APE5 / APE1.
APEr20_1 is APE20 / APE1.
APEr25_5 is APE25 / APE5.
rDIFF is APEr5_1 - APEr25_5.
! APE ALPHA FOR N PERIODS
APEalp10 is (ln(APE10 / APE1)) / ln(10).
APEalp20 is (ln(APE20 / APE1)) / ln(20).
APEalp25  is (ln(APE25 / APE1)) / ln(25).
! REPORT TO SHOW VALUES OF INDICATOR ON ANY CHOOSEN DATE
List if hasdatafor(265) >= 255.


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

BACK 


TECHNIFILTER PLUS: AVERAGE PEAK EXCURSION (APE)

Here are the TechniFilter Plus formulas based on Chris Young's article in this issue, "The Average Peak Excursion."
 

NAME: PE
PARAMETERS:
FORMULA:
(h-o)%(l-o)u0
NAME: PE_2
PARAMETERS: 2
FORMULA:
(hm&1-oy1)%(ln&1-oy1)u0
NAME: APE_1
PARAMETERS: 20
FORMULA: ((h-o)%(l-o)u0)A&1
NAME: APE_2
PARAMETERS: 20
FORMULA:
((hm2-oy1)%(ln2-oy1)u0)A&1
Visit the TechniFilter Plus website to download this strategy test. A sample chart is shown in Figure 8.

Figure 8: TECHNIFILTER, AVERAGE PEAK EXCURSION. Here is an example of the APE plotted in TechniFilter.

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

TRADECISION: AVERAGE PEAK EXCURSION (APE)

In "The Average Peak Excursion," Chris Young describes the Ape as a tool to select stocks that tend to yield higher returns and stocks with better relative reward versus risk performance. What's more, the Ape allows determining the best trading time frame to maximize return.

Tradecision NeatScan enables creating a scan based on the average peak excursion method:
 

var
   ape1:=sum(abs(open-high),10);
   ape20:=sum( abs(Highest(C,20)-open\20\),10 );
   limit:=0.01;
end_var
return LogN(ape20/ape1)/LogN(20)> limit;


 In this example, the scan has the growing tendency > 0.01, but you can easily modify the coefficient (limit) for tightening or weakening the condition.
 

--Alex Grechanowski
Alyuda Research, Inc.
347 416-6083
www.alyuda.com, www.tradecision.com
BACK 

BIOCOMP DAKOTA: AVERAGE PEAK EXCURSION (APE)

The Ape (average peak excursion) indicator described by Chris Young in his article can be easily implemented in BioComp Dakota by calling the built-in Ape function. This can be done in either the "ScriptBot CreateSignal" function or a "ScriptStop Evaluate" function.
 

APE = Dakota.APE(NbrBarsBackInHistory, NbrBarsInAPE, Open, High, Low)


The variable NbrBarsBackInHistory enables you to adaptively track Ape as the security's behavior changes over time. This is important because securities change due to a variety of reasons, including market dynamics, mergers and acquisitions, and if it is a fund, with changes in the mix of the underlying securities.

The NbrBarsInApe is the nth day parameter of the Ape, as Young describes it. The open, high, and low are arrays of price history.

Included is the ApeAlpha, indicating the "trendiness" of the security over the specified horizon, called the same way:
 

APEAlpha = Dakota.APEAlpha(NbrBarsBackInHistory, NbrBarsInAPE, Open, High, Low)


These functions can be used in BioComp Dakota either in modifying trading bot signals or for supporting your decisions in executing stops.
 

--Carl Cook
BioComp Systems, Inc.
www.biocompsystems.com/products/Dakota
952 746-5761
BACK 

TRADE NAVIGATOR/TradeSense: AVERAGE PEAK EXCURSION (APE)

In Trade Navigator Gold and Platinum versions of Trade Navigator, you can create custom functions to display on the chart as indicators. In this way, you can add your own indicators to the indicators already provided in Trade Navigator, or you can add indicators from traders who have provided formulas for their indicators in books or magazines.

The TradeSense formula to create the average peak excursion indicators requires you to create two functions. We will call the indicators "one day peak excursion average" and "two day peak excursion average." The number of bars to use can be edited for each of these indicators by simply changing the "nbars" on the Chart Settings window.

To add the Average Peak Excursion Indicators to the list of indicators in Trade Navigator, follow these steps:
One Day Peak Excursion Average
(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 MovingAvg (((Max (Abs (High - Open.nbars) , Abs (Low - Open.nbars))) / Open.nbars) * 100 , nbars) into the Function window, as shown here:
By setting nbars as an input you can change the default number later to customize the function.
(4) Click on the Verify button, a message will pop up saying that nbars is not recognized as an existing function or input. Click the Add button then double click on the number in the Default Value field and change it to 10.
(5) Click on the Save button, type in One Day Peak Excursion Average as the name for the function and then click the Ok button.

Two Day Peak Excursion Average
(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 MovingAvg ((Max (Abs (Highest (High , 2) - Open.nbars) , Abs (Lowest (Low , 2) - Open.nbars)) / Open.nbars) * 100 , nbars) into the Function window. By setting nbars as an input you can change the default number later to customize the function.
(4) Click on the Verify button, a message will pop up saying that nbars is not recognized as an existing function or input. Click the Add button then double click on the number in the Default Value field and change it to 10.
(5) Click on the Save button, type in Two Day Peak Excursion Average as the name for the function and then click the Ok button.

You can then add your new peak excursion average indicators to a chart. by clicking on the chart, typing "A," selecting the Indicators tab, holding the Ctrl key on your keyboard down, and selecting the indicators from the list, then clicking the Add button. You may then move the indicator to the desired pane by clicking and dragging the indicator's label into that pane.

If you desire to change the number of bars to use for these indicators, simply click on the chart that you have added them to, type the letter "E" on your keyboard, select the indicator from the list, click the Value field next to nbars on the right side of the window, and type the new number of bars to use in the average.

For your convenience, we have created a special file that you can download through Trade Navigator, which will add the one day peak excursion average and two day peak excursion average indicators to Trade Navigator for you. Simply download the free special file "ScApr06" using your Trade Navigator and follow the upgrade prompts.
 

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

VTTRADER: AVERAGE PEAK EXCURSION (APE)

Chris Young's article in this issue, "The Average Peak Excursion," introduces an indicator by the same name. The Ape indicator is unique and consists of three different responses, including the average peak excursion, alpha, and relative reward versus risk performance.

We'll be offering the Ape indicator as a downloadable indicator file in our user forums. The VT Trader code and instructions for creating this indicator are as follows (each input variable has been parameterized to allow customization):
 

1. Navigator Window>Tools>Indicator Builder>[New] button

2. In the Indicator Bookmark, type the following text for each field:

Name: Average Peak Excursion (APE)
Short Name: vt_APE
Label Mask: Average Peak Excursion (%apeperiods%, %display:ls%)
Placement: New Frame
Inspect Alias: Average Peak Excursion (APE)


3. In the Input Bookmark, create the following variables:
 

[New] button... Name: Periods , Display Name: 1-Day PE Periods , Type: integer , Default: 1
[New] button... Name: LookbackPeriods , Display Name: n-Day PE Periods , Type: integer , Default: 20
[New] button... Name: _apeperiods, Display Name: APE Periods , Type: integer , Default: 4
[New] button... Name: Display , Display Name: Indicator Display , Type: Enumeration ,
                Default: click [...] button, [New] button, then create the following entries:
                Average_Peak_Excursion , Alpha, Risk_Reward_Performance; then, click [OK] button
Default: Average_Peak_Excursion (chosen from list created)


4. In the Output Bookmark, create the following variables:
 

[New] button...
Var Name: DisplayOneDayAPE
Name: 1-Day APE
Line Color: blue
Line Width: thin line
Line Type: solid line
[New] button...
Var Name: DisplayNthDayAPE
Name: Nth-Day APE
Line Color: red
Line Width: thin line
Line Type: solid line
[New] button...
Var Name: DisplayAlpha
Name: Alpha
Line Color: pink
Line Width: thin line
Line Type: solid line
[New] button...
Var Name: DisplayRR_Performance
Name: Risk-Reward Performance
Line Color: dark green
Line Width: thin line
Line Type: solid line


5. In the Formula Bookmark, copy and paste the following formula:
 

{Provided By: Visual Trading Systems, LLC (c) Copyright 2006}
{Description: Average Peak Excursion (APE) by Chris M. Young}
{Notes: April 2006 Issue - Going APE - The Average Peak Excursion}
{APE Version 1.0}
{Calculate the 1-Day Peak Excursion}
OneDayPE:= max(abs(High-Open),abs(Low-Open)) * 100 / Open;
{Calculate the n-Day Peak Excursion}
NthDayPE:= max(abs(HHV(High,LookbackPeriods)-ref(Open,-(LookbackPeriods-1))),
           abs(LLV(Low,LookbackPeriods)-ref(Open,-(LookbackPeriods-1)))) * 100 / Open;
{Calculate the 1-Day Average Peak Excursion
over n-Periods using the 1-Day Peak Excursion}
OneDayAPE:= mov(OneDayPE,apeperiods,S);
{Calculate the n-Day Average Peak Excursion
over n-Periods using the n-Day Peak Excursion}
NthDayAPE:= mov(NthDayPE,apeperiods,S);
{Calculate the APE Alpha}
Alpha:= (log(NthDayAPE/ref(OneDayAPE,-(LookbackPeriods-1)))/log(10)) / (log(apeperiods)/log(10));
{Calculate the Relative Reward vs. Risk Ratio}
RR_Performance:= NthDayAPE/ref(OneDayAPE,-(LookbackPeriods-1));
{Display Indicator on the Chart}
DisplayOneDayAPE:= if(Display=0, OneDayAPE, null);
DisplayNthDayAPE:= if(Display=0, NthDayAPE, null);
DisplayAlpha:= if(Display=1, Alpha, null);
DisplayRR_Performance:= if(Display=2, RR_Performance, null);


6. Click the "Save" icon to finish building the Ape indicator.
To attach the Ape indicator to a chart, click the right mouse-button within the chart window and then select "Add Indicators" -> "Average Peak Excursion (Ape)" from the indicator list. Users will have the ability to customize the parameters at this time. Once attached to the chart, clicking the right mouse-button over the displayed indicator label and selecting "Properties" allows customization of the parameters (Figure 9).

To learn more about VT Trader, visit www.cmsfx.com.

FIGURE 9: VT TRADER, AVERAGE PEAK EXCURSION (APE) INDICATOR. Here is the APE indicator attached to a GBP/USD 15-minute candlestick chart in VT Trader. The three frames display the APE, alpha, and risk vs. reward performance.
 

--Chris Skidmore
Visual Trading Systems, LLC (courtesy of CMS Forex)
866 51-CMSFX, trading@cmsfx.com

BACK 

Return to April 2006 Contents

Originally published in the April 2006 issue of Technical Analysis of STOCKS & COMMODITIES magazine.
All rights reserved. © Copyright 2006, Technical Analysis, Inc.