Автор:
Разместил:   Дата: 2005-12-27 16:29
Комментарии: (0)   Рейтинг:

# Candle Code by Viktor Likhovidov

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 o­n 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.

Typ : Function, Name : CandleCode

inputs: BBLength( numericsimple ),
{ recommended value of input: 55 }
BBNumDevs( numericsimple );
{ recommended value of input: .5 }
variables: BodyHi(0),
BodyLo(0),
Body(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;
ThBot_Body = BollingerBand(Body, BBLength, -BBNumDevs);
ThTop_Body = BollingerBand(Body, 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;

Typ : Indicator, Name : Candle Code

inputs: BBLength(55),

BBNumDevs(.5),
AvgLength(9);

variables:

CCode(0);
CCode = CandleCode(BBLength, BBNumDevs);

Plot1(CCode, "CCode");
Plot2(Average(CCode, AvgLength), "CCodeAvg"); Реклама:  Страница создана за 0.032 секунды