AFL to explore scrips trading in a narrow range

#1
Hi,

I am new to AFL. I want to explore scrips that are traded within a narrow price range in recent times. For example, I want to explore the stocks whose closing prices are not more (or less) than 10% of their average closing price of the past 2 months. Can anyone please help me with this?

Thanks.
 

colion

Active Member
#2
Try something like this as the basis for your exploration:

maC = ma( c, 40 ); //assume 20 days/month
inrangeC = iif( c < 1.1 * maC or c > .9 * maC, 1, 0 );
 
#4
Try something like this as the basis for your exploration:

maC = ma( c, 40 ); //assume 20 days/month
inrangeC = iif( c < 1.1 * maC or c > .9 * maC, 1, 0 );
I think we should use AND rather than OR because we want to capture the price value if it falls within that narrow range. Moreover, the above code tests the condition for only one day. That means, if the price was way above the 40-day moving average for the last 3 or 4 months and dropped only in recent days to satisfy our condition, then that value will also be considered. But what we need is that the price should be varying within a narrow range of plus or minus 10% in the last 40 or 20 trading days. Am I making myself clear?

Can anyone please help me with the code? Since I am new to AFL, please give me the full working program which includes all the statements, not just the bare logic as I don't know the declarations I have to make.
 

Similar threads