Re: [amibroker] Re: code for Clenow book

 

I am posting main part of my 'stocks on the move' code here:
I use it on Russell 1000 historical constituents.  (using premium data alpha program)

SetBacktestMode( backtestRotational );
SetOption("WorstRankHeld", 250); //top 25%

BuyPrice = O;
SellPrice = O;

//Calculate purchase size
lbp = 30; //one month
RiskPerShare =  3 * ATR(lbp);
PositionRisk = 1.5;     //PosRisk risk 1.5% of equity
PctSize =  PositionRisk * BuyPrice / RiskPerShare;


SPY = Foreign("SPY","C");
SPY200 = EMA(SPY,200);

//sell if SPY below 200day ema
bMacro_SellStocks =     (SPY < SPY200) ;      //Liquidate holdings


lbp = 90;  
AnnualizedSlope = (exp(LinRegSlope(ln(C),lbp))^252) - 1;
Rsq =  (Correlation(Cum(1), C, lbp))^2;
ExpectedGain = AnnualizedSlope * Rsq;


Score = 100 + ExpectedGain;  //to avoid short selling
Score = IIf(bMacro_SellStock, 0, Score); //no buy if market in downtrend

PositionScore = IIf(DayOfWeek() == 5,Score, scoreNoRotate); //trade once a week

HTH,
Vandan

__._,_.___

Posted by: vandan_tanna@yahoo.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (9)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/


.

__,_._,___


EmoticonEmoticon