DEV Community

Cover image for Pivot-Based Dynamic Trend Strategy (Quality-Controlled)
Ranga
Ranga

Posted on

Pivot-Based Dynamic Trend Strategy (Quality-Controlled)

Overview

This strategy demonstrates a pivot-based trend continuation approach built with execution realism in mind.
It combines confirmed swing structure (pivot highs/lows), a higher-timeframe EMA trend filter, and ATR-based risk management to create a clean, auditable trading framework suitable for backtesting and experimentation.
All logic is evaluated on confirmed bars only, with no repainting or intrabar assumptions.

Core idea

Markets often form identifiable swing highs and lows while trending.
When price pulls back toward a trend reference (EMA) and then breaks a prior swing level, continuation becomes more likely, provided overall trend strength is present.
This strategy focuses on:

  • Structure first
  • Trend alignment
  • Defined risk on every trade

How it works

1) Trend context
A single EMA is used to define directional bias:

  • Price above the EMA → bullish context
  • Price below the EMA → bearish context
  • This keeps the logic simple and consistent.

2) Pivot structure
Confirmed pivot highs and lows are detected using a fixed lookback window.

  • Pivot highs represent recent resistance
  • Pivot lows represent recent support Only confirmed pivots are used, no future data or repainting behavior.

3) Trend strength filter
Directional strength is evaluated using ADX (via DMI):

  • Trades are allowed only when trend strength exceeds a minimum threshold
  • This helps reduce signals during low-energy or choppy market conditions

4) Entry logic
Entries are evaluated only when:

  • Price is aligned with the EMA trend
  • Trend strength is sufficient
  • Price pulls back toward the EMA
  • Price then breaks the most recent confirmed pivot level This avoids chasing extended moves and helps improve entry quality.

5) Risk management
Risk is fully defined at entry:

  • Stop-loss is based on an ATR multiple
  • Take-profit uses a fixed risk-to-reward ratio
  • Position sizing is capped at a fixed percentage of equity
  • One position at a time
  • No trailing stops, no hidden exits, no retroactive adjustments.

Usage notes

  • Results vary by symbol, timeframe, volatility regime, and session
  • This is not a signal service or a finished trading system
  • Best used as a structural template for studying trend continuation and swing-based entries

Users are encouraged to:

  • Test across multiple markets
  • Adjust pivot length, EMA length, and ATR parameters
  • Validate behavior with forward testing before using alerts or automation

Purpose

This script is designed to emphasize:

  • confirmed-bar logic
  • realistic execution
  • explicit risk definition
  • repeatable behavior It intentionally prioritizes quality and clarity over optimization or curve-fitted performance.

Top comments (0)