[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] [Newbie] Exploration Sum of outperforming weeks:



PureBytes Links

Trading Reference Links

Hi All.
 
I do the following exploration to look for stocks that are outperforming base index:
 
BaseIndex = "XAO";

P1 =Param("MA time period",13, 5, 20, 1);

P2 = Param("ROC period", 5, 1, 100, 1);

RS = RelStrength(BaseIndex);

MA_RS = MA(RS,P1);

RC = ROC(MA_RS,P2);

AddColumn(C, "C",1.3);

AddColumn(RS,"RS", 1.2);

AddColumn(MA_RS,"MA_RS",1.2);

AddColumn(ROC(MA_RS,5),"RSC",1.2);

QUESTION:

I also want to Addcolumn to display the number of weeks that the RS has been above the MA_RS.

I can use 

cond1 = RS > MA_RS;

cond2 = Ref(RS,-1) > Ref(MA_RS,-1);

cond3 = Ref(RS,-2)  > Ref(MA_RS,-2);

cond4 = Ref(RS, -3) > Ref(MA_RS, -3);

condn = Ref(RS, -(n-1)) > Ref(MA_RS, -(n-1)); // how do I fix this to go back as far as necessary?

N = cond1 + cond2+ cond3 + cond4  + cond  n ;// number of weeks RS is above its MA

Then use

Addcolumn(N, "no of weeks above MA", 1.0);

How do I tidy up the code underlined above to allow me go back n number of weeks?

Regards

Chris

 


		
---------------------------------
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.

[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/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/