PureBytes Links
Trading Reference Links
|
OK I will answer my own question.
(Amazing how going for a bike ride, leaving the PC and coming back to it later clears the brain, even at my age!!)
I have found a way of doing this with the BarsSince function:
BaseIndex = "XAO";
rs =RelStrength("BaseIndex"); MA_rs= EMA(rs,30);
Cond1 = rs > MA_rs; Cond2 = Cross(rs, MA_rs);
Filter = Cond1 AND BarsSince(Cond2) > 5 ;
AddColumn(BarsSince(Cond2) >= 5;
Plot(rs,"RS",colorGreen,1); Plot(EMA(rs,30),"ema RS",colorBlue,1);
Regards to all.
ChrisB
kris45mar <kris45mar@xxxxxxxxx> wrote:
Greetings All..
I want to explore for stocks where the Relative strength is currently greater than its own EMA for more than the last 5 *sequential* periods.
So far I am using the following filter… Filter = Sum(Cond1,10) > 5 ; as in…
BaseIndex = "XAO";
rs =RelStrength("BaseIndex"); MA_rs= EMA(rs,30);
Cond1 = rs > MA_rs;
Filter = Sum(Cond1,10) > 5 ;
AddColumn(RelStrength("BaseIndex"),"RS vs XAO",1.2); AddColumn(EMA(RelStrength("BaseIndex"),30),"EMA30 RS", 1.2); AddColumn(Sum(Cond1,10),"days over",1.2);
Plot(rs,"RS",colorGreen,1); Plot(EMA(rs,30),"ema RS",colorBlue,1);
PROBLEM: this gives me total no. of times Cond1 has occurred within the last 10 periods, even if the condition does not apply at the last bar, and only *totals* the number of times this has occurred, and they
may or may not be sequential/continuous.
GOAL: I want to be able to explore for stocks where the Relative Strength is *currently* greater than its own EMA for more than say 5 continuous/sequential periods, and then rank them according to those that outperformed for the longest.
I NEED: AFL code for a filter that returns shares where the cond1 has been true for > 5 sequential periods and is still true at the moment.
What functions in AFL code can I use here?
TIA
ChrisB
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
------------------------ Yahoo! Groups Sponsor --------------------~--> $4.98 domain names from Yahoo!. Register anything. http://us.click.yahoo.com/Q7_YsB/neXJAA/yQLSAA/GHeqlB/TM --------------------------------------------------------------------~->
Check AmiBroker web page at: http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html Yahoo! Groups Links
<*> To visit your group on the web, go to: http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to: amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
Do you Yahoo!?
Yahoo! Mail - Find what you need with new enhanced search. Learn more.
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
|