Boring Candle

#1
Dear Members,
Was looking for AFL for Boring Candles (who's body is less than 50% of the whole candle) color coding - such candles to be blue in color - and found one.
But when implemented, getting Warning 505. Division by Zero. Divisor array at [ 199 ] is equal to zero.
Due to this error, the Apply function is not working and code not getting implemented.

Request support from Seniors to correct the same please

Here is the code for the same please
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

normalCandle = (Open > Close) ;
baseCandle = (Open-Close)/(High-Low) < 0.5;
BarColor = IIf( baseCandle, colorBlue, IIf(normalCandle, colorGreen, colorRed) );
// set color
Plot( Close, "Price", BarColor, styleCandle );

Attaching the screenshot with the error shown.

Thanks in advance

warm regards-ARB Boring Candle AFL Error.jpg
 

Romeo1998

Well-Known Member
#2
good luck :)
Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

normalCandle = (Open > Close) ;
baseCandle = (Open-Close)/IIf(H-L<=0,H-L*0.000000001,H-L) < 0.5;
BarColor = IIf( baseCandle, colorBlue, IIf(normalCandle, colorGreen, colorRed) );
// set color
Plot( Close, "Price", BarColor, styleCandle );
 

Similar threads