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
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;
Short=Sell AND (TimeNum() >= FirstTradeTime AND TimeNum() <= LastTradeTime ); Cover=Buy OR TimeNum() >= ExitAllPositionsTime;
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.
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)
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.