0bps

Strategy vault / Trend following

Enhanced Trend Following System Dynamic Trend Identification Based on ADX and Parabolic SAR

This strategy is a trend following trading system that combines the Average Directional Index (ADX) with the Parabolic Stop and Reverse (SAR) indicator. The system measures trend strength using ADX and confirms trend…

Author
ChaoZhang
Complexity
Starter · 63 lines
Parameters
0
Backtest bar
1d · swing
Tested on
BTC/USDT · futures

IMG

Overview

This strategy is a trend following trading system that combines the Average Directional Index (ADX) with the Parabolic Stop and Reverse (SAR) indicator. The system measures trend strength using ADX and confirms trend direction using SAR to capture trading opportunities in strong trending markets. It employs a dual confirmation mechanism to ensure both the existence and reliability of trends.

Strategy Principle

The core logic is based on the following key components:

  1. ADX indicator measures trend strength, with values above 25 indicating a significant trend.
  2. DI+ and DI- crossovers determine trend direction, with DI+ > DI- indicating uptrend and vice versa.
  3. Parabolic SAR tracks price movement by dynamically adjusting stop points, providing additional trend confirmation.

Trade signal triggers are as follows:

  • Long entry: ADX>25, DI+>DI-, and price above SAR
  • Short entry: ADX>25, DI->DI+, and price below SAR
  • Exit: When opposite trading signals appear

Strategy Advantages

  1. Dual confirmation mechanism significantly improves signal reliability
  2. Dynamic stop-loss helps protect existing profits
  3. High parameter adaptability for different market conditions
  4. Clear strategy logic, easy to understand and execute
  5. Excellent performance in strong trending markets

Strategy Risks

  1. May generate frequent false signals in oscillating markets
  2. Entry points may lag behind trend initiation
  3. Potential for significant drawdowns during quick reversals
  4. Parameter settings can significantly impact strategy performance

Risk control suggestions:

  • Set maximum drawdown limits
  • Adjust parameters based on market volatility
  • Incorporate additional technical indicators for trade confirmation
  • Implement position management strategies

Strategy Optimization Directions

  1. Introduce volatility indicators for parameter adjustment

    • Increase ADX threshold during high volatility periods
    • Reduce SAR sensitivity during low volatility periods
  2. Optimize exit mechanism

    • Add profit targets
    • Design dynamic stop-loss strategy
  3. Add market environment filters

    • Incorporate trendline analysis
    • Consider volume factors
  4. Improve position management

    • Design position sizing based on ATR
    • Implement staged entry/exit

Summary

This strategy constructs a robust trend following system by combining ADX and SAR indicators. Its main advantages lie in the dual confirmation mechanism and dynamic stop-loss settings, although performance may be suboptimal in oscillating markets. Through appropriate parameter optimization and risk control, the strategy can achieve good performance in clearly trending market environments. Traders are advised to conduct thorough backtesting before live implementation and adjust parameters according to specific market characteristics.

Source Pine Script

/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-10 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © traderhub

//@version=5
strategy("Trend Following ADX + Parabolic SAR", overlay=true)

// Strategy parameters
adxLength = input(14, title="ADX Period")
adxThreshold = input(25, title="ADX Threshold")
adxSmoothing = input(14, title="ADX Smoothing")
sarStart = input(0.02, title="Parabolic SAR Start")  // Starting acceleration factor
sarIncrement = input(0.02, title="Parabolic SAR Increment")  // Increment step
sarMax = input(0.2, title="Parabolic SAR Max")  // Maximum acceleration factor

// Calculate ADX, DI+, and DI-
[diPlus, diMinus, adx] = ta.dmi(adxLength, adxSmoothing)

// Parabolic SAR calculation
sar = ta.sar(sarStart, sarIncrement, sarMax)

// Conditions for a long position
longCondition = adx > adxThreshold and diPlus > diMinus and close > sar

// Conditions for a short position
shortCondition = adx > adxThreshold and diMinus > diPlus and close < sar

// Enter a long position
if (longCondition)
    strategy.entry("Long", strategy.long)

// Enter a short position
if (shortCondition)
    strategy.entry("Short", strategy.short)

// Close position on reverse signal
if (strategy.position_size > 0 and shortCondition)
    strategy.close("Long")
if (strategy.position_size < 0 and longCondition)
    strategy.close("Short")

// Plot indicators on the chart
plot(sar, color=color.blue, style=plot.style_circles, linewidth=2, title="Parabolic SAR")
plot(adx, color=color.red, title="ADX")
hline(adxThreshold, "ADX Threshold", color=color.green)










Published by ChaoZhang on the FMZ strategy square · last modified 2024-12-12. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Enhanced-Trend-Following-System-Dynamic-Trend-Identification-Based-on-ADX-and-Parabolic-SAR.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open