|
allan nathan
2015-08-18 17:11:40
|
|
Hi,
I am working with the composite function and have read thru the examples you have provided.I am still unsure how to reference another list of stocks to create an
Advance Decline index. I have a watchlist named SP 500,and I would like to reference it while running a simulation on another list of stocks..I created a basic AD line and 2
moving averages.I use a crossover of the adv -Dec as a market timer. I then use the setsimlongrank to purchase the strongest stocks.
My specific question is how do I compute the Adv Dec from my watchlist Sp 500 if I am backtesting another list?
dif=comp(close>ref(close,1),"sum"); // adv
baddif=comp(close<=ref(close,1),"sum"); //dec
adl=dif-baddif; // adv-dec
shortdif=sma(adl,13); // 13d ma
longdif=sma(adl,200); // 200d ma
a1 = perf(close,66); // Performance of stock for the last month
strength=a1;
buy=cross(shortdif,longdif);
SetSimLongRank(strength); // Rank stocks by their performance
sell=cross(longdif,shortdif);
Thanks,
Allan
|
|