The Momentum Tracking and Trend Strategy

Author: ChaoZhang, Date: 2024-02-22 17:27:18



The core idea of this strategy is to combine the Super Trend indicator and the Average Directional Movement Index (ADX) to judge and track trends. The Super Trend indicator is used to identify the current price trend direction, and the ADX is used to determine the trend strength. Trades are only made under strong trend conditions. In addition, the strategy also uses candlestick body color, trading volume and other indicators for confirmation, forming a relatively complete set of trading rules.

Overall, this strategy belongs to the trend tracking strategy, aiming to capture medium and long term clear trends while avoiding interference from consolidation and oscillation periods.

Strategy Principles

  1. Use the Super Trend indicator to determine the price trend direction. When the price stands above the Super Trend it is a long signal, and when it stands below the Super Trend it is a short signal.

  2. Use the ADX to judge the strength of the trend. Trading signals are generated only when the ADX is greater than the threshold, so that periods with unclear consolidation can be filtered out.

  3. The candlestick body color is used to judge whether it is currently in an upward or downward pattern, combined with the Super Trend indicator to form confirmation.

  4. Expanding trading volume serves as a confirmation signal. Positions are only established when trading volume rises.

  5. Set stop loss and take profit to lock in profits and control risks.

  6. Close all positions before the set end of day time.

Advantages of the Strategy

  1. Track medium and long term clear trends, avoid oscillation, and achieve high profitability.

  2. The strategy has few parameters and is easy to understand and implement.

  3. Risks are well controlled with stop loss and take profit in place.

  4. The use of multiple indicators for confirmation can reduce false signals.

Risks of the Strategy

  1. May suffer large losses during major market-wide corrections.

  2. Individual stocks may have sharp reversals due to changes in fundamentals.

  3. Black swan events from major policy changes.


  1. Appropriately adjust ADX parameters to ensure trading only under strong trends.

  2. Increase stop loss percentage to control single loss amount.

  3. Closely monitor policies and important events, actively cut loss if necessary.

Directions for Optimization

  1. Test different combinations of Super Trend parameters to find the one that generates the most stable signals.

  2. Test different ADX parameter combinations to determine the optimal settings.

  3. Add other confirmation indicators like volatility and Bollinger Bands to further reduce false signals.

  4. Combine with breakout strategies to cut losses in a timely manner when trends break down.


The overall logic of this strategy is clear, using the Super Trend to judge price trend direction, the ADX to determine trend strength, and trading along strong trends. Stop loss and take profit are set to control risks. The strategy has few parameters and is easy to optimize. It can serve as a good example for learning simple and effective trend tracking strategies. Further improvements can be made through parameter optimization, signal filtering etc.

start: 2023-02-15 00:00:00
end: 2024-02-21 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]

//Intraday Strategy Template

// This source code is subject to the terms of the Mozilla Public License 2.0 at
// © vikris

strategy("[VJ]Hulk Smash Intra", overlay=true, calc_on_every_tick = false, pyramiding=0,default_qty_type=strategy.percent_of_equity, default_qty_value=100,initial_capital=2000)

// ********** Strategy inputs - Start **********

// Used for intraday handling
// Session value should be from market start to the time you want to square-off 
// your intraday strategy
// Important: The end time should be at least 2 minutes before the intraday
// square-off time set by your broker
var i_marketSession = input(title="Market session", type=input.session, 
     defval="0915-1455", confirm=true)

// Make inputs that set the take profit % (optional)
longProfitPerc = input(title="Long Take Profit (%)",
     type=input.float, minval=0.0, step=0.1, defval=1) * 0.01

shortProfitPerc = input(title="Short Take Profit (%)",
     type=input.float, minval=0.0, step=0.1, defval=1) * 0.01
// Set stop loss level with input options (optional)
longLossPerc = input(title="Long Stop Loss (%)",
     type=input.float, minval=0.0, step=0.1, defval=0.5) * 0.01

shortLossPerc = input(title="Short Stop Loss (%)",
     type=input.float, minval=0.0, step=0.1, defval=0.5) * 0.01    
var float i_multiplier = input(title = "ST Multiplier", type = input.float, 
     defval = 2, step = 0.1, confirm=true)

var int i_atrPeriod = input(title = "ST ATR Period", type = input.integer, 
     defval = 10, confirm=true)     
len = input(title="ADX Length", type=input.integer, defval=14)
th = input(title="ADX Threshold", type=input.integer, defval=20)
adxval = input(title="ADX Momemtum Value", type=input.integer, defval=25)     

// ********** Strategy inputs - End **********

// ********** Supporting functions - Start **********

// A function to check whether the bar or period is in intraday session
barInSession(sess) => time(timeframe.period, sess) != 0

// ********** Supporting functions - End **********

// ********** Strategy - Start **********

[superTrend, dir] = supertrend(i_multiplier, i_atrPeriod)

colResistance = dir == 1 and dir == dir[1] ?, 0) :, 100)
colSupport = dir == -1 and dir == dir[1] ?, 0) :, 100)

// Super Trend Long/short condition
stlong = close > superTrend
stshort = close < superTrend

// Figure out take profit price
longExitPrice  = strategy.position_avg_price * (1 + longProfitPerc)
shortExitPrice = strategy.position_avg_price * (1 - shortProfitPerc)

// Determine stop loss price
longStopPrice  = strategy.position_avg_price * (1 - longLossPerc)
shortStopPrice = strategy.position_avg_price * (1 + shortLossPerc)

//Vol Confirmation
vol = volume > volume[1]

//Candles colors
greenCandle = (close > open)
redCandle = (close < open)

// See if intraday session is active
bool intradaySession = barInSession(i_marketSession)

// Trade only if intraday session is active

TrueRange = max(max(high - low, abs(high - nz(close[1]))), abs(low - nz(close[1])))
DirectionalMovementPlus = high - nz(high[1]) > nz(low[1]) - low ? max(high - nz(high[1]), 0) : 0
DirectionalMovementMinus = nz(low[1]) - low > high - nz(high[1]) ? max(nz(low[1]) - low, 0) : 0

SmoothedTrueRange = 0.0
SmoothedTrueRange := nz(SmoothedTrueRange[1]) - nz(SmoothedTrueRange[1]) / len + TrueRange
SmoothedDirectionalMovementPlus = 0.0
SmoothedDirectionalMovementPlus := nz(SmoothedDirectionalMovementPlus[1]) - 
   nz(SmoothedDirectionalMovementPlus[1]) / len + DirectionalMovementPlus
SmoothedDirectionalMovementMinus = 0.0
SmoothedDirectionalMovementMinus := nz(SmoothedDirectionalMovementMinus[1]) - 
   nz(SmoothedDirectionalMovementMinus[1]) / len + DirectionalMovementMinus

DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
DX = abs(DIPlus - DIMinus) / (DIPlus + DIMinus) * 100
ADX = sma(DX, len)

// a = plot(DIPlus,, title="DI+", transp=100)
// b = plot(DIMinus,, title="DI-", transp=100)

//Final Long/Short Condition
longCondition = stlong and redCandle and vol and ADX>adxval
shortCondition = stshort and greenCandle and vol and ADX >adxval

//Long Strategy - buy condition and exits with Take profit and SL
if (longCondition and intradaySession)
    stop_level = longStopPrice
    profit_level = longExitPrice
    strategy.entry("My Long Entry Id", strategy.long)
    strategy.exit("TP/SL", "My Long Entry Id",stop=stop_level, limit=profit_level)

//Short Strategy - sell condition and exits with Take profit and SL
if (shortCondition and intradaySession)
    stop_level = shortStopPrice
    profit_level = shortExitPrice
    strategy.entry("My Short Entry Id", strategy.short)
    strategy.exit("TP/SL", "My Short Entry Id", stop=stop_level, limit=profit_level)
// Square-off position (when session is over and position is open)
squareOff = (not intradaySession) and (strategy.position_size != 0)
strategy.close_all(when = squareOff, comment = "Square-off")

// ********** Strategy - End **********