All indicators

Supertrend Strategy

Dec 30, 2021

Static chart image
Support and ResistanceVolume BasedSignalsTime BasedMoving AveragesVolatility

The Supertrend Strategy tool provides a comprehensive framework for backtesting and executing trades based on trend reversals identified by the Supertrend indicator.

Usage

The script is designed to automate long and short entries when the Supertrend shifts direction. Users can apply this strategy to various asset classes by adjusting the ATR parameters to fit specific volatility profiles.

Examples of usage include:

  • Trend Following: Enter long when the Supertrend turns bullish and short when it turns bearish.
  • Intraday Trading: Use the time restriction settings to limit trading to specific sessions (e.g., New York Open) and automatically close positions before the market close.
  • Filtered Entries: Combine the Supertrend signals with the built-in EMA or Chaikin Money Flow (CMF) filters to ensure trades are taken only in the direction of the broader trend or when volume flow is supportive.

Details

The strategy utilizes the Average True Range (ATR) to calculate dynamic support and resistance levels. When the price crosses these levels, a trend change is triggered.

  • ATR Calculation: Users can toggle between the standard ATR calculation and an SMA-based ATR, which can smooth out noise on more volatile assets.
  • Entry Logic: The "Enter Supertrend ASAP" setting allows the strategy to join an existing trend immediately upon the start of a session, while "Wait To Enter" requires a fresh signal.
  • Contrarian Mode: A unique toggle allows for contrarian trading, where signals are reversed (shorting bullish flips and vice versa), which can be useful in ranging markets.

Settings

Backtesting & Time

  • Backtesting Start/End Date: Defines the historical range for the strategy simulation.
  • Time Frame To Enter/Exit Trades: Restricts trading activity to specific hours of the day.
  • Enable Close Trade At End: Force closes all open positions at the end of the specified exit time frame.

Supertrend Settings

  • ATR Period: The lookback period used for the ATR calculation.
  • ATR Multiplier: The coefficient that determines the distance of the stop level from the price.
  • Change ATR Calculation Method: Toggles between standard ATR and SMA-based TR calculation.

Filters

  • EMA Filter: When enabled, long trades are only permitted if the price is above the specified EMA, and shorts if below.
  • CMF Filter: Filters signals based on Chaikin Money Flow; longs require CMF > 0, while shorts require CMF < 0.

Risk Management

  • Enable Stop Loss & Take Profit: Activates percentage-based exit targets.
  • Stop Loss %: The percentage distance for the hard stop loss.
  • Take Profit %: The percentage distance for the take profit target.

FAQ

How do I use this for automated trading? You can use the "Alert Messages" section to define custom JSON or text payloads. Use the {{strategy.order.alert_message}} placeholder in the TradingView alert dialogue to dynamically send these messages to your execution bridge.

Can I use this as a standalone indicator without the strategy backtesting? While this version is a strategy, the visual plots allow you to see the Supertrend levels and filters on your chart for manual trading.

How do I access Supertrend Strategy? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.