Skip to main content

52 weeks high momentum strategy.





52 weeks high momentum strategy.
(FTWHMS)
Strategy is to buy stocks which have closed at 52 weeks high and which has the characteristics of a possible bullish run identified by momentum indicators like RS and RSI. Volumes and key MAs are also used as important indicators to figure out the stocks. Exploration can be used to filter stocks and can be sorted based on momentum scores in descending order. Momenutm scores are a function of relative strength and price change with respect to 12 periods back. The top 5 stocks can be explored further for investments. This is a long only strategy. Weekly chart gives better results than daily charts.
I am posting the AFL code for the above strategy , a sample chart screenshot and the last 7 years backtesting results on weekly charts of nse listed stocks. Though backtesting result appears faily decent I am not commenting anything further on it as the result does not guarantee any future returns.
Please note to use this AFL code at your own risk. I will not be in anyway responsible for any loss arising out of this strategy / AFL whatsoever. By posting this AFL I am not recommending to follow this strategy.
// TRADING STRATEGY OF THIS AFL
// FTWHMS - FIFTY TWO WEEKS HIGH MOMENTUM STRATEGY
// BROAD CONDITIONS - 52 WEEKS HIGH; RSI AND RS FOR MOMENTUM; OPTIMISED EMAS FOR DIRECTION; VOLUME BASED BUYING
// USE ONLY ON WEEKLY CHART. FOUND TO BE BETTER PERFORMING ON WEEKLY CHARTS
// THIS AFL DOES NOT GUARANTEE ANY POSITIVE RETURNS.
// USE THIS AFL AT YOUR OWN RISK
// THIS AFL WAS DEVELOPED BY HALAN MANOJ KUMAR, MSC,CAIIB,FRM,PRM,CMA,ACMA. HOWEVER IN SOME CASES INDIVIDUAL CODE SNIPPETS ARE FROM DIFFERENT SOURCES AND I THANK THOSE DEVELOPERS.
// ANY CONCEPTUAL QUERIES OR COMMENTS CAN BE MAILED TO scorpiomanoj73@gmail.com
_SECTION_BEGIN("CHART");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%)", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
// MAs OPTIMISED USING TRIAL AND ERROR METHOD ;
// OPENING PRICE BASED MAs USED TO HAVE RELATIVELY ADVANCE SIGNAL.
cmaperiod1 = Param( "Price MA Period1", 10, 0, 500, 1 );
SMA = MA(O,CMAPERIOD1);
cmaperiod2 = Param( "Price MA Period2", 18, 0, 500, 1 );
MMA = MA(O,CMAPERIOD2);
cmaperiod3 = Param( "Price MA Period3", 50, 0, 500, 1 );
TMA = MA(O,CMAPERIOD3);
Plot(SMA ,"SMA10WK",colorBrown,styleLine);
Plot(MMA ,"SMA18WK",colorBrown,styleLine);
Plot(TMA,"SMA50WK",colorBlueGrey,styleLine);
// Other conditions
// STOCKS ABOVE RS 25 ONLY CONSIDERED TO AVOID PENNY STOCKS.
// VOLUME ABOVE 10 PD MA
// RSI ABOVE 50
// 52 WEEKS HIGH
// RELATIVE STRENGTH WITH RESPECT TO BROAD INDEX SHOULD BE UPWARD SLOPING.
// STOCKS RANKED BASED ON CHANGE IN PRICE WITH RESPECT TO 12 PERIODS BACK - ONLY USED IN EXPLORER TO SCORE STOCKS.
A1 = C > 25;
A2 = V > 3*MA(V,10);
A3 = RSI(14) > 50;
A5 = Close > Ref(HHV(High,52),-1);
A6 = RelStrength("NSENIFTY",True) > MA(RelStrength("NSENIFTY",True),50);
TtD_Change = 100 * (Close - Ref(Close, -12) ) / Ref(Close, -12);
_SECTION_BEGIN("Explorer");
Filter = 1;
AddColumn(TtD_Change,"MOMENTUM SCORE",1.2,IIf(TtD_Change>0,colorGreen,colorRed));
_SECTION_END();
Buy = (SMA > MMA) AND (C > TMA OR Cross(C,TMA)) AND LinRegSlope(tma,14) > 0 AND A1 AND A2 AND A3 AND A5 AND A6;
Sell= Cross(MMA,SMA);
Buy = ExRem(Buy,SELL);
Sell = ExRem(Sell,Buy);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorYellow, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorYellow, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeHollowUpArrow, shapeNone),colorBlack, 0,L, Offset=-45);
PlotShapes(Sell*shapeStar,colorDarkRed,0,H,20);
PositionSize = -10;
// BACKGROUND NAME
_SECTION_BEGIN("Name");
GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", Status("pxheight")/8 );
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ColorHSB( 120, 240, 180 ) );
GfxSetBkMode(0); // transparent
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/12 );
GfxSelectFont("Tahoma", Status("pxheight")/18 );

GfxSelectFont("Tahoma", Status("pxheight")/18 );
GfxSelectFont("Tahoma", Status("pxheight")/36 );
GfxTextOut( "FTWHMS - LONG ONLY STRATEGY (HALAN MANOJ KUMAR)", Status("pxwidth")/2, Status("pxheight")/3 );
_SECTION_END();
// BACKTESTING POSITION SIZING
_SECTION_BEGIN("position sizing");
SetOption("InitialEquity", 1000000 );
SetTradeDelays(1,1,1,1);
RoundLotSize = 1;
posqty = Optimize("PosQty", 10, 1, 20, 1 );
PositionScore = TtD_Change + RelStrength("NSENIFTY",True);
SetOption("MaxOpenPositions", posqty);
// desired position size is 100% portfolio equity
// divided by PosQty positions
PositionSize = -100/posqty;
//PositionScore = RelStrength("NSENIFTY",True);
_SECTION_END();
// EXPLORATION
_SECTION_BEGIN("EXPLORATION");
Filter = Buy ;
AddColumn( Buy, "Buy", 1 );
AddColumn( SELL, "SELL", 1 );
AddColumn( c, "entry", 1.3 );
AddColumn( MA(C,30), "STOP",1.3);
NoS = 200000/C;
AddColumn(NoS,"No.Shares",1.3);
AddColumn(RSI(14),"RSI14",1.3);
AddColumn(PositionScore,"MOMENTUM SCORE",1.2,IIf(TtD_Change>0,colorGreen,colorRed));
AddColumn(LastValue(C,True),"cmp",1.3);
AddColumn(IIf(Buy,(LastValue(C,True)-C)*nos, (C-LastValue(C,True))*nos),"profit",1.3);
_SECTION_END();

Comments

Popular posts from this blog

STAN WEINSTEIN'S STRATEGY - Halan Manoj Kumar

// THIS AFL INCORPORATES MOST OF THE CONCEPTS OF STAN WEINSTEINS TRADING METHODOLOGY. // USE ONLY WEEKLY CHART. // THIS AFL DOES NOT GUARANTEE ANY POSITIVE RETURNS. // USE THIS AFL AT YOUR OWN RISK // THIS AFL WAS DEVELOPED BY HALAN MANOJ KUMAR, MSC,CAIIB,FRM,PRM,CMA,ACMA. HOWEVER IN SOME CASES INDIVIDUAL CODE SNIPPETS ARE FROM DIFFERENT SOURCES AND I THANK THOSE DEVELOPERS. // ANY CONCEPTUAL QUERIES OR COMMENTS CAN BE MAILED TO scorpiomanoj73@gmail.com _SECTION_BEGIN("CHART"); SetChartOptions(0,chartShowArrows|chartShowDates); _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%)", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); _SECTION_END(); //RELATIVE STRENGTH // IF YOUR NIFTY TRADING SYMBOL IS DIFFERENT, PLEASE USE THAT INSTEAD OF ONE MENTIONED HERE. rsmaPeriod...

10K AFL FREE INTRADAY TRADING.afl

_SECTION_BEGIN("Price1"); SetChartOptions(0,chartShowArrows|chartShowDates); Plot( C, "Close", ParamColor("Color", colorRed ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); _SECTION_END(); //_SECTION_BEGIN("Pivot")     YH = TimeFrameGetPrice("H", inDaily, -1);        // yesterdays high     YL = TimeFrameGetPrice("L", inDaily, -1);        //                low     YC = TimeFrameGetPrice("C", inDaily, -1);        //                close     YO = TimeFrameGetPrice("O", inDaily);            // current day open     //Normal Pivot     PP = (YH + YL + YC) / 3;     R1 = (2 * PP) - YL;     R2 = PP + (YH - YL); ...

Wilders Most Succesful Intraday Intraday

PM1 = Param("MA1",7.5,1,1500,1); PM2 = Param("MA2",11,1,1500,1); M1 = Wilders(Close,PM1); M2 = Wilders(Close,PM2); A = Cross(M1,M2); B = Cross(M2,M1); Hor1=Param(" LEFT/RIGHT",1,1,1660,1); Ver1=Param(" UP DOWN",35,1,830,1); FS1=Param(" Font Size",15,11,100,1); GfxSelectFont("Tahoma", FS1, 200 ); GfxSetBkColor(colorBlack); GfxSetTextColor(colorGold); //GfxTextOut("EMA "+ PM1 + " "+ Prec(M1,2),Hor1,Ver1); GfxSetTextColor(colorGreen); //GfxTextOut("EMA "+ PM2 + " "+ Prec(M2,2),Hor1,Ver1+25); Plot(M1," EMA: "+pm1,ParamColor("FAST EMA COLOR",colorBrightGreen)); Plot(M2," EMA: "+pm2,ParamColor("SLOW EMA COLOR",colorRed)); PlotShapes(IIf(A,shapeUpArrow,shapeNone),colorBrightGreen,0,L,Offset= -30); PlotShapes(IIf(B,shapeDownArrow,shapeNone),colorRed,0,H,Offset = -30); Filter = (A == 1) OR (B == 1); AddColumn(A,"BUY/SELL",1,IIf(A,colorGreen,c...