Need Buy/Sell Values for this AFL

#1
Hi Seniors and all AFL coders ..

Need help on the below AFL . This is a simple AFL 14 days EMA crossover by 206 days ema . Got this AFL frm a well know site of Rajendra .

Buy and Sell arrows are visible .. But i need values to attached for those signals...Like Buy at xyz price .. and sell at xyz price .


Also need a Message box below displaying the buy and Sell price generated above .

i am a beginner and have no idea abt AFL coding.. so plz help me .


Thanks,
Kumar



the code is as follows :


_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", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();



_SECTION_BEGIN("EMA");

Range1=Optimize("range1",14,1,20,1);
Range2=Optimize("range2",206,1,125,1);

Buy = Cross((EMA(Close,range1)),(EMA(Close,range2)));
Sell = Cross(EMA(Close,range2),(EMA(Close,range1)));
Short = Sell;
Cover = Buy;

// plot expanded average

Plot(EMA( Close,range1), "70min-ema", colorRed );
Plot(EMA( Close,range2), "1030min-ema", colorGreen );

// plot arrows
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );

_SECTION_END();
 
Last edited:

casoni

Well-Known Member
#2
Hello,
paste this below your code . this will plot close price of given , signal bar.

perc=Param("text up-dn,",1,0.5,2,0.1);
dist = ((H+L)/2)/100* perc;
for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "Buy\[email protected]" + C[ i ], i, L[ i ]-dist, colorGreen );
if( Sell ) PlotText( "Sell\[email protected]" + C[ i ], i, H[ i ]+dist, colorRed );
}

hope this helps
thank you
 
#4
use on 5 mint chart same as ur afl u can check it

u have used 70 & 1030 ema & same way i have taken 14 & 200 ema.

thanks

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", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

_SECTION_BEGIN("14200");
MO=EMA(C,14);
ML=EMA(C,200);


Plot(MO,"",colorBlue,styleDashed);
Plot(ML,"",4,styleDashed);

Buy = Cross(MO,ML);
Sell = Cross (ML,MO);


dist = 1.5*ATR(10);

for( i = 0; i < BarCount; i++ ) 
{ 
if( Buy[i] ) PlotText( "Buy " + H[ i ], i, L[ i ]-dist[i],2, colorGreen ); 
if( Sell[i] ) PlotText( "SELL " + L[ i ], i, H[ i ]+dist[i], colorRed, colorYellow ); 
}

PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorYellow, colorYellow ) );

 

_SECTION_END();

_SECTION_BEGIN("Background_Setting");
SetChartBkGradientFill( ParamColor("BgTop", colorBlack),

ParamColor("BgBottom", colorLightGrey),ParamColor("titleblock",colorBlack)); 
_SECTION_END();

_SECTION_BEGIN("Stoploss");
no=20;
res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
supres=IIf(avn==1,sup,res);
 
color=IIf(avn==1,colorPaleGreen,colorOrange);
Plot(supres,"Stoploss",color,styleStaircase|styleThick|styleNoTitle);
_SECTION_END();
 
#5
thank you Casoni and YrJadeja for helping me out .

Also need a Message box below displaying the buy and Sell price generated above .

Plz help me out on this issue.

Also . yrjadeja has taken High and low average .. But casoni sir has taken just closing... which is the better method ...
 
#6
Sir, I am new to AMI BROKER (downloaded version) I am using it for Intra Day 5mins chart, I get BUY/SELL signals but, the option show arrows in actual trade doesn't work, after 5 mins when it refreshes the previous buy/sell signals disappear till I double click the scrip in ANALYSIS window..is it same for all or I need some specific afl to fix this..I want the buy sell signal always available in the chart, n when new buy sell signal comes that needs to appear in the chart auto
 
#7
Hi Partha,

i am not sure wat the problem is.. But in my amibroker and AFL .. the previous buy/sell signal .. still remains... It doesnt disappear .

I think some seniors can throw light or solve your problem .

Thank you,
Kumar
 

KelvinHand

Well-Known Member
#8
Hello,
paste this below your code . this will plot close price of given , signal bar.

perc=Param("text up-dn,",1,0.5,2,0.1);
dist = ((H+L)/2)/100* perc;
for( i = 0; i < BarCount; i++ )
{
if( Buy ) PlotText( "Buy\[email protected]" + C[ i ], i, L[ i ]-dist, colorGreen );
if( Sell ) PlotText( "Sell\[email protected]" + C[ i ], i, H[ i ]+dist, colorRed );
}

hope this helps
thank you


Your dist statement not very good. Can cause problem.
 
#9
Sir, I am new to AMI BROKER (downloaded version) I am using it for Intra Day 5mins chart, I get BUY/SELL signals but, the option show arrows in actual trade doesn't work, after 5 mins when it refreshes the previous buy/sell signals disappear till I double click the scrip in ANALYSIS window..is it same for all or I need some specific afl to fix this..I want the buy sell signal always available in the chart, n when new buy sell signal comes that needs to appear in the chart auto
Hi Partha
Which afl you are using. Just post it here.
If using one posted above then the buy and sell signal once generated, do not disappear, they remain. (need not post afl here)
However, if you are using someother afl just post it here. And in the meantime stop using that afl. As it looks into future, and it can give you heavy losses.
 

mastermind007

Well-Known Member
#10
Sir, I am new to AMI BROKER (downloaded version) I am using it for Intra Day 5mins chart, I get BUY/SELL signals but, the option show arrows in actual trade doesn't work, after 5 mins when it refreshes the previous buy/sell signals disappear till I double click the scrip in ANALYSIS window..is it same for all or I need some specific afl to fix this..I want the buy sell signal always available in the chart, n when new buy sell signal comes that needs to appear in the chart auto
Put this line on top

SetBarsRequired(sbrAll);

If this continues to happen after that, your AFL is most likely faulty.
 

Similar threads

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?