Join our facebook group for Amibroker afl code discussion https://www.facebook.com/groups/603980776889348

Support Resistance Based Trading System


How to use Support Resistance Based Trading System Amibroker afl?

Support Resistance Based Trading System is one of the most reliable trading system. It generates accurate signals most of the times. Support Resistance Based Trading System correctly identifies beginning of the new trend and gives buy or sell signals accordingly. Support Resistance Based Trading System can be used in any timeframe but it works perfectly in daily time frame. Support Resistance Based Trading System is very useful for swing trading or short term trading. Support Resistance Based Trading System afl can be used with any lagging indicator like RSI, MACD, Stochastic to avoid false signals.
Support Resistance Based Trading System
Support Resistance Based Trading System

//www.aflcode.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,res); 
//If current close breaks the resistance then dynamic pivot level would be last support, if close breaks the support then dynamic pivot level will be last resistance
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();

Previous
Next Post »

1 Comments:

Write Comments
Unknown
AUTHOR
August 9, 2020 at 1:21 PM delete

The strategy is tested on Nifty August Future hourly time frame and if used only to go long and exit, it gives very good results but on short side it not good. Please let me know if this can be used only for buy and exit?

Reply
avatar