PSAR Zigzag (Non-Lagging) - MetaTrader 5 Script | Trading Script Download - MT4/MT5 Resources






This indicator differs from the traditional zigzag that you are already familiar with. The traditional zigzag has a different purpose: it mainly emphasizes previous market moves and delays the necessary number of bars before confirming the next move. It works based on price action. The hysteresis and redraw indicators are not designed to detect real-time signals. Zigzag charts are less commonly used among trend following indicators. It is more commonly used to analyze the market's historical pivot points to predict future price movements.
This zigzag is something else entirely. This is a dynamic, trend-based zigzag that does not lag behind the current bar. I use SAR Trend as a basis, which is a trend following algorithm without lag. Trend-following zigzags have been developed in the past, including PSAR-based zigzags, but they were delayed and produced invalid legs. Why are there lagging zigzags based on non-lag trend following algorithms? This doesn't seem logical to me. That's why I created this, because I thought we should have a zigzag plot with zero lag.
The back step is used to keep the legs active. When searching for highs, it will find the highest high from the number of backstep bars defined in the backstep input, and when searching for lows through the same number of backstep bars defined in the backstep chart, it will find the lowest low. This means that the end of the section will sometimes fluctuate at a high or low, or at the nearest support or resistance level. PSAR is known to struggle in range-bound markets, which is one of its shortcomings. Otherwise, it's a pretty good trend following indicator. This zigzag structure is the most relevant part of the code. It is designed to be clean, efficient and maintainable. I hope you appreciate my work and experiments.
v1 -- Swings are either related to candle highs or lows, or to support and resistance found by the pullback
v2 -- Connect the legs strictly to the highs and lows of the candle (as many as possible) at the swing points
v3 -- includes step forward logic to provide final control over zigzags
Attachment download
📎 psar_zigzag.mq5 (11.07 KB)
📎 psar_zigzag_v2.mq5 (11.55 KB)
📎 psar_zigzag_v3.mq5 (13.95 KB)
Source: MQL5 #57724
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •