Price Statistical Strategy-Z Score V 1.01 by ata_sabanci

By ata_sabanci

Performance Metrics

Description

Price Statistical Strategy – Z Score V 1.01OverviewA technical breakdown of the logic and components of the “Price Statistical Strategy – Z Score V 1.01”.This script implements a smoothed Z-Score crossover mechanism applied to the closing price to detect potential statistical deviations from local price mean. The strategy operates solely on price data (close) and includes signal spacing control and momentum-based candle filters. No volume-based or trend-detection components are included.Core MethodologyThe strategy is built on the statistical concept of Z-Score, which quantifies how far a value (closing price) is from its recent average, normalized by standard deviation. Two moving averages of the raw Z-Score are calculated: a short-term and a long-term smoothed version. The crossover between them generates long entries and exits.Signal ConditionsEntry Condition:A long position is opened when the short-term smoothed Z-Score crosses above the long-term smoothed Z-Score, and additional entry conditions are met.Exit Condition:The position is closed when the short-term Z-Score crosses below the long-term Z-Score, provided the exit conditions allow.Signal Gapping:A minimum number of bars (Bars gap between identical signals) must pass between repeated entry or exit signals to reduce noise.Momentum Filter:Entries are prevented during sequences of three or more consecutively bullish candles, and exits are prevented during three or more consecutively bearish candles. Z-Score FunctionThe Z-Score is calculated as:Z = (Close - SMA(Close, N)) / STDEV(Close, N)Where N is the base period selected by the user.Input ParametersEnable Smoothed Z-Score StrategyEnables or disables the Z-Score strategy logic. When disabled, no trades are executed.Z-Score Base PeriodDefines the number of bars used to calculate the simple moving average and standard deviation for the Z-Score. This value affects how responsive the raw Z-Score is to price changes.Short-Term SmoothingSets the smoothing window for the short-term Z-Score. Higher values produce smoother short-term signals, reducing sensitivity to short-term volatility.Long-Term SmoothingSets the smoothing window for the long-term Z-Score, which acts as the reference line in the crossover logic.Bars gap between identical signalsMinimum number of bars that must pass before another signal of the same type (entry or exit) is allowed. This helps reduce redundant or overly frequent signals.Trade Visualization TableA table positioned at the bottom-right displays live PnL for open trades:Entry PriceUnrealized PnL %Text colors adapt based on whether unrealized profit is positive, negative, or neutral. Technical NotesThis strategy uses only close prices — no trend indicators or volume components are applied.All calculations are based on simple moving averages and standard deviation over user-defined windows.Designed as a minimal, isolated Z-Score engine without confirmation filters or multi-factor triggers.

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView