com
AFL of the week: Support Resistance based Trading System
2016-02-20 16:02:48 admin
This is a breakout strategy where buy/sell signal is generated when price crosses a dynamic support/resistance. The calculation of support/resistance is based on highest
high value and lowest low value for a particular lookback period. This strategy seems to work well in Trending markets.
Read our article on AFL tutorial here.
AFL Overview
Paramter
Value
None
Buy Condition
Sell Condition
Stop Loss
2%
Targets
No fixed target, Stop and reverse when AFL gives opposite signal
Position Size
150 (fixed)
Initial Equity
200000
Brokerage
50 per order
Margin
10%
AFL Code
//-----------------------------------------------------//
// Formula Name:
Support Resistance based Trading System
// Author/Uploader: Trading Tuitions
// E-mail:
support@tradingtuitions.com
// Website:
www.tradingtuitions.com
//------------------_SECTION_BEGIN("Dynamic Support Resistance");
SetTradeDelays( 1, 1, 1, 1 );
SetOption( "InitialEquity", 200000);
SetOption("FuturesMode" ,True);
SetOption("MinShares",1);
SetOption("CommissionMode",2);
SetOption("CommissionAmount",50);
SetOption("AccountMargin",10);
SetOption("RefreshWhenCompleted",True);
SetPositionSize(150,spsShares);
SetOption( "AllowPositionShrinking", True );
BuyPrice=Open;
SellPrice=Open;
ShortPrice=Open;
CoverPrice=Open;
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C ));
Plot( Close, "Price", colorWhite, styleCandle );
period=Optimize("Swing",3,1,25,1);
res=HHV(H,period); //resistance
sup=LLV(L,period); //support
DynamicPivot=IIf(ValueWhen(IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0))!=0,IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0)),1)==1,sup,r
//If current close breaks the resistance then dynamic pivot level would be last support, if close breaks the support then dynamic p
Plot(DynamicPivot, "DynamicPivot", colorBlue, styleStaircase);
Buy = Cross(C,DynamicPivot) ;
Sell = Cross(DynamicPivot,C) ;
Short = Sell;
Cover = Buy;
StopLoss=2;
ApplyStop(Type=0,Mode=1,Amount=StopLoss);
/* Plot Buy and Sell Signal Arrows */
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
_SECTION_END();
AFL Screenshot
Backtest Report
Paramter
Value
NSE Nifty
Initial Capital
200000
Final Capital
1275626.60
Backtest Period
01-Jan-2007 to 19-02-2016
Timeframe
Daily
Net Profit %
537.81%
Annual Return %
22.48%
Number of Trades
243
Winning Trade %
41.56%
8.93 periods
-28.78%
-60.73%
Equity Curve
Disclaimer:
All the AFLs posted in this section are for learning purpose. Trading Tuitions does not necessarily own these AFLs and we dont have any intellectual property rights on
them. We might copy useful AFLs from public forums and post it in this section in a presentable format. The intent is not to copy anybodys work but to share knowledge. If
you find any misleading or non-reproducible content then please inform us at support@tradingtuitions.com
Liked this article? Please spare few seconds to share it. Share on FacebookShare on TwitterShare on Google+Share on Linkedin
Related