Help adding buy/sell signal,exploration to this afl

#1
Hello guys pls help me add buy sell signal and exploration to this afl,the conditions are long over high of blue candle,short bellow low of red candle ,sl is high/low of 2 previous candle when there is a new low/high.The exploration should show the candle colour..


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() );

_SECTION_BEGIN("MA2");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
 
#2
Hi Friends,

I am new in stock market. I use amibroker software for analyses. I want write one simple afl in intraday 30 min candle chart when candle color is green and after closing these green candle and next candle is break high of previous green candle buy call and vise versa in case of red candle

if any one do these pls try.......

Thanks
 
#4
here go you ,

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

_SECTION_BEGIN("MA2");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();


i have tried my best..
thank you
 
#5
if i want to check if filter condition is buy then do something how to do that, if it is sell then do some thing else...i m not getting control in if condition .
if lastvalue(buy= true);
{
do something
}
this do somthing not trigerred.


pls help experts.
 

Similar threads