trying to do AFL coding....Help please.

#1
Hi everyone, been hee for a few days and the amount of information and wisdom on this forum is great...

Now I have been trying to program the following rules into Amibroker so that I can scan for stocks.

1. higher than 5 days volume
2. Aroon higher than 50
3. ADX higher than 30
4. RSI14 higher than 60

I am new to AFL so any help would be greately appreciated.

Raj.
 

swagat86

Active Member
#2
Hi everyone, been hee for a few days and the amount of information and wisdom on this forum is great...

Now I have been trying to program the following rules into Amibroker so that I can scan for stocks.

1. higher than 5 days volume
2. Aroon higher than 50
3. ADX higher than 30
4. RSI14 higher than 60

I am new to AFL so any help would be greately appreciated.

Raj.
volume
/* Create date: 05 Jun 2007
The Volume of the current bar is greater than the Volume (Average) of 1 bar ago */

Filter = Volume > Ref( MA( Volume, 5 ), -1 );
AddColumn( Close, "Close " );
AddColumn( Open, "Open " );
AddColumn( High, "High " );
AddColumn( Low, "Low " );
AddColumn( Volume, "Volume " );


adx

/* Create date: 05 Jun 2007
The ADX of the current bar is greater than 30 */

Filter = ADX( 14 ) > 30;
AddColumn( Close, "Close " );
AddColumn( Open, "Open " );
AddColumn( High, "High " );
AddColumn( Low, "Low " );
AddColumn( Volume, "Volume " );


Rsi

/* Create date: 05 Jun 2007
The RSI of the current bar is greater than 60 */

Filter = RSIa( Close, 14 ) > 60;
AddColumn( Close, "Close " );
AddColumn( Open, "Open " );
AddColumn( High, "High " );
AddColumn( Low, "Low " );
AddColumn( Volume, "Volume " );

aroon i have no idea abt.


thanks
 
#3
Hi Swagat, thanx a lot for your time and effort. I got 2 syntax error:

Error31. Syntax error, expecting '('

Filter = ADX( 14 ) > 30;
Filter = RSIa(Close, 14 ) > 60;

I thought we could use something like this one:

Filter = RSI(14) > 60

ADX(14) > 30 ;

and at the end do something like this to only list stocks that qualify all the conditions:

Filter = RSI(14) > 60 AND ADX(14) > 0 AND Volume > Ref( MA( Volume, 5 ), -1 );
AddColumn( Close, "Close " );
AddColumn( Open, "Open " );
AddColumn( High, "High " );
AddColumn( Low, "Low " );
AddColumn( Volume, "Volume " );
 
#4
ok I have got it this close, but getting an error at the last line. I think its the "Aroon_Osc" > 30; bit that is not right.

Also, if I wanna add Buy/Sell to it, what would be a good way to do it ?

thanx a lot for your help, and hope somebody is able to fix it for me. This is really interesting.

Code:
//****************************************************************************************
// My Exploration - Ver 4
// ***************************************************************************************

/* Create date: 05 Jun 2007

The Volume of the current bar is greater than the Volume (Average) of 1 bar ago */

Filter = Volume > Ref( MA( Volume, 2 ), -1 );

//The ADX of the current bar is greater than 20 */

Filter = ADX( 14 ) > 20;

//The RSI of the current bar is greater than 50 */

Filter = RSIa( Close, 14 ) > 50;

// Exploration in Aroon 
Period = 14;
LLVBarsSince = LLVBars(L, Period) + 1;
HHVBarsSince = HHVBars(H, Period) + 1;

Aroon_Down = 100 * (Period - LLVBarsSince) / (Period - 1);
Aroon_Up   = 100 * (Period - HHVBarsSince) / (Period - 1);
Aroon_Osc  = Aroon_Up - Aroon_Down;

AddColumn(Aroon_Osc,    "Aroon_Osc",    format=1.2);
AddColumn( Close, "Close " );
AddColumn( Open, "Open " );
AddColumn( High, "High " );
AddColumn( Low, "Low " );
AddColumn( Volume, "Volume " );

Filter = RSIa( Close, 14 ) > 60 AND ADX(14) > 30 AND Volume > Ref( MA( Volume, 5 ), -1 ); AND "Aroon_Osc" > 30;
 
Last edited:

bvpraveen

Active Member
#6
ok I have got it this close, but getting an error at the last line. I think its the "Aroon_Osc" > 30; bit that is not right.
1. There is a typo in the last statement. Remove the extra semi-colon and remove the doube quotes in Aroon_Osc. Here is the updated Filter statement:

Filter = RSIa( Close, 14 ) > 60 AND ADX(14) > 30 AND Volume > Ref( MA( Volume, 5 ), -1 ) AND Aroon_Osc > 30;

2. Assign the Filter variable just once. Assigning more than once is not logical. The usage of Filter in your last statement is correct - ie using AND, OR, etc...

Also, if I wanna add Buy/Sell to it, what would be a good way to do it ?
I don't know what your formula does. I think the Filter condition is itself Buy signal. So

Buy = Filter;

will suffice for Buy signals. Similarly code for Sell signal.

Please look at some sample AFLs, or templates(which i'd posted some time back), for getting Buy and Sell signals on charts(with arrows, etc)

Get back to us for any clarifications.

Praveen.
 
#7
I need help on making indicators for weekly prices.

eg If today is thursiday, and the closing EOD is 111, and last week friday the opening was 91. That is opening on (n-4)th day and closing on nth day

I need these data for all days.

And then use it for indicators.


How to do it?
 

bvpraveen

Active Member
#8
I need help on making indicators for weekly prices.

eg If today is thursiday, and the closing EOD is 111, and last week friday the opening was 91. That is opening on (n-4)th day and closing on nth day

I need these data for all days.

And then use it for indicators.


How to do it?
Try Ref(). See Amibroker User Guide for details about Ref().

Praveen.