Formular AFL for Amibroker Explorer

Hello,

I am new on amibroker and programming. I in need to a formula AFL that can scan a watchlist with this columns:

  1. number on ranking;
  2. name of the stock ticket;
  3. price variation of the last 26 weeks as a percentage;
  4. average volume;
  5. last price of close;
  6. Relative Strength - RS.

Until now, I get this code:

rs = RelStrength( "IBOV");
Filter = True;
AddColumn(C,"Close",1.2);
AddColumn(rs, "Relative Strength vs. Bovespa");
AddColumn(OpenInt,"OpenInt",1.2);
AddColumn(V,"Volume",1.2);
AddColumn(ROC(C,1),"% Price change",1.2);
AddColumn(ROC(OpenInt,1),"% OpenInt change",1.2);
AddColumn(ROC(V,1),"% Volume change",1.2);
_SECTION_END();

But it's still a long way from what I need.

Since now, thank you for every help.

@iagolplima you look like you are off to a very good start.

By what criteria are you ranking? You may need to learn about staticvargenerateranks
https://www.amibroker.com/guide/afl/staticvargenerateranks.html

Add this to your Exploration

AddTextColumn(FullName(), "Name");
AddColumn( ROC( C, 26 ), "26 week % Change", 1.2 ); // if WEEKLY setting in AA, 26 week ROC

Over what period do you want to average the volume? If using WEEKLY settings in analysis,

AveVolume = MA( V, 10 ); // replace 10 with whatever average period you need
AddColumn( AveVolume, "10 week Ave Volume", 1.0 );

The rest you seem to have already found?

I am not familiar with the details of AmiBroker's RelStrength function, and I don't have Bovespa data or Open Interest data. But here is a simple example.

SP500 			= Foreign( "$SPX", "Close");
RelativeROC26	= ROC(C, 26) / ROC(SP500, 26);
AveVolume 		= MA( V, 10 ); // replace 10 with whatever average period you need

//  explore your results // 
Filter = 1;
AddTextColumn(FullName(), "Name");
AddColumn( C, "Close", 1.2 );
AddColumn( AveVolume, "10 week Ave Volume", 1.0 );
AddColumn( ROC( C, 26 ), "26 week % Change", 1.2 ); // if WEEKLY setting in AA, 26 week ROC
AddColumn( RelativeROC26, "Relative ROC(26)", 1.2 );

image

3 Likes

Thank you very very much.