All indicators

ZigZag PA Strategy V4.1

Jan 18, 2016

Static chart image
Price Action BasedSignalsFibonacciPatternsPivot Based (Retrospective)Repainting Functionality

The ZigZag PA Strategy V4.1 indicator identifies harmonic and geometric price patterns based on ZigZag movements to execute automated trading strategies. It provides a systematic framework for detecting complex patterns like Bats, Butterflies, and Gartleys while offering customizable Fibonacci-based entry and exit targets.

Usage

The Usage section describes how the script can be used to identify trend reversals and continuations through automated pattern recognition.

  • Pattern Detection: The script automatically plots labels on the chart when specific price action patterns are completed. These include classic harmonic patterns (Bat, Butterfly, Crab, Shark, etc.) and geometric shapes like Head and Shoulders or Triangles.
  • Dual Target Management: Users can activate a primary and an optional secondary target. To utilize the second target effectively, the "Pyramiding" setting in the strategy properties must be manually set to at least 1.
  • Timeframe Flexibility: The "Use Alt Timeframe" setting allows users to detect patterns on a higher timeframe (e.g., 60 minutes) while viewing the results on a lower timeframe for more precise entry timing.
  • Fibonacci Levels: The indicator plots Fibonacci retracement levels based on the current ZigZag leg to help traders visualize the entry window (EW), take profit (TP), and stop loss (SL) zones.

Details

The script utilizes a custom ZigZag function that identifies pivots based on price direction changes. Once these pivots (labeled X, A, B, C, and D) are established, the script calculates the ratios between different legs:

  • XAB: The ratio of leg AB to leg XA.
  • ABC: The ratio of leg BC to leg AB.
  • BCD: The ratio of leg CD to leg BC.
  • XAD: The ratio of leg AD to leg XA.

These ratios are compared against predefined ranges for various harmonic patterns. For example, a "Bat" pattern is identified when the XAB ratio is between 0.382 and 0.5, and the XAD ratio is less than or equal to 0.618.

Note: Due to the nature of ZigZag calculations, the D point of a pattern may update as price evolves, which can lead to repainting of the entry signals upon script reloading.

Settings

General Settings

  • Use Heikin Ashi Candles: Toggles the use of Heikin Ashi price data for ZigZag calculations to smooth out noise.
  • Use Alt Timeframe: Enables the calculation of patterns based on a secondary timeframe.
  • Alt Timeframe: Sets the specific timeframe used for pattern detection when "Use Alt Timeframe" is active.
  • Show Patterns: Toggles the visibility of text labels for detected patterns on the chart.

Fibonacci Display

  • Display Fibonacci [Levels]: Individual toggles to show or hide various Fibonacci retracement lines (0.000, 0.236, 0.382, 0.500, 0.618, 0.764, 1.000).

Target 1 & 2 Settings

  • Active? (Target 2): Enables the secondary trading target logic.
  • Trade size: Determines the quantity for the specific target order.
  • Fib. Rate to use for Entry Window: Sets the Fibonacci level that defines the entry zone relative to the current ZigZag leg.
  • Fib. Rate to use for TP: Sets the Fibonacci level for the take-profit order.
  • Fib. Rate to use for SL: Sets the Fibonacci level for the stop-loss order.

FAQ

How do I use both targets simultaneously? To use the second target, you must manually go into the Strategy "Settings" -> "Properties" tab and set "Pyramiding" to 1 or higher.

Why do patterns disappear or move after I refresh the chart? The script uses a ZigZag-based logic which is reactive to price highs and lows; signals may adjust until a pivot point is fully confirmed by subsequent price action.

How can I access this script? 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.