Skip to content
All library documents

Swing Pivot Strategy with Moving-Average Filtering and Scaled Exits

Article Strategy library · Author: LucasVivien

Summary

This open-source strategy is organized around confirmed swing highs and lows. Its lookback setting controls how many elapsed bars are needed before a pivot is identified. The visible settings also include a selectable moving-average type and length for trend filtering, plus stop-loss and take-profit distances expressed in minimum ticks or, for forex symbols, pips. The excerpt shows a default lookback of 23 and a 200-period EMA filter, alongside configurable exit distances.

An optional two-target mode is described: it doubles entry quantity, closes half at the first target, moves the stop to entry, and closes the remainder at the second target or stop. The excerpt does not include the complete signal-generation and order-management logic, nor any backtest settings or performance results, so the precise pivot entry rules and observed behavior cannot be assessed from the available material. The provided code is a strategy implementation with alert-message inputs; its settings alone do not establish profitability or suitability across markets.

Key ideas

  • The pivot lookback determines how many bars pass before swing highs or lows are confirmed.
  • A configurable moving-average filter is intended to restrict trades according to trend direction.
  • Stops and profit targets are specified in ticks, or in pips for forex symbols.
  • Optional two-target management takes partial profit at the first target and can move the stop to entry.
  • The excerpt does not provide complete entry rules or evidence from backtesting.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.