Supertrend with a simple EMA Filter can improve the performance of the signals during a strong trending market and reduces the number of trades as well which in turn reduces the trading cost + unwanted losing trades. i.e overall drawdown reduces and improves the sharp ratio compared to the regular supertrend long/short signals.
Strategy Rules
Buy – if candle closes above supertrend and price above 200 EMA on closing basis
Exit Buy – if price of the candle closes below supertrend.
Strategy Parameters
EMA Filter used: 200 EMA
Strategy Type: Long Only
Recommended Timeframe: 15min
Symbol Backtested: Nifty Futures
Backtesting Period : Jan 2017 – 29th Nov 2022 – Till to date
Supertrend Default Parameters: Multiplier- 3 and ATR Length – 10
Optimization : No
Position Size : 1 lot (50 shares)
Supertrend V4.0 – Nifty Futures 15min Charts
During the sideways markets, it behaves like supertrend, creating noisy signals. However, the overall performance of the super trend improves with reduced drawdown
Equity Curve per lot
Absolute Drawdown per lot
Backtesting Metrics
Tradingview Pinescript Code – Supertrend V4.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © algostudio
// Coded by Rajandran R (Founder - Marketcalls and Creator - OpenAlgo)
//@version=5
strategy("Supertrend with EMA as Filter", overlay=true)
//input controls
factor = input.float(2,"Factor",1.0,10.0,0.5)
length = input.int(10,"ATR Length",1,100,1)
[supertrend,direction] = ta.supertrend(factor,length)
ema200 = ta.ema(close,200)
plot(ema200,"EMA 200",color.yellow,linewidth = 2)
//direction variables contains series of +1 and -1
//supertrend variable contains the supertrend line
longEntry = direction == -1 and close > ema200
longExit = direction == 1 and direction[1] == -1
shortEntry = direction == 1 and close < ema200
shortExit = direction == -1 and direction[1] == 1
supcolor = direction == -1 ? color.green : color.red
plot(supertrend,"Supertrend",supcolor,linewidth = 2)
if(longEntry)
strategy.entry("BUY",strategy.long,comment="BUY")
if(longExit)
strategy.close("BUY",comment="BUY EXIT")
// if(shortEntry)
// strategy.entry("SHORT",strategy.short,comment="SHORT")
// if(shortExit)
// strategy.close("SHORT",comment="SHORT EXIT")
I have downloaded the nakshatra system for nifty and modified it. It is giving vey good calmar ratio for 6 months but the problem is i don’t have reliable data source for historical data. It would be great if you would share your data with us as you have shared many code. If it is not possible to share your data, please share the nakshatra system for tradingview where we can buy the data and test the code also. Thanks.
Hello sir can you share short entry signal with same parameters