OPEN-SOURCE SCRIPT

Uptrick X PineIndicators: Z-Score Flow Strategy

1 854
This strategy is based on the Z-Score Flow Indicator developed by Uptrick. Full credit for the original concept and logic goes to Uptrick.

The Z-Score Flow Strategy combines statistical mean-reversion logic with trend filtering, RSI confirmation, and multi-mode trade execution, offering a flexible and structured approach to trading both reversals and trend continuations.

Core Concepts Behind Z-Score Flow
1. Z-Score Mean Reversion Logic
The Z-score measures how far current price deviates from its statistical mean, in standard deviations.
  • A high positive Z-score (e.g. > 2) suggests price is overbought and may revert downward.
  • A low negative Z-score (e.g. < -2) suggests price is oversold and may revert upward.

The strategy uses Z-score thresholds to trigger signals when price deviates far enough from its mean.

2. Trend Filtering with EMA
To prevent counter-trend entries, the strategy includes a trend filter based on a 50-period EMA:
  • Only allows long entries if price is below EMA (mean-reversion in downtrends).
  • Only allows short entries if price is above EMA (mean-reversion in uptrends).


3. RSI Confirmation and Lockout System
An RSI smoothing mechanism helps confirm signals and avoid whipsaws:
  • RSI must be below 30 and rising to allow buys.
  • RSI must be above 70 and falling to allow sells.
  • Once a signal occurs, it is "locked out" until RSI re-enters the neutral zone (30–70).


This avoids multiple signals in overextended zones and reduces overtrading.

Entry Signal Logic
A buy or sell is triggered when:
  • Z-score crosses below (buy) or above (sell) the threshold.
  • RSI smoothed condition is met (oversold and rising / overbought and falling).
  • The trend condition (EMA filter) aligns.
  • A cooldown period has passed since the last opposite trade.


This layered approach helps ensure signal quality and timing precision.

Trade Modes
The strategy includes three distinct trade modes to adapt to various market behaviors:

1. Standard Mode
  • Trades are opened using the Z-score + RSI + trend filter logic.
  • Each signal must pass all layered conditions.


2. Zero Cross Mode
  • Trades are based on the Z-score crossing zero.
  • This mode is useful in trend continuation setups, rather than mean reversion.


3. Trend Reversal Mode
  • Trades occur when the mean slope direction changes, i.e., basis line changes color.
  • Helps capture early trend shifts with less lag.


Each mode can be customized for long-only, short-only, or long & short execution.

Visual Components
1. Z-Score Mean Line
  • The basis (mean) line is colored based on slope direction.
  • Green = bullish slope, Purple = bearish slope, Gray = flat.
  • A wide shadow band underneath reflects current trend momentum.


2. Gradient Fill to Price
A gradient zone between price and the mean reflects:
  • Price above mean = bearish zone with purple overlay.
  • Price below mean = bullish zone with teal overlay.


This visual aid quickly reveals market positioning relative to equilibrium.

3. Signal Markers
  • "𝓤𝓹" labels appear for buy signals.
  • "𝓓𝓸𝔀𝓷" labels appear for sell signals.
  • These are colored and positioned according to trend context.


Customization Options
  • Z-Score Period & Thresholds: Define sensitivity to price deviations.
  • EMA Trend Filter Length: Filter entries with long-term bias.
  • RSI & Smoothing Periods: Fine-tune RSI confirmation conditions.
  • Cooldown Period: Prevent signal spam and enforce timing gaps.
  • Slope Index: Adjust how far back to compare mean slope.
  • Visual Settings: Toggle mean lines, gradients, and more.


Use Cases & Strategy Strengths
1. Mean-Reversion Trading
Ideal for catching pullbacks in trending markets or fading overextended price moves.

2. Trend Continuation or Reversal
With multiple trade modes, traders can choose between fading price extremes or trading slope momentum.

3. Signal Clarity and Risk Control
The combination of Z-score, RSI, EMA trend, and cooldown logic provides high-confidence signals with built-in filters.

Conclusion
The Z-Score Flow Strategy by Uptrick X PineIndicators is a versatile and structured trading system that:
  • Fuses statistical deviation (Z-score) with technical filters.
  • Provides both mean-reversion and trend-based entry logic.
  • Uses visual overlays and signal labels for clarity.
  • Prevents noise-driven trades via cooldown and lockout systems.


This strategy is well-suited for traders seeking a data-driven, multi-condition entry framework that can adapt to various market types.

Full credit for the original concept and indicator goes to Uptrick.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.