Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in)

Supertrend Intraday Trading Strategy for High Volatile Scrips

2 min read

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

[wp_ad_camp_5]

 
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.

Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in)

[Live Coding Webinar] Build Your First Trading Bridge for…

In this course, you will be learning to build your own trading bridge using Python. This 60-minute session is perfect for traders, Python enthusiasts,...
Rajandran R
1 min read

[Webinar] Understanding and Mitigating Curve Fitting in System Trading

"Understanding and Mitigating Curve Fitting in System Trading"! This dynamic session aims to equip novice to intermediate traders, quantitative analysts, and financial engineers with...
Rajandran R
1 min read

P-Signal Strategy Long Only Strategy – Amibroker AFL Code

This tutorial provides an overview of the P-Signal reversal strategy, a quantitative trading strategy that utilizes statistical parameters and error functions to generate probabilistic...
Rajandran R
2 min read

33 Replies to “Supertrend Intraday Trading Strategy for High Volatile Scrips”

  1. 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

    1. 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. 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

  3. Hi, i cant understand what you mean by first trade time and last trade time.? Please explain

    1. 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

  4. 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!

    1. 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

  5. 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

    1. 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.

      1. Sir, at the time of 3.25 P.M. we close morning buy position with green signal continue and then next day first bar also starts with green line then we will have to regenerate buy position too. or to be wait for new signal during the day.
        Thanks.
        Dhrumil Patel

  6. Hi Rajendar Sir,
    Your work is excellent to the new traders who use the AFL , What time timeframe best suits this strategy.

  7. Can you send me working Supertrend System Strategy to backtest with my own data on amibroker 5.6 because script on this webpage doesn’t work for me. Thank you.

  8. Thanks indeed for such stupendous effort.

    Like to draw attention to one small aspect. Sometimes when there was Buy Signal yesterday and same signal current day, dashboard doesn’t update Entry Point with the new entry level of current day.

    Please check Bank Nifty on 25th Nov and 26th Nov 2014. On 26th Nov there is a fresh Sell signal, but dashboard shows “SELL @” of the signal from day before.

  9. sir,
    this is my first mail to you.i am not yet member but observing your website and specially your supertrend
    afl code strtegy . actually i am trading on it. and also i want to subscribe for this,but i have following quiries

    1) for nifty which is better carry forward or intraday strategy
    2)for bank nifty again same question ?
    3)i have observed sometimes we get profit before making loss ,so can buy 2 lots each and sell one lot at
    some points of profit
    4)also can i get a daywise performance report for carry or for intraday
    5)since your strike rate is around 45%can i get average per trade profitability and loss,so we can understand it more better
    6)also sir,i have observed that after continous 3 loss chances of profit increses

    i had taken various call provider famous personalities in india but sadly nothing works,so i decided to trade on my own from last 4 months by creating own startegy and frankly it atleast it stop my heavy loss in first place,
    i can trade intrady or carry forward or positional
    please guide me

    bhushan kale . pune maharashtra

  10. Dear Sir,

    Greetings of the day from Ashish Kothari

    I need your help in Amibroker AFL Coding…

    As in intra-day trading startegy , we have FirstTradeTime , LastTradeTime, and ExitAllPositionsTime , Can we have something same and on similar lines for Intra-Contract Trading Strategy for MCX Gold

    In case of MCX Gold, the contract opens at 10:00 AM on the first trading day of the EVEN Month (Dec , Feb , April , June etc etc ) and the contract closes at 11:30 PM or 11:55PM on the last trading day of the ODD Month (Jan , March , May , July )

    Basically , I want all my positions (positional trades) to be opened and closed automatically within the same contract.

    One more important thing , Here the first trading day of the contract might not be necessarily the 1st date of the EVEN month…..the first trading day of the contract might even be the 2nd date or 3rd date or 4th date of the EVEN month (depending on saturdays and sundays)

    Similarly , the last trading day of contract might not be necessarily the 31st date of the ODD month…..the last trading day of the contract might even be the 29th date or 30th date or 31st date of the EVEN month (depending on saturdays and sundays)

    I want to close all the open positions at 11:15pm on the last trading day of the contract

    The above-said AFL coding should help me a lot in my back-testing and study purposes

    Kindly suggest / advice

    Thanks & Regards

    Ashish Kothari
    +91-98812-32295

  11. i need to plot weekly and monthly RSI on Daily charts in Metasock and Amibroker. Can u guide.

  12. Hello ,
    Can i use Suptrend Indicator in Mt4 … 5 min. Time frame in Crude Oil..
    Any suggestion for commodity trade with super trend ..

    Pleas reply ..

    Thank you

  13. hi ,
    very good one
    i m totally new in this realm
    please let me know more about super trend or provide any sight from where i can read more

  14. Hi Rajandran

    While back testing I am getting error. on line 453 “Variable entry used without having been initialized”. Please help to resolve this issue.

  15. Hi Mr Rajandran

    Read the article above and it was very informative.

    Can I use the Supertrend software to trade on a daily or weekly chart setting, for the NSE shares?

    If so where might I be able to purchase or download the software.

    Tks n rgds
    Mathews

      1. Dear Mr Rajandran

        Thank you and appreciate your prompt reply.
        I will look at the above info.

        Regards
        Mathews

  16. highly informative and useful article
    Please suggest for swing trading, how to set Super Trend.
    Is it good st 10,2 on 30 minutes?

  17. Hi Rajandran,

    Firstly, let me Thank you as your AFL codes & videos are being very helpful in learning the same. I have learnt so many things from your teaching, but having a basic problem while using multi time frame super trend.

    Problem: I want to use a hourly super trend on a 5min intraday chart where buy and sell will get triggered when 5 min closing price crosses hourly Supertrend SL. But, I am not being able to code this one. In fact, I want to use the above code where suprtrend is being used in another time frame (say hourly supertrend in 5 mins chart). Can you please tell us where should we do the tweak?

    Regrds,
    Prady

  18. Rajaendran

    How I can check daily movements, supertrend signals on your blog with real ttime
    Can u guide me

  19. can lintra trading system can be used on amibroker.i have global data feed suscription.do you have any fecility to teach various aspects of amibroker online using any desk or team viewer.

Leave a Reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More