I rarely need/use any AFL coding skills (obvious here). I wanted a simple explore to make a count of how many of each of 3 conditions (close > ma1, ma2 ma3) in a watch list.
My code below delivers each symbol in watch list with results of 3 conditions but I simply want just a one line total of how many of each condition. The concept here is "when a very high % of stocks in an index are trading above sma (x), history shows a likely pullback. thanks in advance...
// explore count # of stocks above certain MA levels... theory is look for extremes when % very high or low
maShort = 10;
maMedium = 15;
maLong = 20;
_SECTION_BEGIN("Count");
cond1 = Close > MA(Close,maShort);
cond2 = Close > MA(Close,maMedium);
cond3 = Close > MA(Close,maLong);
cntr1 = sum(cond1,1);
cntr2 = sum(cond2,1);
cntr3 = sum(cond3,1);
Filter = cond1 OR cond2 OR cond3;
_SECTION_END();
Thank you very much for the quick and helpful response. This is exactly what I was hoping to achieve, It seems the 'Total # of Stocks" counter has a problem. I ran it against the Nasdaq 100 watch list and it shows 248 total stocks... the MA totals look OK..
I'll try to figure out the code, perhaps I'll learn something!
Thanks all for the help. What I did was close Amibroker and re-opened it and the code worked perfectly. Prior to that, I had copy and pasted the new code into an existing file, and updated via the "Apply" button. Then running the explore, gave me the inaccurate results.... all is good now