Supertrend Intraday Trading Strategy for High Volatile Scrips

We had already discussed enough about Supertrend Carry forwarding Strategy and this post explores the possibility and the practical difficulties involved in trading a Supertrend Intraday Strategy.

This Supertrend Intraday Strategy is inspired from our Prototype AFL code – Simple EMA Crossover Intraday trading Strategy

Supertrend Intraday Strategy

This strategy will start trade the Supertrend only between 9:15a.m and 3:00:p.m and close any open position by 3:25p.m. The following code defines the time based rules.

FirstTradeTime = 091500;
LastTradeTime = 150000;
ExitAllPositionsTime = 152500;

If you are a MCX Futures trader or trading a different market then the timing values in the AFL code has to be adjusted according to your market. Since it is a intraday strategy i generally prefer to trade in 5min to avoid too many whipsaws. If you are trying with 1min, 2min or 3min charts you might get more whipsaws.

Buy and Sell Rules
1)Initiate Buy if supertrend turns to buy mode(green arrow) and time is greater than FirstTradeTime and less than LastTradeTime

2)Exit the buy (i.e) sell if there is a Sell Signal(Red Arrow) or if time is 3:25p.m(Green Star)

3)Initiate Short if supertrend turns to sell mode(Red arrow) and time is greater than FirstTradeTime and less than LastTradeTime

4)Exit the short (i.e) cover if there is a Buy Signal(Green Arrow) or if time is 3:25p.m(Red Star)

5)First Buy/Short always appear on the first bar of the day. And if Supertrend turns to sell/buy mode after 3.00p.m a trading ban is imposed on the first bar of the day(Signal will not be shown).

Buy = trend==1 AND (TimeNum() >= FirstTradeTime AND TimeNum() <= LastTradeTime );;
Sell=trend==-1 OR TimeNum() >= ExitAllPositionsTime;

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

Short=Sell AND (TimeNum() >= FirstTradeTime AND TimeNum() <= LastTradeTime );
Cover=Buy OR TimeNum() >= ExitAllPositionsTime;

short=ExRem(short,Cover);
Cover=ExRem(cover,short);

And Practically speaking I mostly test my strategies with fixed lotsize initially without any money management principles involved in it. For example : Nifty futures i often test with 2 lots of nifty i,e 100 shares and for Banknifty will test with 2 lots of Banknifty i.e 50 shares This is achieved by the following code

SetPositionSize(100,spsShares); //for Nifty Futures
SetPositionSize(50,spsShares); //for BankNifty Futures

Problem with Continuous Datafeeds
If you are using Continuous datafeeds with symbols like NIFTY-I where the symbol remains the same even after expiry in such cases you will get different results and could misbehave after expiry if there are big premium or deep discount in the next future series and will reflect as gaps in the charts and backtesting such stuff could give you misleading results. To avoid this issue it is always preferable to use non-continuous contract based datafeeds.

Realtime Datafeeders like Globaldatafeeds Support both Non-Continuous and Continuous datafeeds when comes to Strategy based trading non continuous datafeeds are preferable as when the contract expires the symbol expires and non continuous contracts contains the data only corresponding the particular contract. For Example NIFTY14MAYFUT always contains only the Nifty Futures May 2014 contract when the symbol expires you need to shift to next month contract by adding the new symbol NIFTY14JUNFUT which only contains information about June Contracts.

Is this Strategy tested in MCX Futures?
No i dont have enough backtesting data for MCX and so unable to give you clarity on MCX.

Download Supertrend Intraday- Banknifty 5min – Amibroker AFL code.

Performance of Supertrend Intraday Strategy Compared with Supertrend Carry Forward Strategy
1)When comes to the winning ratio Intraday Strategy is slightly higher compared to the carry forward strategy
2)When comes to the risk Intraday Strategy has slightly a lower risk due to no overnight carry forward risk
3)When comes to the Profitability Carry Forward performs a lot better in long run as Intraday Strategy fails to capture the entire length of the trend.

Recommendation
One can try this trading system for Intraday Trading Especially in High Volatile Scripts(For Ex Banknifty).Below insights shows the performance of trading system over 5min charts (BankNifty Spot Since March 2009 till March 2014)

Portfolio Equity
Portfolio Equity

Drawdown Curve

Underwater Equity

Profit Table
Profit Table

Backtest Results for Supertrend Intraday- Banknifty 5min

Remember this is a first version of Supertrend Intraday Strategy. Please highlight any issues with the code needs to be fixed or any additional features needs to be added. If it is worth doing then will add it accordingly. Code suits to run in 5.5+ version onwards. If you havent upgraded to the newer version then please consider upgrading as the new Amibroker has lot more features than the older one.

Note: Dashboard might give your wrong information when there are no signals in the system. It will be fixed in the next upcoming version.

Related Readings and Observations

  • Supertrend Multitimeframe Dashboard Amibroker AFL code This time comingup with Multitimeframe dashboard an addon dashboard for Supertrend indicator with sound and popup alerts. Here are instructions to setup your amibroker with multitimeframe […]
  • How to Plot Bid Vs Ask Dashboard in Amibroker Here is a little Bid Vs Ask Dashboard for Amibroker users which helps to monitor the Bid-Ask Spread during live trading. In a highly liquid market the Bid Ask spread difference will be […]
  • Simple Smoothed RSI Crossover Strategy Here is the simple smoothed RSI crossover strategy can be practiced on higher timeframes especially with daily timeframes with controlled risk. It catches the big trends and gets little […]
  • Intraday Gap Up and Gap Down – Amibroker Strategy Strategy is very simple. when the market open with gap up and at the same time ,it crossed the previous day high then it should be considered as strong buy. When the market open with gap […]

Comments

  1. John says

    Hi Rajendran,

    I have noticed in the trade list that a lot of trades happen at exact time of 9.59.59. Maybe something to be investigated.

    Thanks
    John

    • says

      1)It is said that every day it starts with a signal at the start of first bar. And there will be signal ban in case the previous day has a signal(which will not be displayed) after 3:00p.m.

      2)During 2009 Market Starts at 9:55a.m in the morning. So the first bar on the 5min charts closes at 9:59:59. And the first signal occurs every day at that point

      3)Later market hours shifted to 9:15 so you might see the first signal comes around 9:19:59.

      John, I request you to read the buy and sell section one more time to understand better. Its not a typical supertend carry. forward strategy. Here it involves purely timebased rules along with supertrend.

  2. moorthi says

    sir

    buy signal 3..25 pm position close and next day market open first bar buy continue ok — but

    sell signal 3..25 pm position close and next day market open first bar not genrate sell signal pls help

    • moorthi says

      sir

      Supertrend Intraday Trading strategy will start trade the Supertrend only between 9:15a.m and 3:00:p.m and close any open position by 3:25p.m. The following code defines the time based rules. ok—

      next day continue signal(buy or sell or trend) so genrate 9:15a.m re buy signal -- but not genrate re sell signal ok your unterstand

      thanks

      moorthi

  3. Nehal Suthar says

    i’ve been using Amibroker 5.60 version and while running scan for this AFL, it shows below error.

    Variable ‘entry’ used without having been initialized. (Ln: 445m Col: 102)

    However, it runs back test and also gives report accurately. Please help. Thanks!

    • says

      If some of your stocks in the scan list doesnt has enough data then probably it will throw error. It is advisable to create watchlist and put your favorite stocks over there and then perform scan by applying the watchlist in the filter

  4. moorthi says

    sir

    Supertrend Intraday Trading strategy will start trade the Supertrend only between 9:15a.m and 3:00:p.m and close any open position by 3:25p.m. The following code defines the time based rules. ok—

    next day continue signal(buy or sell or trend) so genrate 9:15a.m re buy signal — but not genrate re sell signal your unterstand

    thanks

    moorthi

    • says

      Moorthi the signal comes at the start 9:15 it doesnt mean that we are continuing the old signal. And the Start symbol Always Represents the Exit Signal.

Leave a Reply

Your email address will not be published. Required fields are marked *