OPEN-SOURCE SCRIPT

Cosine-Weighted MA ATR [InvestorUnknown]

ที่อัปเดต:
The Cosine-Weighted Moving Average (CWMA) ATR (Average True Range) indicator is designed to enhance the analysis of price movements in financial markets. By incorporating a cosine-based weighting mechanism, this indicator provides a unique approach to smoothing price data and measuring volatility, making it a valuable tool for traders and investors.

Cosine-Weighted Moving Average (CWMA)
  • The CWMA is calculated using weights derived from the cosine function, which emphasizes different data points in a distinctive manner. Unlike traditional moving averages that assign equal weight to all data points, the cosine weighting allocates more significance to values at the edges of the data window. This can help capture significant price movements while mitigating the impact of outlier values.
  • The weights are shifted to ensure they remain non-negative, which helps in maintaining a stable calculation throughout the data series. The normalization of these weights ensures they sum to one, providing a proportional contribution to the average.



Cosine-Weighted ATR Calculation
  • The ATR is an essential measure of volatility, reflecting the average range of price movement over a specified period. The Cosine-Weighted ATR uses a similar weighting scheme to that of the CWMA, allowing for a more nuanced understanding of volatility. By emphasizing more recent price movements while retaining sensitivity to broader trends, this ATR variant offers traders enhanced insight into potential price fluctuations.



Signal Generation
  • The indicator generates long and short signals based on the relationship between the price (user input) and the calculated upper and lower bands, derived from the CWMA and the Cosine-Weighted ATR. Crossover conditions are used to identify potential entry points, providing a systematic approach to trading decisions.



Backtest Mode and Equity Calculation
To evaluate its effectiveness, the indicator includes a backtest mode, allowing users to test its performance on historical data:
  • Backtest Equity: A detailed equity curve is calculated based on the generated signals over a user-defined period (startDate to endDate).
  • Buy and Hold Comparison: Alongside the strategy’s equity, a Buy-and-Hold equity curve is plotted for performance comparison.


Visualization and Alerts
  • The indicator features customizable plots, allowing users to visualize the CWMA, ATR bands, and signals effectively. The colors change dynamically based on market conditions, with clear distinctions between long and short signals.
  • Alerts can be configured to notify users of crossover events, providing timely information for potential trading opportunities.

เอกสารเผยแพร่
Added option to use custom Timeframes on current chart Timeframe for CWMA and ATR.


เอกสารเผยแพร่
Fixed issue with custom CWMA source not being passed correctly into the calculation.
Moving AveragesTrend Analysis

สคริปต์โอเพนซอร์ซ

ด้วยเจตนารมณ์หลักของ TradingView ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถเข้าใจและตรวจสอบได้ ต้องขอบคุณผู้เขียน! ที่ให้คุณใช้ได้ฟรี แต่การนำโค้ดนี้ไปใช้ในการเผยแพร่ซ้ำจะต้องอยู่ภายใต้ กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?

คำจำกัดสิทธิ์ความรับผิดชอบ