AFL writing guide for new user

#1
Hello Friends,
I started this thread because I did lot of googling but I have not yet found any good site that helps "How to write AFL". I know there is a site contains AFL Library but it is not sufficient. I have a computer background, so I understand how the process goes, I can write very basic AFL also. But I want active participation of seniors, those have very good knowledge of writing AFL. I know many members are here with good knowledge of AFL. Please help new users as well as intermediate user.

Happy Trading
Debarghya Mukherjee
 

msa5678

Well-Known Member
#2
Hello Friends,
I started this thread because I did lot of googling but I have not yet found any good site that helps "How to write AFL". I know there is a site contains AFL Library but it is not sufficient. I have a computer background, so I understand how the process goes, I can write very basic AFL also. But I want active participation of seniors, those have very good knowledge of writing AFL. I know many members are here with good knowledge of AFL. Please help new users as well as intermediate user.

Happy Trading
Debarghya Mukherjee
Hi DM,

Sure I will help in whatever little I know.

Regards.:)
 
#3
Thank you my friend,
I really appreciate if active members like you help others. It is really very cool to know AFl because then you can test your own trading methods by yourself. right? I searched many, but there is really no good site I found. If any memeber knows any good thread in traderji or any other site. Please share it here. I think it will help new AFL users.

Debarghya Mukherjee

Hi DM,

Sure I will help in whatever little I know.

Regards.:)
 
#4
AFL has 4 main parts

Buy = Your entry signal for long trade;

Sell = You exit signal for long trade;

Short = Your entry signal for short trade;

Cover = You exit signal for short trade;

Now decide your signal and put in here. In the next post I will discuss different codes for entry and exit signals.
 
#5
AFL for MA or EMA cross over system​


May be you have EMA/MA cross over system. I am writing the code for it,


Buy= Cross(EMA( C, 20 ), EMA( C, 50 ));

Sell= Cross(EMA( C, 50 ), EMA( C, 20 ));

Now here replace 20 and 50 with your desired value. This will generate nice signal for your 20/50 EMA cross over system. Go long when EMA(20) crosses EMA(50). and sell in opposite.
 
#6
How to plot Price in your system?

It is very important to show price action in your chart. Here this simple code will show price in your chart.

_SECTION_BEGIN("price section");
SetChartOptions(0,chartShowArrows|chartShowDates);
Plot( Close, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

This will display daily chart.
 
#7
AFL for VISUAL EMA CROSS OVER system

Fine you have already learned how to draw price action and how to generate signal. Now you want to plot your favorite EMA in chart. how can you do it?

_SECTION_BEGIN("EMA 20/50 cross over system");
SetChartOptions(0,chartShowArrows|chartShowDates);
Plot( Close, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

Buy= Cross(EMA( C, 20 ), EMA( C, 50 ));
Sell= Cross(EMA( C, 50 ), EMA( C, 20 ));

Plot( EMA( C,20), "20 EMA Close",ParamColor("EMA 20 Color", colorGreen ),styleNoRescale);
Plot( EMA( C,50), "50 EMA Close",ParamColor("EMA 50 Color", colorRed ),styleNoRescale);
_SECTION_END();

You output will be
 

deadbrain

Well-Known Member
#8
Hello Friends,
I started this thread because I did lot of googling but I have not yet found any good site that helps "How to write AFL". I know there is a site contains AFL Library but it is not sufficient. I have a computer background, so I understand how the process goes, I can write very basic AFL also. But I want active participation of seniors, those have very good knowledge of writing AFL. I know many members are here with good knowledge of AFL. Please help new users as well as intermediate user.

Happy Trading
Debarghya Mukherjee
Good initiative Debarghya.
 
#9
AFL FOR "VISUAL ARROW" FOR EMA CROSS OVER SYSTEM

Well we have have plotted our price and desired ema in the chart. Now may be we want to put an arrow in the chart. This will help us to recognize our signal better. How can I do this? Here is the code for it.

_SECTION_BEGIN("visual arrow ema cross over");
SetChartOptions(0,chartShowArrows|chartShowDates);
Plot( Close, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

Buy= Cross(EMA( C, 20 ), EMA( C, 50 ));
Sell= Cross(EMA( C, 50 ), EMA( C, 20 ));

PlotShapes(IIf(Sell==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-20);
PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorGreen, 0,Low, Offset=-20);

Plot( EMA( C,20), "20 EMA Close",ParamColor("EMA 20 Color", colorGreen ),styleNoRescale);
Plot( EMA( C,50), "50 EMA Close",ParamColor("EMA 50 Color", colorRed ),styleNoRescale);
_SECTION_END();


here Plot function is making this arrow.
Plot( EMA( C,20), "20 EMA Close",ParamColor("EMA 20 Color", colorGreen ),styleNoRescale);
Plot( EMA( C,50), "50 EMA Close",ParamColor("EMA 50 Color", colorRed ),styleNoRescale);


here is the output
 

deadbrain

Well-Known Member
#10
Some AFLs do not work on my 4.8 Ami, they show such errors like

Syntax error, expecting ')" or ','

etc.

Can you please tell how can we overcome such an issue.
 

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?