// 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.
rsmaPeriodshort = Param( "RS Short MA Period", 30, 0, 500, 1 );
rsmaPeriodlong = Param( "RS Long MA Period", 90, 0, 500, 1 );
rsSymbol = ParamStr( "Base Index Symbol", "NSENIFTY" ); //Use Index Symbol Which You have at place of NSENIFTY
rs = RelStrength( rsSymbol );
// MOMENTUM
// THIS IS USED ONLY FOR SCORING DURING EXPLORATION. IT IS NOT PART OF THE BUY SELL CONDITIONS.
_SECTION_BEGIN("MOMENTUM");
TtD_Change = 100 * (Close - Ref(Close, -12) ) / Ref(Close, -12);
_SECTION_END();
// PRICE
cmaperiod1 = Param( "Price MA Period1", 10, 0, 500, 1 );
TMA = MA(C,CMAPERIOD1);
Plot(TMA ,"SMA10WK",colorGreen,styleLine);
cmaperiod2 = Param( "Price MA Period2", 29, 0, 500, 1 );
sTMA = MA(C,cmaperiod2);
Plot(sTMA ,"SMA29WK",colorBrown,styleLine);
//cmaperiod3 = Param( "Price MA Period3", 40, 0, 500, 1 );
//LTMA = MA(C,cmaperiod3);
//Plot(lTMA,"SMA40WK",colorBlueGrey,styleLine);
// VOLUME
VOLshort = Param( "VOL Short MA Period", 30, 0, 500, 1 );
VOLlong = Param( "VOL Long MA Period", 90, 0, 500, 1 );
//CONDITIONS
RSB = MA(rs,rsmaperiodshort) > MA(rs,rsmaperiodlong) OR RS > MA(RS,RSMAPERIODLONG);
vola = V > 2 * MA(V,4) OR V > 5 * Ref(V,-1);
VOLb = Cross(V,MA(V,volshort)) OR V > MA(V,VOLSHORT);
COND1 = (Cross (C,STMA) OR C > STMA) AND C > TMA AND TMA > STMA;
COND2 = VOLA;
COND3 = RS > MA(RS,RSMAPERIODSHORT);
COND5 = C > 5;
COND6 = C > (Ref(HHV(H,52),-1));
// buy if price crosses 30wk ma or price is greater than 30 wk ma (stan weinstein's theory)
// and if vol is greater than 2 times of 4 period ma or vol is greater than 5 times the prev period (stan weinsteins general theory of vol increase. numbers are based on my experience)
// and if relative strength with respect to index is greater than 30 period ma (stan weinsteins theory of upward sloping rel strength)
// and stocks greater than rs 5 (can increase if do not want penny stocks)
// and price is greater than 52 wks high (not stan weinsteins requirement. i have added based on my experience)
// ALL ABOVE BUY CONDITIONS IDEALLY ENSURES IN MOST CASES THAT YOU ARE ENTERING IN STAGE 2
// sell if price crosses down 30 wk ma (stan weinstein's theory)
// SELL CONDITION IDEALLY ENSURES IN MOST CASES THAT YOU ARE EXITING A STOCK IN BEGINING OF STAGE 4.
Buy = COND1 AND COND2 AND COND3 AND COND5 AND COND6 AND C>O;
Sell= Cross(sTMA,H);
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);
// 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( " STAN WEINSTEIN'S STRATEGY - Halan Manoj Kumar", Status("pxwidth")/2, Status("pxheight")/3 );
_SECTION_END();
_SECTION_BEGIN("position sizing");
SetOption("InitialEquity", 1000000 );
SetTradeDelays(0,0,0,0);
RoundLotSize = 1;
posqty = Optimize("PosQty", 10, 1, 20, 1 );
SetOption("MaxOpenPositions", posqty);
PositionSize = -100/POSQTY;
PositionScore = rs*100/MA(rs,rsmaperiodshort); // ENSURES YOU ENTER ONLY THOSE STOCKS WHICH HAVE HIGH RELATIVE STRENGTH IF YOU HAVE MULTIPLE BUYS.
_SECTION_END();
_SECTION_BEGIN("EXPLORATION");
Filter = Buy ;
AddColumn( Buy, "Buy", 1 );
AddColumn( V*100 / MA(V,4), "V/MAVOL", 1 );
AddColumn( rs*100/MA(rs,rsmaperiodshort) , "RS / MARS", 1 );
AddColumn(TtD_Change,"MOMENTUM SCORE",1.2,IIf(TtD_Change>0,colorDarkBlue,colorRed));
AddColumn( (V*100 / MA(V,4)) + (rs*100/MA(rs,rsmaperiodshort)) + Ttd_Change, "V + RS + MS", 1 );
AddColumn( c, "entry", 1.3 );
NoS = 100000/C;
AddColumn(NoS,"No.Shares",1.3);
AddColumn(LastValue(C,True),"cmp",1.3);
AddColumn(IIf(Buy,(LastValue(C,True)-C)*nos, (C-LastValue(C,True))*nos),"profit",1.3);
AddColumn(MA(C,30),"STOP",1.3);
_SECTION_END();
// 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.
rsmaPeriodshort = Param( "RS Short MA Period", 30, 0, 500, 1 );
rsmaPeriodlong = Param( "RS Long MA Period", 90, 0, 500, 1 );
rsSymbol = ParamStr( "Base Index Symbol", "NSENIFTY" ); //Use Index Symbol Which You have at place of NSENIFTY
rs = RelStrength( rsSymbol );
// MOMENTUM
// THIS IS USED ONLY FOR SCORING DURING EXPLORATION. IT IS NOT PART OF THE BUY SELL CONDITIONS.
_SECTION_BEGIN("MOMENTUM");
TtD_Change = 100 * (Close - Ref(Close, -12) ) / Ref(Close, -12);
_SECTION_END();
// PRICE
cmaperiod1 = Param( "Price MA Period1", 10, 0, 500, 1 );
TMA = MA(C,CMAPERIOD1);
Plot(TMA ,"SMA10WK",colorGreen,styleLine);
cmaperiod2 = Param( "Price MA Period2", 29, 0, 500, 1 );
sTMA = MA(C,cmaperiod2);
Plot(sTMA ,"SMA29WK",colorBrown,styleLine);
//cmaperiod3 = Param( "Price MA Period3", 40, 0, 500, 1 );
//LTMA = MA(C,cmaperiod3);
//Plot(lTMA,"SMA40WK",colorBlueGrey,styleLine);
// VOLUME
VOLshort = Param( "VOL Short MA Period", 30, 0, 500, 1 );
VOLlong = Param( "VOL Long MA Period", 90, 0, 500, 1 );
//CONDITIONS
RSB = MA(rs,rsmaperiodshort) > MA(rs,rsmaperiodlong) OR RS > MA(RS,RSMAPERIODLONG);
vola = V > 2 * MA(V,4) OR V > 5 * Ref(V,-1);
VOLb = Cross(V,MA(V,volshort)) OR V > MA(V,VOLSHORT);
COND1 = (Cross (C,STMA) OR C > STMA) AND C > TMA AND TMA > STMA;
COND2 = VOLA;
COND3 = RS > MA(RS,RSMAPERIODSHORT);
COND5 = C > 5;
COND6 = C > (Ref(HHV(H,52),-1));
// buy if price crosses 30wk ma or price is greater than 30 wk ma (stan weinstein's theory)
// and if vol is greater than 2 times of 4 period ma or vol is greater than 5 times the prev period (stan weinsteins general theory of vol increase. numbers are based on my experience)
// and if relative strength with respect to index is greater than 30 period ma (stan weinsteins theory of upward sloping rel strength)
// and stocks greater than rs 5 (can increase if do not want penny stocks)
// and price is greater than 52 wks high (not stan weinsteins requirement. i have added based on my experience)
// ALL ABOVE BUY CONDITIONS IDEALLY ENSURES IN MOST CASES THAT YOU ARE ENTERING IN STAGE 2
// sell if price crosses down 30 wk ma (stan weinstein's theory)
// SELL CONDITION IDEALLY ENSURES IN MOST CASES THAT YOU ARE EXITING A STOCK IN BEGINING OF STAGE 4.
Buy = COND1 AND COND2 AND COND3 AND COND5 AND COND6 AND C>O;
Sell= Cross(sTMA,H);
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);
// 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( " STAN WEINSTEIN'S STRATEGY - Halan Manoj Kumar", Status("pxwidth")/2, Status("pxheight")/3 );
_SECTION_END();
_SECTION_BEGIN("position sizing");
SetOption("InitialEquity", 1000000 );
SetTradeDelays(0,0,0,0);
RoundLotSize = 1;
posqty = Optimize("PosQty", 10, 1, 20, 1 );
SetOption("MaxOpenPositions", posqty);
PositionSize = -100/POSQTY;
PositionScore = rs*100/MA(rs,rsmaperiodshort); // ENSURES YOU ENTER ONLY THOSE STOCKS WHICH HAVE HIGH RELATIVE STRENGTH IF YOU HAVE MULTIPLE BUYS.
_SECTION_END();
_SECTION_BEGIN("EXPLORATION");
Filter = Buy ;
AddColumn( Buy, "Buy", 1 );
AddColumn( V*100 / MA(V,4), "V/MAVOL", 1 );
AddColumn( rs*100/MA(rs,rsmaperiodshort) , "RS / MARS", 1 );
AddColumn(TtD_Change,"MOMENTUM SCORE",1.2,IIf(TtD_Change>0,colorDarkBlue,colorRed));
AddColumn( (V*100 / MA(V,4)) + (rs*100/MA(rs,rsmaperiodshort)) + Ttd_Change, "V + RS + MS", 1 );
AddColumn( c, "entry", 1.3 );
NoS = 100000/C;
AddColumn(NoS,"No.Shares",1.3);
AddColumn(LastValue(C,True),"cmp",1.3);
AddColumn(IIf(Buy,(LastValue(C,True)-C)*nos, (C-LastValue(C,True))*nos),"profit",1.3);
AddColumn(MA(C,30),"STOP",1.3);
_SECTION_END();
Comments
Post a Comment