afl help for candle colour change on wilder20

dell

Well-Known Member
#1
can we have such setup like :

candle colour green when it is above wilder moving average (20)
candle colour red when it is below wilder moving average (20)
candle colour yellow when it is touching wilder moving average (20)

also can we add exploration/scan codes like ;

scan for symbols whose candles r green
scan for candles which r red
scan for candles which r yellow.............

also if we want to add more reliability than can we add more exploration code :
yellow candles which r hammer , buligh engulfing or shooting star ..........?

whole idea is that finding clear visibility for market trend .............
also i many times see that when we get breakout or breakdown and during pullback it often rejects from ma50 or wilder20 and forming a pattern like hammer , bulish engulfing or shooting star .........so i want to automate the process of scanning ...........

many afl experts r here ,
it mainly needs three conditions
1) candle colour change
2)exploration code for colour
3)exploration for candlestickpattern for yellow candles only

plz help ..........

p.s. : idea taken from a senior member here....
 
#2
can we have such setup like :

candle colour green when it is above wilder moving average (20)
candle colour red when it is below wilder moving average (20)
candle colour yellow when it is touching wilder moving average (20)

also can we add exploration/scan codes like ;

scan for symbols whose candles r green
scan for candles which r red
scan for candles which r yellow.............

also if we want to add more reliability than can we add more exploration code :
yellow candles which r hammer , buligh engulfing or shooting star ..........?

whole idea is that finding clear visibility for market trend .............
also i many times see that when we get breakout or breakdown and during pullback it often rejects from ma50 or wilder20 and forming a pattern like hammer , bulish engulfing or shooting star .........so i want to automate the process of scanning ...........

many afl experts r here ,
it mainly needs three conditions
1) candle colour change
2)exploration code for colour
3)exploration for candlestickpattern for yellow candles only

plz help ..........

p.s. : idea taken from a senior member here....
It can be done....
 

dell

Well-Known Member
#3
manoj ji ,
plz try ur hands on it....
and also plz give suggestions to improve it...and ur observation on it...
 

dell

Well-Known Member
#4
plz take a help from below ; if candlestick pattern will not be included only bar colour change and exploration of yellow bars only can be done it will also a graet help :
here yellow colour bar means candle touching wilder(20)

afl from which help can be taken it is rdma special :

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", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
SetChartBkColor(colorBlack) ;
SetBarFillColor( IIf( C >O AND C>MA(C,21) AND C>EMA(C,8),colorBlack, IIf( C <O AND C>MA(C,21) AND C>EMA(C,8),colorBlueGrey,IIf(( C<O AND C<MA(C,21) AND C>EMA(C,8)) OR ( C<O AND C>MA(C,21) AND C<EMA(C,8)) ,colorYellow,IIf(( C>O AND C<MA(C,21) AND C>EMA(C,8)) OR ( C>O AND C>MA(C,21) AND C<EMA(C,8)) ,colorBlack,IIf( C>O AND C<MA(C,21) AND C<EMA(C,8) ,colorBlack,colorRed) )))));
Col=IIf( C<MA(C,21) AND C<EMA(C,8) ,colorRed,IIf( C>MA(C,21) AND C>EMA(C,8),colorBlueGrey,IIf(( C<MA(C,21) AND C>EMA(C,8)) OR ( C>MA(C,21) AND C<EMA(C,8)) ,colorYellow,colorYellow)));
Plot( C, "Close", col, styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
black = C >O AND C>MA(C,21) AND C>EMA(C,8);
blue = C <O AND C>MA(C,21) AND C>EMA(C,8);
bb = black OR blue;
red = C <O AND C<MA(C,21) AND C<EMA(C,8);
Sell = Cross(red,bb);
Buy = Cross(bb,red);
Buyabove = High;
Buystop = Ref(Low,-2);
Sellbelow = Low;
Sellstop = Ref(High,-2);
sig = Buy OR Sell;
Filter = sig;
AddColumn(Sell,"sell");
AddColumn( Buy, "buy");
AddColumn(Buyabove,"buyabove",1.2,colorBlue);
AddColumn(Buystop,"buystop",1.2,colorBlue);
AddColumn(Sellbelow,"sellbelow",1.2,colorRed);
AddColumn(Sellstop,"sellstop",1.2,colorRed);
PlotShapes( shapeUpArrow*Buy, colorGreen,0, L, -20);
PlotShapes( shapeDownArrow*Sell, colorRed,0,H, -20) ;
 

dell

Well-Known Member
#5
now i understand coding is how much difficult after 40 minutes of work , trying different afl's mixture i finally can do only this :
it has only changing color , can any one add code to it for candle touching wilder became yellow ............

_SECTION_BEGIN("rdma spl");
_N(Title = StrFormat(EncodeColor( colorWhite) + "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
SetChartOptions(0,chartShowArrows|chartShowDates);

SetChartBkColor(colorBlack ) ;
ToolTip = "High = " + H + "\nOpen = " + O + "\nClose = " + C + "\nLow = " + L;


Col=IIf( C<Wilders(C,20) ,colorRed,colorBlueGrey);
Plot( C, "Close", col, styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

_SECTION_END();
 
#6
_SECTION_BEGIN("Price Color");
upEMAColor=ParamColor("Up OutLine Color", colorBrightGreen );
downEMAColor=ParamColor("Down OutLine Color", colorRed );
sidewaysEMAColor=ParamColor("Sideways OutLine Color", colorYellow );

upCandleColor=ParamColor("Up Candle Color", colorGreen );
downCandleColor=ParamColor("Down Candle Color", colorBrown );
sidewaysCandleColor=ParamColor("Sideways Candle Color", colorBlue );

em20=WMA(C, 20);

sidewaysEMAPercentage=Param("Sideways EMA %", 0.02, Minimum=0, Maximum=100, step=0.001);
emaDiff=abs(Ref(em20, 0) - Ref(em20, -1));
notSidewaysEMACondition=((100 * emaDiff) / em20) >= sidewaysEMAPercentage;

upEMACondition=C>em20 AND notSidewaysEMACondition;
downEMACondition=C<em20 AND notSidewaysEMACondition;
candleOutLineColor=IIf(upEMACondition, upEMAColor, IIf(downEMACondition, downEMAColor, sidewaysEMAColor));

upCandleCondition=C>O;
downCandleCondition=C<O;

candleFillColor=IIf(upCandleCondition, upCandleColor, IIf(downCandleCondition, downCandleColor, sidewaysCandleColor));

SetBarFillColor(candleFillColor);

Plot(C, "Close", candleOutLineColor, styleNoTitle | ParamStyle("Price Style", styleNoLabel) | GetPriceStyle());
_SECTION_END();

In this afl check what you need ....
 

dell

Well-Known Member
#7
_SECTION_BEGIN("Price Color");
upEMAColor=ParamColor("Up OutLine Color", colorBrightGreen );
downEMAColor=ParamColor("Down OutLine Color", colorRed );
sidewaysEMAColor=ParamColor("Sideways OutLine Color", colorYellow );

upCandleColor=ParamColor("Up Candle Color", colorGreen );
downCandleColor=ParamColor("Down Candle Color", colorBrown );
sidewaysCandleColor=ParamColor("Sideways Candle Color", colorBlue );

em20=WMA(C, 20);

sidewaysEMAPercentage=Param("Sideways EMA %", 0.02, Minimum=0, Maximum=100, step=0.001);
emaDiff=abs(Ref(em20, 0) - Ref(em20, -1));
notSidewaysEMACondition=((100 * emaDiff) / em20) >= sidewaysEMAPercentage;

upEMACondition=C>em20 AND notSidewaysEMACondition;
downEMACondition=C<em20 AND notSidewaysEMACondition;
candleOutLineColor=IIf(upEMACondition, upEMAColor, IIf(downEMACondition, downEMAColor, sidewaysEMAColor));

upCandleCondition=C>O;
downCandleCondition=C<O;

candleFillColor=IIf(upCandleCondition, upCandleColor, IIf(downCandleCondition, downCandleColor, sidewaysCandleColor));

SetBarFillColor(candleFillColor);

Plot(C, "Close", candleOutLineColor, styleNoTitle | ParamStyle("Price Style", styleNoLabel) | GetPriceStyle());
_SECTION_END();

In this afl check what you need ....
THANKS MANOJ JI ,
for me on 30m charts sideways ema % = 0.04 works ,
can u plz eleborate in simple words what here we r getting in sideways (condition)term ....
it is working ..........
also can we add my afl and ur sideways condition only , it will also serve perpose of clear visibility ...........
my afl
_SECTION_BEGIN("rdma spl");
_N(Title = StrFormat(EncodeColor( colorWhite) + "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
SetChartOptions(0,chartShowArrows|chartShowDates);

SetChartBkColor(colorBlack ) ;
ToolTip = "High = " + H + "\nOpen = " + O + "\nClose = " + C + "\nLow = " + L;


Col=IIf( C<Wilders(C,20) ,colorRed,colorBlueGrey);
Plot( C, "Close", col, styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

_SECTION_END();
 
#8
THANKS MANOJ JI ,
for me on 30m charts sideways ema % = 0.04 works ,
can u plz eleborate in simple words what here we r getting in sideways (condition)term ....
it is working ..........
also can we add my afl and ur sideways condition only , it will also serve perpose of clear visibility ...........
my afl
_SECTION_BEGIN("rdma spl");
_N(Title = StrFormat(EncodeColor( colorWhite) + "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
SetChartOptions(0,chartShowArrows|chartShowDates);

SetChartBkColor(colorBlack ) ;
ToolTip = "High = " + H + "\nOpen = " + O + "\nClose = " + C + "\nLow = " + L;


Col=IIf( C<Wilders(C,20) ,colorRed,colorBlueGrey);
Plot( C, "Close", col, styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

_SECTION_END();
Thank to raghuveer, he has written this afl, I too dont know much about afl's.
If raghuveer sees this thread he can solve this issue.
I will also give it a try
 

Similar threads

Broker Special Offers

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?