March 2001
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 issue.

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:
 
 
METASTOCK FOR WINDOWS
TRADESTATION EASYLANGUAGE
NEUROSHELL TRADER
TRADINGSOLUTIONS
WEALTH-LAB.COM
TECHNIFILTER PLUS
WAVEWI$E MARKET SPREADSHEET

or return to March 2001 Contents


METASTOCK FOR WINDOWS

In my article in this issue, "Coding Candlesticks (II)," I continue with a discussion of my method for quantitatively analyzing candlestick charts, a discussion I began in the November 1999 issue of STOCKS & COMMODITIES with my original article, "Coding Candlesticks." My approach is to assign values to each candlestick, so that candlestick charting will lend itself better to analysis with indicators, pattern recognition, and trading systems.

Here is the code for the CandleWeight indicator I discuss in this month's article.

If(CLOSE=OPEN,1,0)*
If(Fml("ushd")>=Fml("lshd"),64,-64)+
If(CLOSE=OPEN,0,1)*
If(CLOSE>OPEN,1,-1)* (If(Fml("body")<= Fml("ThBot_b"),80,0)+
If(Fml("body")> Fml("ThBot_b") AND Fml("body") <= Fml("ThTop_b"),96,0)+
If(Fml("body")> Fml("ThTop_b"),112,0))+
If(CLOSE>=OPEN,-4,4)* (If(Fml("lshd")= 0,3,0)+
If(Fml("lshd")< Fml("ThBot_l") AND Fml("lshd")> 0,2,0)+
If(Fml("lshd")> Fml("ThBot_l") AND Fml("lshd")<= Fml("ThTop_l") AND Fml("lshd")>0,1,0))+
If(CLOSE>=OPEN,1,-1)* (If(Fml("ushd")> 0 AND Fml("ushd")<= Fml("ThBot_u"),4,0)+
If( Fml("ushd")> Fml("ThBot_u") AND Fml("ushd")<= Fml("ThTop_u"),8,0)+
If(Fml("ushd")> Fml("ThTop_u"),12,0))
-- Viktor Likhovidov
GO BACK

TRADESTATION EASYLANGUAGE

Here's the EasyLanguage code for a single function that generates candlestick codes as described by Viktor Likhovidov in his article this month, "Coding Candlesticks (II)." Computations for the candlestick body and upper/lower shadows, the top and bottom thresholds for each element, and the candle code itself are all included in this single function. This contrasts with the multiple-function approach originally presented in Likhovidov's November 1999 STOCKS & COMMODITIES article on coding candlesticks.

This EasyLanguage code is written without any calls to the "Iff" function to keep it simple, and the Bollinger Band length and number of deviations are surfaced as inputs to the function so that the user can experiment with different values of these parameters.

A simple indicator that plots the candle code and its average is included. Any user-created analysis technique or strategy can similarly call the CandleCode function.

FUNCTION: CandleCode
inputs:
  BBLength( numericsimple ),  { recommended value of input: 55 }
  BBNumDevs( numericsimple ); { recommended value of input: .5 }

variables:
  BodyHi(0),
  BodyLo(0),
  Body(0),
  UpperShadow(0),
  LowerShadow(0),
  ThBot_Body(0),
  ThTop_Body(0),
  ThBot_US(0),
  ThTop_US(0),
  ThBot_LS(0),
  ThTop_LS(0),
  ColorCode(0),
  BodyCode(0),
  USCode(0),
  LSCode(0);

BodyHi = MaxList(Open, Close);
BodyLo = MinList(Open, Close);

Body = BodyHi - BodyLo;
UpperShadow = High - BodyHi;
LowerShadow = BodyLo - Low;

ThBot_Body = BollingerBand(Body, BBLength, -BBNumDevs);
ThTop_Body = BollingerBand(Body, BBLength, BBNumDevs);

ThBot_US = BollingerBand(UpperShadow, BBLength, -BBNumDevs);
ThTop_US = BollingerBand(UpperShadow, BBLength, BBNumDevs);

ThBot_LS = BollingerBand(LowerShadow, BBLength, -BBNumDevs);
ThTop_LS = BollingerBand(LowerShadow, BBLength, BBNumDevs);

if Close >= Open then
  begin
  ColorCode = 64;
  if Body = 0 then
    BodyCode = 0
  else if Body < ThBot_Body then
    BodyCode = 16
  else if Body < ThTop_Body then
    BodyCode = 32
  else
    BodyCode = 48;
  end
else
  begin
  ColorCode = 0;
  if Body = 0 then
    BodyCode = 48
  else if Body < ThBot_Body then
    BodyCode = 32
  else if Body < ThTop_Body then
    BodyCode = 16
  else
    BodyCode = 0;
  end;

if UpperShadow = 0 then
  USCode = 0
else if UpperShadow < ThBot_US then
  USCode = 4
else if UpperShadow < ThTop_US then
  USCode = 8
else
  USCode = 12;

if LowerShadow = 0 then
  LSCode = 3
else if LowerShadow < ThBot_LS then
  LSCode = 2
else if LowerShadow < ThTop_LS then
  LSCode = 1
else
  LSCode = 0;

CandleCode = ColorCode + BodyCode + USCode + LSCode;

INDICATOR: Candle Code
inputs:
  BBLength(55), 
  BBNumDevs(.5), 
  AvgLength(9);
variables:
  CCode(0);
CCode = CandleCode(BBLength, BBNumDevs);
Plot1(CCode, "CCode");
Plot2(Average(CCode, AvgLength), "CCodeAvg");
This EasyLanguage for both the function and indicator will be available for download at www.TradeStation.com. Look for the file "CandleCode.ELS."

-- Ramesh Dhingra, Product Manager, EasyLanguage
TradeStation Technologies, Inc. (Formerly Omega Research, Inc.)
A wholly owned subsidiary of TradeStation Group, Inc.
https://www.TradeStation.com

GO BACK

NEUROSHELL TRADER

The indicator that Viktor Likhovidov describes in his article this month, "Coding Candlesticks (II)," is quite complex and is best coded in a standard programming language rather than in NeuroShell's Indicator Wizard. NeuroShell Trader can directly call external code written in C, C++, Power Basic (also Visual Basic using one of our add-on packages), and Delphi. We went ahead and built the CandleWeight indicator in external code so that it runs easily in NeuroShell Trader:
#include "math.h"
 
const long BBLENGTH = 55;
const float BBMULT = 0.5;

float body (float *CLOSE, float *OPEN, long i)
{ // Abs(OPEN-CLOSE)
  return ((float) fabs(OPEN[i] - CLOSE[i]));
}

float lshd (float *CLOSE, float *OPEN, float *LOW, long i)
{ // If(CLOSE>=OPEN,OPEN-LOW,CLOSE-LOW)
  return (CLOSE[i]>=OPEN[i] ? OPEN[i]-LOW[i] : CLOSE[i]-LOW[i]);
}

float ushd (float *CLOSE, float *OPEN, float *HIGH, long i)
{ // If(CLOSE>=OPEN,HIGH-CLOSE,HIGH-OPEN)
  return (CLOSE[i]>=OPEN[i] ? HIGH[i]-CLOSE[i] : HIGH[i]-OPEN[i]);
}

float BBandBot (float avg, float sum, float sumsqd, long bblength, float bbmult)
{ if ((sumsqd - sum * sum / bblength) > 0.0)
    return (avg - bbmult * (float) sqrt ((sumsqd - sum * sum / bblength) / (bblength-1.0)));
  else 
    return (avg);
}

float BBandTop (float avg, float sum, float sumsqd, long bblength, float bbmult)
{ if ((sumsqd - sum * sum / bblength) > 0.0)
    return (avg + bbmult * (float) sqrt ((sumsqd - sum * sum / bblength) / (bblength-1.0)));
  else 
    return (avg);
}

float ThBot_b (float *CLOSE, float *OPEN, long i)
{ float avg=0;
  float sum=0;
  float sumsqd=0;
  float val;
  long j;
  float expmult;

  // BBandBot(Fml("body"),55,E,0.5)
  expmult = (float)2.0/(BBLENGTH+(float)1.0);
  for (j=i-BBLENGTH+1; j<=i; j++)
  { val = body(CLOSE, OPEN, j);
    avg = expmult * val  + ((float)1.0-expmult) * avg;
    sum += val;
    sumsqd += (val*val);
  }
  return (BBandBot (avg, sum, sumsqd, BBLENGTH, BBMULT));
}

float ThTop_b (float *CLOSE, float *OPEN, long i)
{ float avg=0;
  float sum=0;
  float sumsqd=0;
  float val;
  long j;
  float expmult;

  // BBandTop( Fml("body"),55,E,0.5)
  expmult = (float)2.0/(BBLENGTH+(float)1.0);
  for (j=i-BBLENGTH+1; j<=i; j++)
  { val = body(CLOSE, OPEN, j);
    avg = expmult * val  + ((float)1.0-expmult) * avg;
    sum += val;
    sumsqd += (val*val);
  }
  return (BBandTop (avg, sum, sumsqd, BBLENGTH, BBMULT));
}

float ThBot_l (float *CLOSE, float *OPEN, float *LOW, long i)
{ float avg=0;
  float sum=0;
  float sumsqd=0;
  float val;
  long j;
  float expmult;

  // BBandBot( Fml("lshd"),55,E,0.5)
  expmult = (float)2.0/(BBLENGTH+(float)1.0);
  for (j=i-BBLENGTH+1; j<=i; j++)
  { val = lshd(CLOSE, OPEN, LOW, j);
    avg = expmult * val  + ((float)1.0-expmult) * avg;
    sum += val;
    sumsqd += (val*val);
  }
  return (BBandBot (avg, sum, sumsqd, BBLENGTH, BBMULT));
}

float ThTop_l (float *CLOSE, float *OPEN, float *LOW, long i)
{ float avg=0;
  float sum=0;
  float sumsqd=0;
  float val;
  long j;
  float expmult;

  // BBandTop( Fml("lshd"),55,E,0.5)
  expmult = (float)2.0/(BBLENGTH+(float)1.0);
  for (j=i-BBLENGTH+1; j<=i; j++)
  { val = lshd(CLOSE, OPEN, LOW, j);
    avg = expmult * val  + ((float)1.0-expmult) * avg;
    sum += val;
    sumsqd += (val*val);
  }
  return (BBandTop (avg, sum, sumsqd, BBLENGTH, BBMULT));
}

float ThBot_u (float *CLOSE, float *OPEN, float *HIGH, long i)
{ float avg=0;
  float sum=0;
  float sumsqd=0;
  float val;
  long j;
  float expmult;

  // BBandBot( Fml("ushd"),55,E,0.5)
  expmult = (float)2.0/(BBLENGTH+(float)1.0);
  for (j=i-BBLENGTH+1; j<=i; j++)
  { val = ushd(CLOSE, OPEN, HIGH, j);
    avg = expmult * val  + ((float)1.0-expmult) * avg;
    sum += val;
    sumsqd += (val*val);
  }
  return (BBandBot (avg, sum, sumsqd, BBLENGTH, BBMULT));
}

float ThTop_u (float *CLOSE, float *OPEN, float *HIGH, long i)
{ float avg=0;
  float sum=0;
  float sumsqd=0;
  float val;
  long j;
  float expmult;

  // BBandTop( Fml("ushd"),55,E,0.5)
  expmult = (float)2.0/(BBLENGTH+(float)1.0);
  for (j=i-BBLENGTH+1; j<=i; j++)
  { val = ushd(CLOSE, OPEN, HIGH, j);
    avg = expmult * val  + ((float)1.0-expmult) * avg;
    sum += val;
    sumsqd += (val*val);
  }
  return (BBandTop (avg, sum, sumsqd, BBLENGTH, BBMULT));
}

_declspec (dllexport) void CandleWeight (float *OPEN,float *HIGH,float *LOW,float *CLOSE,long NumberOfPoints,float *Result)
{ long i;
  float Fml_ThBot_b;
  float Fml_ThTop_b;
  float Fml_ThBot_l;
  float Fml_ThTop_l;
  float Fml_ThBot_u;
  float Fml_ThTop_u;
  float Fml_body;
  float Fml_lshd;
  float Fml_ushd;

  // IF(CLOSE=OPEN,1,0)
  // * If(Fml("ushd")>=Fml("lshd"),64,-64)
  // + If(CLOSE=OPEN,0,1)
  // * If(CLOSE>OPEN,1,-1)
  // * (If(Fml("body")<= Fml("ThBot_b"),80,0)
  //    +If(Fml("body")> Fml("ThBot_b") AND Fml("body") <= Fml("ThTop_b"),96,0)
  //    +If(Fml("body")> Fml("ThTop_b"),112,0)
  //   )
  // + If(CLOSE>=OPEN,-4,4)
  // * (If(Fml("lshd") = 0,3,0)
  //    +If(Fml("lshd") < Fml("ThBot_l") AND Fml("lshd")>0,2,0)
  //    +If(Fml("lshd")> Fml("ThBot_l") AND Fml("lshd")<= Fml("ThTop_l") AND Fml("lshd")>0,1,0)
  //   )
  // +If(CLOSE>=OPEN,1,-1)
  // * (If(Fml("ushd")>0 AND Fml("ushd")<= Fml("ThBot_u"),4,0)
  //    +If(Fml("ushd")>Fml("ThBot_u") AND Fml("ushd")<= Fml("ThTop_u") ,8,0)
  //    +If(Fml("ushd")> Fml("ThTop_u"),12,0)
  //   )

  for (i=0; i<NumberOfPoints; i++)
  { if (i>=BBLENGTH)
      /* assign intermediate calculations to variables */
      /* so that only evaluated once (i.e. faster)     */
      Fml_ThBot_b = ThBot_b(CLOSE,OPEN,i);
      Fml_ThTop_b = ThTop_b(CLOSE,OPEN,i);
      Fml_ThBot_l = ThBot_l(CLOSE,OPEN,LOW,i);
      Fml_ThTop_l = ThTop_l(CLOSE,OPEN,LOW,i);
      Fml_ThBot_u = ThBot_u(CLOSE,OPEN,HIGH,i);
      Fml_ThTop_u = ThTop_u(CLOSE,OPEN,HIGH,i);
      Fml_body = body(CLOSE,OPEN,i);
      Fml_lshd = lshd(CLOSE,OPEN,LOW,i);
      Fml_ushd = ushd(CLOSE,OPEN,HIGH,i);

      /* calculate result for current bar */
      Result[i] = (float) (
        (CLOSE[i] == OPEN[i] ? 1:0)
        * (Fml_ushd >= Fml_lshd ? 64:-64)
        + (CLOSE[i] == OPEN[i] ? 0:1)
        * (CLOSE[i] > OPEN[i] ? 1:-1)
        * ((Fml_body <= Fml_ThBot_b ?80:0)
           +(Fml_body > Fml_ThBot_b && Fml_body <= Fml_ThTop_b ? 96:0)
           +(Fml_body > Fml_ThTop_b?112:0)
          )
        + (CLOSE[i] >= OPEN[i] ? -4:4)
        * ((Fml_lshd == 0?3:0)
           +(Fml_lshd < Fml_ThBot_l && Fml_lshd > 0 ? 2:0)
           +(Fml_lshd > Fml_ThBot_l && Fml_lshd <= Fml_ThTop_l && Fml_lshd > 0 ? 1:0)
          )
        + (CLOSE[i]>=OPEN[i] ? 1:-1)
        * ((Fml_ushd > 0 && Fml_ushd <= Fml_ThBot_u ? 4:0)
           +(Fml_ushd > Fml_ThBot_u && Fml_ushd <= Fml_ThTop_u ? 8:0)
           +(Fml_ushd > Fml_ThTop_u ? 12:0)
          )
      );
  }
};

_declspec (dllexport) void CandleCode (float *OPEN,float *HIGH,float *LOW,float*CLOSE,long NumberOfPoints,float *Result)
{ long i;
  float Fml_ThBot_b;
  float Fml_ThTop_b;
  float Fml_ThBot_l;
  float Fml_ThTop_l;
  float Fml_ThBot_u;
  float Fml_ThTop_u;
  float Fml_body;
  float Fml_lshd;
  float Fml_ushd;

  // If(CLOSE=OPEN,1,0)
  // * If(Fml("ushd")>=Fml("lshd"),64,48)
  // + If(Close=OPEN,0,1)
  // * (If(CLOSE>OPEN,1,0)
  //    * (If(Fml("body")<=Fml("ThBot_b"),80,0)
  //       + If(Fml("body")>Fml("ThBot_b") AND Fml("body") <= Fml("ThTop_b"),96,0)
  //       + If(Fml("body")>Fml("ThTop_b"),112,0)
  //       )
  //    + If(CLOSE<OPEN,1,0)
  //    * ( If(Fml("body")<=Fml("ThBot_b"),32,0)
  //        + If(Fml("body")> Fml("ThBot_b") AND Fml("body") <= Fml("ThTop_b"),16,0)
  //       )
  //   )

  // + If(Fml("lshd") = 0,3,0)
  // + If(Fml("lshd") < Fml("ThBot_I") AND Fml("lshd")>0,2,0)
  // + If(Fml("lshd")>Fml("ThBot_I") AND Fml("lshd")<=Fml("ThTop_I") AND Fml("lshd")>0,1,0)

  // + If(Fml("ushd")>0 AND Fml("ushd") <= Fml("ThBot_u"), 4,0)
  // + If(Fml("ushd")>Fml("TheBot_u") AND Fml("ushd")<=Fml("ThTop_u"),8,0)
  // + If(Fml("ushd")>Fml("ThTop_u"),12,0)

  for (i=0; i<NumberOfPoints; i++)
  { if (i>=BBLENGTH)
      /* assign intermediate calculations to variables so that only evaluated once (i.e. faster) */
      Fml_ThBot_b = ThBot_b(CLOSE,OPEN,i);
      Fml_ThTop_b = ThTop_b(CLOSE,OPEN,i);
      Fml_ThBot_l = ThBot_l(CLOSE,OPEN,LOW,i);
      Fml_ThTop_l = ThTop_l(CLOSE,OPEN,LOW,i);
      Fml_ThBot_u = ThBot_u(CLOSE,OPEN,HIGH,i);
      Fml_ThTop_u = ThTop_u(CLOSE,OPEN,HIGH,i);
      Fml_body = body(CLOSE,OPEN,i);
      Fml_lshd = lshd(CLOSE,OPEN,LOW,i);
      Fml_ushd = ushd(CLOSE,OPEN,HIGH,i);

      /* calculate result for current bar */
      Result[i] = (float) (
        (CLOSE[i] == OPEN[i]?1:0)
        * (Fml_ushd >= Fml_lshd?64:48)
        + (CLOSE[i] == OPEN[i]?0:1)
        * ((CLOSE[i] > OPEN[i]?1:0)
           * ((Fml_body <= Fml_ThBot_b?80:0)
              + (Fml_body > Fml_ThBot_b && Fml_body <= Fml_ThTop_b?96:0)
              + (Fml_body > Fml_ThTop_b?112:0)
              )
           + (CLOSE[i]<OPEN[i]?1:0)
           * ((Fml_body <= Fml_ThBot_b?32:0)
              + (Fml_body > Fml_ThBot_b && Fml_body <= Fml_ThTop_b?16:0)
              )
          )

        + (Fml_lshd == 0?3:0)
        + (Fml_lshd < Fml_ThBot_l && Fml_lshd > 0?2:0)
        + (Fml_lshd > Fml_ThBot_l && Fml_lshd <= Fml_ThTop_l && Fml_lshd > 0?1:0)

        + (Fml_ushd > 0 && Fml_ushd <= Fml_ThBot_u? 4:0)
        + (Fml_ushd > Fml_ThBot_u && Fml_ushd <= Fml_ThTop_u?8:0)
        + (Fml_ushd > Fml_ThTop_u?12:0)
     );
  }
};


In addition to coding the indicator CandleWeight in conjunction with this month's article, we have also coded the indicator CandleCode, which was described in Viktor Likhovidov's original "Coding Candlesticks" article in the November 1999 issue of STOCKS & COMMODITIES. Users of NeuroShell Trader can go to the Stocks & Commodities section of the NeuroShell Trader free technical support website to download the CandleWeight and CandleCode indicators. If you wish, you can also download the source code in C.

After downloading the custom indicators, you can insert them into NeuroShell Trader charts (Figures 1 and 2), predictions, and trading strategies using the Indicator Wizard and selecting the Custom Indicators category (Figure 3).

FIGURE 1: NEUROSHELL TRADER. Here is an example of Viktor Likhovidov's CandleWeight indicator displayed on a NeuroShell Trader daily chart.


FIGURE 2: NEUROSHELL TRADER. Here's the CandleWeight indicator in an intraday chart in NeuroShell Trader.


FIGURE 3: NEUROSHELL TRADER. Here's how to insert a Custom Indicator in NeuroShell Trader.


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

-- Marge Sherald

Ward Systems Group, Inc.
301 662-7950
https://www.neuroshell.com
GO BACK

TRADINSOLUTIONS

TradingSolutions allows you to enter custom formulas as function definitions that you may apply to any stock or data series in your portfolio. These functions can also be shared with other users by exporting them to files.

The functions described in Viktor Likhovidov's article in this issue, "Coding Candlesticks (II)," as well as those from Likhovidov's original November 1999 article, "Coding Candlesticks," can be reproduced in TradingSolutions fairly easily. The MetaStock Indicator Builder language used in Likhovidov's examples is very similar to that of TradingSolutions.

FIGURE 4: TRADING SOLUTIONS. Here's a composite chart of candlesticks and Likhovidov's index of candle strength for Intel.


The CandleCode indicator -- that is, the index of candle strength -- from the November 1999 article and the new, revised CandleWeight function from this month's article are made up of several steps and values. These functions are printed here but also have been made available as a function file that can be downloaded from our website (www.tradingsolutions.com) in the Solution Library section. This file can then be imported into TradingSolutions using "Import Functions..." from the File menu. Functions for CandleWeight, as well as the weighted version of CandleCode, are included.

To apply one of these imported functions to a stock or group of stocks, select "Add New Field..." from the context menu for the stock or group, select "Calculate a value...", then select the desired function from the "Traders Tips Functions" group.

Here are the underlying functions based on Likhovidov's November 1999 S&C article:

CandleCode Value: Body
CandleBody ( Open , Close )
Abs ( Sub ( Open , Close ) )
CandleCode Value: Lower Shadow
CandleLower ( Low , Open , Close )
        Sub ( Min ( Open , Close ) , Low )
CandleCode Value: Upper Shadow
CandleUpper ( High , Open , Close )
        Sub ( High , Max ( Open , Close ) )
The threshold functions from the original article can be simplified into two functions:
CandleCode Threshold: Bottom
CThreshBot ( Data )
        BBandBottom ( Data , 55 , 0.5 )
CandleCode Threshold: Top
CThreshTop ( Data )
        BBandTop ( Data , 55 , 0.5 )
Here are the CandleCode functions based on the November 1999 article:
CandleCode Step: Body
CCodeBody ( High , Low , Open , Close )
If (EQ (Close, Open), If (GE (CandleUpper (High, Open, Close), CandleLower (Low, 
Open, Close)), 64, 48), If (GT (Close, Open), If (LE (CandleBody (Open, Close),
  CThreshBot (CandleBody (Open, Close))), 80, If (LE (CandleBody (Open, Close),
  CThreshTop (CandleBody (Open, Close))), 96, 112)), If (LE (CandleBody (Open, Close),
  CThreshBot (CandleBody (Open, Close))), 32, If (LE (CandleBody (Open, Close),
  CThreshTop (CandleBody (Open, Close))), 16, 0))))
CandleCode Step: Lower Shadow
CCodeLower ( Low , Open , Close )
If (LE (CandleLower (Low, Open, Close), 0), 3, If (LE (CandleLower (Low, Open,
  Close), CThreshBot (CandleLower (Low, Open, Close))), 2, If (LE (CandleLower (Low,
  Open , Close), CThreshTop (CandleLower (Low, Open, Close))), 1, 0)))
CandleCode Step: Upper Shadow
CCodeUpper ( High , Open , Close )
If (LE (CandleUpper (High, Open, Close), 0), 0, If (LE (CandleUpper (High, Open,
  Close), CThreshBot (CandleUpper (High, Open, Close))), 4, If (LE (CandleUpper (High,
  Open, Close), CThreshTop (CandleUpper (High, Open, Close))), 8, 12)))

CandleCode
CCode ( High , Low , Open , Close )

Add3 (CCodeBody (High, Low, Open, Close), CCodeLower (Low, Open,
  Close), CCodeUpper (High, Open, Close))

Index of Candle Strength
ICS ( High , Low , Open , Close , Period )

MA ( MA ( MA ( CCode ( High , Low , Open , Close ) , Period ) , Period ) , Period )
Likhovidov's article in this issue, "Coding Candlesticks (II)," introduced a weighted version of CandleCode:
CandleCode (Weighted)
CCodeWt ( High , Low , Open , Close , Coeff Body , Coeff Upper , Coeff Lower )

Add3 (Mult (CCodeBody (High, Low, Open, Close), Coeff Body), Mult (CCodeLower (Low,
  Open, Close), Coeff Lower), Mult (CCodeUpper (High, Open, Close), Coeff Upper))
A revised version of CandleCode, called CandleWeight, was also introduced by Likhovidov this month. For the sake of clarity and comparison, we have divided it into functions, as we did with the original indicator:
CandleWeight Step: Body
CWeightBody ( High , Low , Open , Close )

If (EQ (Close, Open), If (GE (CandleUpper (High, Open, Close), CandleLower (Low,
  Open, Close)), 64, -64), Mult (If (GT (Close, Open), 1, -1), If (LE (CandleBody
  (Open , Close), CThreshBot (CandleBody (Open, Close))), 80, If (LE (CandleBody
  (Open, Close), CThreshTop (CandleBody (Open, Close))), 96, 112))))

CandleWeight Step: Lower Shadow
CWeightLower ( Low , Open , Close )

Mult  (If (LE (CandleLower (Low, Open, Close), 0), 3, If (LE (CandleLower (Low,
  Open, Close), CThreshBot (CandleLower (Low, Open, Close))), 2, If (LE
  (CandleLower (Low, Open, Close), CThreshTop (CandleLower (Low, Open, Close))),
  1, 0))), If (GE (Close, Open), -4, 4))

CandleWeight Step: Upper Shadow
CWeightUpper ( High , Open , Close )

Mult (If (LE (CandleUpper (High, Open, Close), 0), 0, If (LE (CandleUpper (High,
  Open, Close), CThreshBot (CandleUpper (High, Open, Close))), 4, If (LE
  (CandleUpper (High, Open, Close), CThreshTop (CandleUpper (High, Open, Close))),
  8, 12))), If (GE (Close, Open), 1, -1))

CandleWeight
CWeight ( High , Low , Open , Close )

Add3 (CWeightBody (High, Low, Open, Close), CWeightLower (Low, Open, Close),
  CWeightUpper (High, Open, Close))
--Gary Geniesse, TradingSolutions Project Lead
NeuroDimension, Inc., 800 634-3327, 352 377-5144
info@tradingsolutions.com, www.tradingsolutions.com
GO BACK

WEALTH-LAB.COM

In this issue, Viktor Likhovidov shares a method of coding candlesticks. You can explore CandleCode further at the Wealth-Lab.com website.

At www.wealth-lab.com, click the "Public ChartScripts" link that you'll find in the left-side navigation menu. You'll be presented with a list of Wealth-Lab ChartScripts. Click the ChartScript "CandleCode." You can now run the ChartScript against any stock that you wish by entering the stock symbol and clicking the Execute button.

FIGURE 5: WEALTH LAB. Here is a sample Wealth-Lab chart plotting the CandleCode.


This ChartScript uses Likhovidov's CandleCode formulation with one simple modification, and creates a trading system based on CandleCode.

The CandleCode method expresses a candlestick value as a binary number, coding the body, upper shadow, and lower shadow in different "bits" of the number. One principle of binary numbers is that we can use the highest bit as a sign. This is what we do in our adaptation. Rather than adding 64 to the CandleCode value, we simply give black candles negative values. This simplifies the code because we don't have to reverse the bits when calculating black candlesticks.

On a technical note, we use 20-day Bollinger Bands with 0.5 standard deviations to determine whether the body and shadow sizes are small, medium, or large. A value above the upper Bollinger Band indicates a large candlestick body and shadow, within the Bollinger Bands indicates a medium candlestick body and shadow, and below the lower BBand indicates small. The ChartScript displays the candle body size, with corresponding Bollinger Bands, to illustrate this technique.

We also present a trading system based on the sign-modified CandleCode. The system presented takes a 20-day simple moving average of CandleCode. When this value crosses below -25, an extreme reading occurs and a long position is established. When it crosses above 25, a short position is opened. The system exits at a 20% stop loss and 15% profit target.

--Dion Kurczek, Wealth-Lab.com
773 883-9047, dionkk@ix.netcom.com
https://www.wealth-lab.com
GO BACK

TECHNIFILTER PLUS

Here is the TechniFilter Plus formula that computes the CandleWeight indicator from Viktor Likhovidov's article, "Coding Candlesticks (II)." Lines 1 through 3 in this multiline formula compute the body, lower shadow, and upper shadow, respectively. Lines 4 through 9 compute the Bollinger Bands described in Likhovidov's November 1999 S&C article, "Coding Candlesticks."

Line 10 uses the first nine lines to compute the candle weight. One technique of interest is how line 10 handles calculations such as: IF ushd > lshd THEN 64 ELSE -64. This expression is computed using (([3]>[2])-([3]<=[2])) * 64. In it, if ushd > lshd, the expression on the left computes to the value 1. If ushd <= lshd, this expression computes to -1. Then, multiplying by 64 completes the calculation.

Formula for CandleWeight

NAME: CandleWeight
SWITCHES: multiline 
FORMULA: 
[1]: (C-O)U0    {body}
[2]: (C>=O) * (O-L) + (C<0) * (L-O)   {lshd}
[3]: (C>=O) * (H-C) + (C<0) * (H-O)   {ushd}
[4]: [1]X55 - .5*[1]|55   {ThBot_b}
[5]: [1]X55 + .5*[1]|55   {ThTop_b}
[6]: [2]X55 - .5*[2]|55   {ThBot_l}
[7]: [2]X55 + .5*[2]|55   {ThTop_l}
[8]: [3]X55 - .5*[3]|55   {ThBot_u}
[9]: [3]X55 + .5*[3]|55   {ThTop_u}
[10]: (C=O) * (([3]>[2])-([3]<=[2])) * 64
  + (C<>O) * ((C>O)-(C<=O)) * ([1]<=[4]) * 80
  + ([1]>[4]) * ([1]<=[5]) * 96
  + ([1]>[5]) * 112
  + ((C>=O)-(C<O))*4*(([2]=0)*3 +([2]<[6])*([2]>0)*2 +([2]>[6])*([2]<=[7])*([2]>0))
  + ((C>=O)-(C<O))*(([3]>0)*([3]<[8])*4 +([3]>[8])*([3]<=[9])*8 +([3]>[9])*12)
Visit RTR's website at https://www.rtrsoftware.com to download this formula as well as program updates.
--Clay Burch, RTR Software
919 510-0608, E-mail: rtrsoft@aol.com
 https://www.rtrsoftware.com
GO BACK

WAVE WI$E MARKET SPREADSHEET

The following Wave Wi$e formula shows how to color-code data in a bar chart in Wave Wi$e. Set the chart Properties to include column H for the bars' color value.
A: DATE @TC2000(C:\TC2000V3\Data,SP-500,Standard & Poors 500,DB)
B: HIGH
C: LOW
D: CLOSE
E: OPEN
F: VOL
G:
H: Colors   @IF(CLOSE >= OPEN, GREEN, @IF(CLOSE < OPEN, RED, WHITE))
I: 
 
==========End Formulas
Visit RTR's website at https://www.rtrsoftware.com to download this formula as well as program updates.
--Peter Di Girolamo
Jerome Technology, 908 369-7503
jtiware@aol.com
https://members.aol.com/jtiware
GO BACK


MetaStock (Equis International)
EasyLanguage (TradeStation Technologies, Inc.)
NeuroShell Trader (Ward Systems Group)
TradingSolutions (NeuroDimension)
Wealth-Lab.com (Wealth-Lab.com)
TechniFilter Plus (RTR Software)
Wave Wi$e Market Spreadsheet (Jerome Technology)

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


Return to March 2001 Contents