OPEN-SOURCE SCRIPT

Weighted CG Oscillator with ATR

ATR-Weighted CG Oscillator

The ATR-Weighted CG Oscillator is an enhanced version of the Center of Gravity (CG) Oscillator, originally developed by John Ehlers. By adding the Average True Range (ATR) to dynamically adjust the oscillator’s values based on market volatility, this indicator aims to make trend signals more responsive to price changes, offering an adaptive tool for trend analysis.

Functionality Overview:
The CG Oscillator, a classic trend-following indicator, has been modified here to incorporate the ATR for improved context and adaptability in different market conditions. The indicator calculates the CG Oscillator and scales it by dividing the ATR by the closing price to normalize for volatility. This creates a “weighted” CG Oscillator that generates more contextually relevant signals. A colored line shows green for long signals (above the long threshold), red for short signals (below the short threshold), and gray for neutral conditions.

Input Parameters:
  • CGO Length: Sets the period of the CG Oscillator calculation.
  • ATR Length: Determines the period of the ATR calculation. Longer periods smooth out the volatility impact.
  • Long Threshold: The threshold that triggers a long signal; a long (green) signal occurs when the weighted CG Oscillator crosses above this level.
  • Short Threshold: The threshold that triggers a short signal; a short (red) signal occurs when the weighted CG Oscillator crosses below this level.
  • Source: Specifies the data source for CG Oscillator calculations, with the default set to the closing price.


Recommended Use:
This indicator is designed to be an adaptive tool, not your sole resource. To ensure its effectiveness, it’s essential to backtest the indicator on your chosen asset over your preferred timeframe. Market dynamics vary, so testing the indicator’s parameters—especially the thresholds—will allow you to find the settings that best suit your strategy. While the default values work well for some scenarios, customizing the settings will help align the indicator with your unique trading style and the asset’s characteristics.
ATRatrweightedAverage True Range (ATR)Centered OscillatorscenterofgravityTrend Analysistrendfollowingtrendindicatortrendtradingweighted

Mã nguồn mở

Theo tinh thần TradingView thực sự, tác giả của tập lệnh này đã xuất bản dưới dạng nguồn mở để các nhà giao dịch có thể hiểu và xác minh. Chúc mừng tác giả! Bạn có thể sử dụng miễn phí. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?


Ngoài ra, trên:

Thông báo miễn trừ trách nhiệm