OPEN-SOURCE SCRIPT

Z-Score Weighted Trend System I [InvestorUnknown]

已更新
The Z-Score Weighted Trend System I is an advanced and experimental trading indicator designed to utilize a combination of slow and fast indicators for a comprehensive analysis of market trends. The system is designed to identify stable trends using slower indicators while capturing rapid market shifts through dynamically weighted fast indicators. The core of this indicator is the dynamic weighting mechanism that utilizes the Z-score of price, allowing the system to respond effectively to significant market movements.

Dynamic Z-Score-Based Weighting System

  • The Z-Score Weighted Trend System I utilizes the Z-score of price to assign weights dynamically to fast indicators. This mechanism is designed to capture rapid market shifts at potential turning points, providing timely entry and exit signals.
  • Traders can choose from two primary weighting mechanisms:
  • Threshold-Based Weighting: The fast indicators are given weight only when the absolute Z-score exceeds a user-defined threshold. Below this threshold, fast indicators have no impact on the final signal.
  • Continuous Weighting: By setting the threshold to zero, fast indicators always contribute to the final signal, regardless of Z-score levels. However, this increases the likelihood of false signals during ranging or low-volatility markets




Choice of Z-Score Normalization

Traders have the flexibility to select different Z-score processing methods to better suit their trading preferences:
  • Raw Z-Score or Moving Average: Traders can opt for either the raw Z-score or a moving average of the Z-score to smooth out fluctuations.
  • Normalized Z-Score (ranging from -1 to 1) or Z-Score Percentile: The normalized Z-score is simply the raw Z-score divided by 3, while the Z-score percentile utilizes a normal distribution for transformation.




快照

Slow and Fast Indicators

The indicator uses a combination of slow and fast indicators:
  • Slow Indicators (constant weight) for stable trend identification: DMI (Directional Movement Index), CCI (Commodity Channel Index), Aroon
  • Fast Indicators (dynamic weight) to identify rapid trend shifts: ZLEMA (Zero-Lag Exponential Moving Average), IIRF (Infinite Impulse Response Filter)


Each indicator is calculated using for-loop methods to provide a smoothed and averaged view of price data over varying lengths, ensuring stability for slow indicators and responsiveness for fast indicators.

Signal Calculation

The final trading signal is determined by a weighted combination of both slow and fast indicators. The slow indicators provide a stable view of the trend, while the fast indicators offer agile responses to rapid market movements. The signal calculation takes into account the dynamic weighting of fast indicators based on the Z-score:


Backtest Mode and Performance Metrics

The indicator features a detailed backtesting mode, allowing traders to compare the effectiveness of their selected settings against a traditional Buy & Hold strategy. The backtesting provides:
  • Equity calculation based on signals generated by the indicator.
  • Performance metrics comparing Buy & Hold metrics with the system’s signals, including: Mean, positive, and negative return percentages, Standard deviations, Sharpe, Sortino, and Omega Ratios




快照

Calibration Mode

A Calibration Mode is included for traders to focus on individual indicators, helping them fine-tune their settings without the influence of other components. In Calibration Mode, the user can visualize each indicator separately, making it easier to adjust parameters.

Alerts

The indicator includes alerts for long and short signals when the indicator changes direction, allowing traders to set automated notifications for key market events.


Important Note:
  • The default settings of this indicator are not optimized for any particular market condition. They are generic starting points for experimentation. Traders are encouraged to use the calibration tools and backtesting features to adjust the system to their specific trading needs.
  • The results generated from the backtest are purely historical and are not indicative of future results. Market conditions can change, and the performance of this system may differ under different circumstances. Traders and investors should exercise caution and conduct their own research before using this indicator for any trading decisions.
版本注释
Updated the code to pinescript v6, added backtesting library v2 with more backtesting functions and removed old backtesting functions from the code
educationalstatisticsTrend Analysis

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?

免责声明