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),
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;
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»);