AFL Beginner's Queries

#1
Hi,

I am a beginner to Amibroker AFL. I am an experienced trader who is trying his hand at Amibroker and AFL. I have programming experience with other programming languages. I went thro' AFL tutorial and came up with a very simple AFL. The idea is to generate Buy & Sell Indicators. However, it doesn't work as required:annoyed: Can you please help me with this? Here goes the code:

_SECTION_BEGIN("AFL Example");

LongMA = EMA( C, 100 );
MidMA = EMA( C, 50 );
ShortMA = EMA( C, 20 );
Buy = Cross( ShortMA, MidMA ) AND Cross(MidMA,LongMA);
Sell = Cross( LongMA, MidMA ) AND Cross(MidMA,ShortMA);

Filter=1;
AddTextColumn( FullName(), "Company Name" );
AddColumn( Buy, "Buy", 1 );
AddColumn( Sell, "Sell", 1 );
AddColumn( C, "Close", 1.3 );
AddColumn( H, "High", 1.3 );
AddColumn( ShortMA, "Short MA", 1,3 );
AddColumn( MidMA, "Mid MA", 1,3 );
AddColumn( LongMA, "Long MA", 1,3 );
_SECTION_END();


I have also attached the screenshot and highlighted what is displayed and what I am expecting from this script. Can you please help?

Thanks,
Prash
 

Attachments

#2
Hi,

I am a beginner to Amibroker AFL. I am an experienced trader who is trying his hand at Amibroker and AFL. I have programming experience with other programming languages. I went thro' AFL tutorial and came up with a very simple AFL. The idea is to generate Buy & Sell Indicators. However, it doesn't work as required:annoyed: Can you please help me with this? Here goes the code:

_SECTION_BEGIN("AFL Example");

LongMA = EMA( C, 100 );
MidMA = EMA( C, 50 );
ShortMA = EMA( C, 20 );
Buy = Cross( ShortMA, MidMA ) AND Cross(MidMA,LongMA);
Sell = Cross( LongMA, MidMA ) AND Cross(MidMA,ShortMA);

Filter=1;
AddTextColumn( FullName(), "Company Name" );
AddColumn( Buy, "Buy", 1 );
AddColumn( Sell, "Sell", 1 );
AddColumn( C, "Close", 1.3 );
AddColumn( H, "High", 1.3 );
AddColumn( ShortMA, "Short MA", 1,3 );
AddColumn( MidMA, "Mid MA", 1,3 );
AddColumn( LongMA, "Long MA", 1,3 );
_SECTION_END();


I have also attached the screenshot and highlighted what is displayed and what I am expecting from this script. Can you please help?

Thanks,
Prash

Buy = Cross( ShortMA, MidMA ) AND Cross(MidMA,LongMA);
Sell = Cross( LongMA, MidMA ) AND Cross(MidMA,ShortMA);

red and blue never happend at the same time. :D

better change short>=long,.... something
 

HULK

Active Member
#3
Hi,

I am a beginner to Amibroker AFL. I am an experienced trader who is trying his hand at Amibroker and AFL. I have programming experience with other programming languages. I went thro' AFL tutorial and came up with a very simple AFL. The idea is to generate Buy & Sell Indicators. However, it doesn't work as required:annoyed: Can you please help me with this? Here goes the code:

_SECTION_BEGIN("AFL Example");

LongMA = EMA( C, 100 );
MidMA = EMA( C, 50 );
ShortMA = EMA( C, 20 );
Buy = Cross( ShortMA, MidMA ) AND Cross(MidMA,LongMA);
Sell = Cross( LongMA, MidMA ) AND Cross(MidMA,ShortMA);

Filter=1;
AddTextColumn( FullName(), "Company Name" );
AddColumn( Buy, "Buy", 1 );
AddColumn( Sell, "Sell", 1 );
AddColumn( C, "Close", 1.3 );
AddColumn( H, "High", 1.3 );
AddColumn( ShortMA, "Short MA", 1,3 );
AddColumn( MidMA, "Mid MA", 1,3 );
AddColumn( LongMA, "Long MA", 1,3 );
_SECTION_END();


I have also attached the screenshot and highlighted what is displayed and what I am expecting from this script. Can you please help?

Thanks,
Prash
Parsh

In Buy / Sell condition Insted of using cross condition try to use ">/<"
condition. I think it will solve ur issue.



Buy = ShortMA > LongMA ; //This will give you strong buy sign But sign will be late
Sell = ShortMA < LongMA ; // This will give you strong sell sign (Late)

Also add

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

Let me know the result

Enjoy :thumb:

HULK
 
#4
Code:
LongMA = EMA( C, 100 );
MidMA = EMA( C, 50 );
ShortMA = EMA( C, 20 );
Buy = Cross( ShortMA, MidMA ) AND MidMA > LongMA ;
Sell = Cross( LongMA, MidMA ) AND MidMA < LongMA;

Filter=Buy || Sell;
AddTextColumn( FullName(), "Company Name" );
AddColumn( Buy, "Buy", 1 );
AddColumn( Sell, "Sell", 1 );
AddColumn( C, "Close", 1.3 );
AddColumn( H, "High", 1.3 );
AddColumn( ShortMA, "Short MA", 1.3 );
AddColumn( MidMA, "Mid MA", 1.3 );
AddColumn( LongMA, "Long MA", 1.3 );
 
#5
Thanks Everybody for helping me understand the mistake in the code.:)

Hulk,

You have used following lines of code. What is the significance?
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

Also, I tried back testing this script against the EOD data in Amibroker. Is there a way I can execute this data against Intraday data? Whenever I execute this using Automatic analysis tool, it seems to only list data from Daily charts.

Thanks,
Prash
 
#6
Also, I tried back testing this script against the EOD data in Amibroker. Is there a way I can execute this data against Intraday data? Whenever I execute this using Automatic analysis tool, it seems to only list data from Daily charts.

Thanks,
Prash
First you need to use intra-day data. Secondly you need to set intra-day periodicity in AA (Auto Analysis) settings.
 
#8
Detwo,

Thanks for your reply.

I think you mistook my question. Obviously I read the manual before coding. But it's just that I didn't get the intent / logic behind using exrim instead of just using Buy / Sell.

A beginner's stumbling block questions these.. :)
 
#9
is afl for price action trading can be created in amibroker or not?

what does afl means?
once u stored ur system in amibroker n it will automatically give buy sell signals target, tsl, sl.
you have to just watch those signals n place order from terminal.
m i correct

thax
 
#10
Hi..
I was looking for Afl if any, available for for Multiple VMA(Variable MA) also known as VIDYA.
If any one has it, please post the same.

Regards

Santosh
 

Similar threads