Trading Courses

TRADE LIKE CRAZY - Best Intraday Trading Systems on Banknifty & NIfty 2021.png

Best Intraday Trading Amibroker AFL 2021 | Free Download

Updated: Jan 27

There are millions of Amibroker AFLs are present in the intraday trading community.


But most of the traders only look at ‘Success Ratio’ while developing most of the AFLs.


It is not a good idea. Because a trader can have a 90% success ratio, but still, he can lose money.


Best Intraday Trading Amibroker AFL code FREE Download

For example, Banknifty is trading at 30100. A person will suggest taking a long trade at CMP (at 30100), target 30200, and stop-loss 29000.


Do you know what will be the outcome of this trade?


On most days, these kinds of trades are winners because we are risking 1100 points for a profit of just 100 points!


One loss can wipe out the profits from 10 trades. Hence, day traders, along with ‘Success Ratio,’ should always look at another parameter, ‘Risk-Reward.’


Popular Topics


Now assume we have a good trading system – Success ratio of 60%, Risk-reward of 1-2.

It means out of 100 trades, 60 trades are winners, and 40 trades are losers. In addition, if we risk 10K per trade, winning trades made a profit of 20K (RR or 1-2).


So all looks good on paper, right?


An intraday trader starts to use the above trading strategy and deploys 10 Lakh capital for this system.


After some trades, his portfolio reduces to 7 lakh (30% erosion). Do you think he will keep the same emotional stability to take trades using the same trading strategy?

Definitely, the answer is a big NO!

In the above case, if the maximum drawdown is only 10% (means capital erosion only up to 9 lakh), then the same trader is in a better condition to take the trades using the same trading concept.


Image 1 – Parameters to measure a trading strategy
Image 1 – Parameters to measure a trading strategy

Hence, three parameters are essential to measuring the performance of a trading system.

  1. Success Ratio

  2. Risk-Reward

  3. Maximum Drawdown

In this article, I will explain an intraday trading strategy for Banknifty.


Besides, I will also provide all the statistics (including success ratio, risk-reward, and maximum drawdown parameters).

However, an explanation of two crucial concepts is necessary before giving the trading strategy.




Day Structures in Banknifty


Market Profile identifies a few readable patterns in the daily time frame based on the level of participation of big players.

IB Range is the first one-hour range in the market after the market open. Based on IB range and price variation around IB range, Market Profile identifies six important day structures:

  1. Normal Day

  2. Normal Variation Day

  3. Trend Day

  4. Double Distribution Day

  5. Non-Trend Day

  6. Neutral Day

We will discuss only ‘Normal Variation Day’ as part of the Banknifty trading strategy.


(Please read ‘Intraday Trading using Market Profile’ if you want to know more about day structures)

Normal Variation Day


Image 2 – Normal Variation Day in Banknifty
Image 2 – Normal Variation Day in Banknifty

On Normal Variation Day, the IB range (1-hour range) will be medium.

The price will move outside of the IB range in any direction (either up or down).


This movement of price outside of the IB range (range extension) generally will be equal to the length of the price range in the IB.


For example, if the IB range is 150 points, the price will move outside IB approximately 150 points.


Normal Variation Day occurs because big players don’t participate in the open.


They will watch the market for some time, and then they enter after the formation of the IB range to create a range extension on any one side of the IB.

Out of 100 trading days in bank nifty, 70 days will be normal variation days. Hence, if we have a trading strategy to trade normal variation days, we get more trades.


Also Read: A Detailed Guide on Options Trading Strategies for Indian Market



Opening Range Breakout (ORB) Concept

TOBY CRABLE develops ORB Strategy, and it is one of the widely used trading strategies among day traders.


It is based on the concept “Amateurs open the market and professionals close the market.”


Image 3 – Opening Range Breakout (ORB) Trading Concept
Image 3 – Opening Range Breakout (ORB) Trading Concept

As per the ORB strategy, traders take the trade in the direction of the breakout of the IB range (1-hour range).


If the price breaks the IB high (1-hour high), they go for a long trade, and if the price breaks the IB low (1-hour low), they go for a short trade.


However, it has a flaw, and traders will get terrible results if they use it as it is. I will explain with the help of charts.


Image 4 – Failure of ORB Concept in Banknifty (example-1)
Image 4 – Failure of ORB Concept in Banknifty (example-1)

Image 5 – Failure of ORB Concept in Banknifty (example-2)
Image 5 – Failure of ORB Concept in Banknifty (example-2)

If we look at image-4 and image-5, it is evident that the ORB concept failed transparently.

In image-4, the price traded above the IB range for some time. If a trader opts for a long trade, then the price will hit his stop-loss. Besides, he will also miss a good short trade.

The same issue occurred in image-5 but in the opposite direction.


Hence we should have a filter to eliminate these failures to increase the success rate and to avoid losing money for these false breakouts.

Hence, the below filter is helpful to pick only the successful trades (higher probability) and avoid failures.


Image 6 – Filter for ORB Trading System in 15-min timeframe
Image 6 – Filter for ORB Trading System in 15-min timeframe

Take 15-min timeframe chart of Banknifty.

When the ‘wick’ of the breakout candle (which breaks IB High) is more than 20% of the entire body, then it is better to avoid the long trade as there is a high probability of false breakout.

For example, if the high of the breakout candle is 35100, the low is 35000, then the close of the candle should be above 35080 (for 20% of the wick) to opt for a long trade.


Entry – Above the high of the breakout candle

Stop-loss – Below the low of the breakout candle

Exit – Target IB range points or EOD close

Trail SL – Once the price moves equal points of risk in the expected direction, then trail SL to the entry price (means if the entry is 35100, SL is 35000, if the price moves to 35200, then trail SL to 35100).


The same rules can be applied for the breakdown candle of the IB low to opt for short trades.


Also Read: Top-10 Trading Books



Backtesting Results

The backtesting results for Normal Variation Day + ORB Concept + 20% Filter looks like below (6 years – from 2014 to 2020).


Image 7– Equity Curve
Image 7– Equity Curve
Image 8 – Underwater Equity (Maximum Drawdown)
Image 8 – Underwater Equity (Maximum Drawdown)
Image 9 – Backtesting Statistics
Image 9 – Backtesting Statistics

Images 7, 8, and 9 display different aspects of the backtesting report.

The equity curve is smooth, and it has grown linearly from 5 lakh capital to 8.64 lakh.


The maximum drawdown is only 6.2% which indicates emotional stress level is less to execute this strategy.

Any positive profit factor indicates that the trading strategy will yield profits.


System traders happily accept any trading system with a profit factor of 1.2 and above.


This trading strategy has generated a profit factor of 1.33, which indicates the efficiency of the system.


The only drawback of the system is the total number of trades per year. It has generated only 1008 trades for 5 years. So it means around 202 trades per year or 7 trades in a month.


However, an intraday trader can quickly negate this drawback by applying the same trading strategy in multiple instruments like Nifty, Finnifty, or other major trading stocks.


If a trader observes 4-5 instruments, there is a higher probability of getting 1-2 trades every day.




Amibroker AFL Code


Below is the AFL code for the above-mentioned strategy. The download link is given at the end.

 

_SECTION_BEGIN("Price");

SetChartOptions(0,chartShowArrows|chartShowDates);

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

_SECTION_END();


//ORB


_SECTION_BEGIN("ORB");


newday = Day() != Ref(Day(),-1) ; //Identifies the beginning of new day


DH = HighestSince(newday,H) ; // returns the highest High of the day till new day

DL = LowestSince(newday,L) ; //returns the lowest low of the day till newday


IBH = ValueWhen((TimeNum() == 101500),TimeFrameGetPrice( "H", inHourly, -1)) ;

IBL = ValueWhen((TimeNum() == 101500),TimeFrameGetPrice( "L", inHourly, -1)) ;


Plot(IBL,"IBL,",colorRed);

Plot(IBH,"IBH",colorGreen);


//Timing functions


//Entry time should be greater than 10:15 and 2:30 PM

Starttime = TimeNum() > 101500 ;

endtime = TimeNum() < 143000 ;

EODsquareoff = TimeNum() == 151500 ;


//Define the strategy rules


//wickpercent = Optimize("WickPercent",0.15,0.05,0.4,0.05);

wickpercent = 0.2;

SmallBuyWick = False OR ((C-L) < ((H-L)*wickpercent));

SmallSellWick = False OR ((H-C) < ((H-L)*wickpercent));

Buy = Ref(C,-1) > Ref(IBH,-1) AND starttime AND endtime AND Ref(SmallSellWick,-1);

Short = Ref(C,-1) < Ref(IBL,-1) AND starttime AND endtime AND Ref(SmallBuyWick,-1);

Buy = ExRem(Buy,newday);

Short = ExRem(Short,newday);


BuyPrice = ValueWhen(Buy,Ref(H,-1));

ShortPrice = ValueWhen(Short,Ref(L,-1));


//BuySL = ValueWhen(Buy,Ref(L,-1));

//ShortSL = ValueWhen(Short,Ref(H,-1));

SLprc = Optimize("SLprc",0.01,0.001,0.02,0.001);

BuySL = BuyPrice * (1 - SLprc);

ShortSL = ShortPrice * (1 + SLprc);


Sell = (L < BuySL) OR EODsquareoff ;

Sell = ExRem(Sell,Buy);

Cover = (H > ShortSL) OR EODsquareoff ;

Cover = ExRem(Cover,Short);


//Buy = ExRem(Buy,sell);

//Short = ExRem(Short,Cover);

//Sell = ExRem(Sell,Buy);

//Cover = ExRem(Cover,Short);


Plot(Ref(BuySL,1),"BuySL",colorWhite);

Plot(Ref(ShortSL,1),"ShortSL",colorYellow);


SellPrice = IIf(EODsquareoff,C,BuySL);

CoverPrice = IIf(EODsquareoff,C,ShortSL);


SetPositionSize(25,spsShares);


PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorBlue, 0, L, Offset=-40);

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorBlue, 0,L, Offset=-50);

PlotShapes(IIf(Buy, shapeHollowUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);

PlotShapes(IIf(Short, shapeSquare, shapeNone),colorYellow, 0, H, Offset=40);

PlotShapes(IIf(Short, shapeSquare, shapeNone),colorYellow, 0,H, Offset=50);

PlotShapes(IIf(Short, shapeHollowDownArrow, shapeNone),colorRed, 0,H, Offset=-45);


PlotShapes(IIf(sell, shapeStar, shapeNone),colorred, 0, H, 20);

PlotShapes(IIf(Cover, shapeStar, shapeNone),colorBlue, 0, L, -20);


 

Download the code by clicking here.


Best Intraday Trading Amirboker AFL code
.
Download • 3KB


Get the Mini Trading Guide


A 5-day email course with amazing tips on trading, different trading instruments, and how to finalize a trading system. Get a best-selling eBook and online course by signing up for free.