OPEN-SOURCE SCRIPT

TradFi Fundamentals: Momentum Trading with Macroeconomic Data

296
Introduction
This indicator combines traditional price momentum with key macroeconomic data. By retrieving GDP, inflation, unemployment, and interest rates using security calls, the script automatically adapts to the latest economic data. The goal is to blend technical analysis with fundamental insights to generate a more robust momentum signal.

Original Research Paper by Mohit Apte, B. Tech Scholar, Department of Computer Science and Engineering, COEP Technological University, Pune, India

Link to paper

Explanation

Price Momentum Calculation:
The indicator computes price momentum as the percentage change in price over a configurable lookback period (default is 50 days). This raw momentum is then normalized using a rolling simple moving average and standard deviation over a defined period (default 200 days) to ensure comparability with the economic indicators.

Fetching and Normalizing Economic Data:
Instead of manually inputting economic values, the script uses TradingView’s security function to retrieve:
  • GDP from ticker "GDP"
  • Inflation (CPI) from ticker "USCCPI"
  • Unemployment rate from ticker "UNRATE"
  • Interest rates from ticker "USINTR"

Each series is normalized over a configurable normalization period (default 200 days) by subtracting its moving average and dividing by its standard deviation. This standardization converts each economic indicator into a z-score for direct integration into the momentum score.

Combined Momentum Score:
The normalized price momentum and economic indicators are each multiplied by user-defined weights (default: 50% price momentum, 20% GDP, and 10% each for inflation, unemployment, and interest rates). The weighted components are then summed to form a comprehensive momentum score. A horizontal zero line is plotted for reference.

Trading Signals:
Buy signals are generated when the combined momentum score crosses above zero, and sell signals occur when it crosses below zero. Visual markers are added to the chart to assist with trade timing, and alert conditions are provided for automated notifications.

Settings

Price Momentum Lookback: Defines the period (in days) used to compute the raw price momentum.
Normalization Period for Price Momentum: Sets the window over which the price momentum is normalized.
Normalization Period for Economic Data: Sets the window over which each macroeconomic series is normalized.
Weights: Adjust the influence of each component (price momentum, GDP, inflation, unemployment, and interest rate) on the overall momentum score.

Conclusion
This implementation leverages TradingView’s economic data feeds to integrate real-time macroeconomic data into a momentum trading strategy. By normalizing and weighting both technical and economic inputs, the indicator offers traders a more holistic view of market conditions. The enhanced momentum signal provides additional context to traditional momentum analysis, potentially leading to more informed trading decisions and improved risk management.

The next script I release will be an improved version of this that I have added my own flavor to, improving the signals.

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。