lengthPercentile: Defines the period used to calculate the percentile values (default: 30). lengthMomentum: Defines the period for calculating the Rate of Change (ROC) momentum (default: 10).
Core Logic:
Rate of Change (ROC): The script calculates the ROC of the closing price over the specified period (lengthMomentum). Percentile Calculations: The script calculates two key percentiles: percentile_upper (80th percentile of the high prices) percentile_lower (20th percentile of the low prices) Percentile Average: An average of the upper and lower percentiles is calculated (avg_percentile). Trade Signals:
Buy Signal: Triggered when the ROC is positive, the close is above the percentile_lower, and the close is above the avg_percentile.
Sell Signal: Triggered when the ROC is negative, the close is below the percentile_upper, and the close is below the avg_percentile.
Trade State Management:
The script uses a binary state: 1 for long (buy) and -1 for short (sell). The trade state is updated based on buy or sell signals.
Bar Coloring:
Bars are colored dynamically based on the trade state: Green for long (buy signal). Red for short (sell signal). The same color is applied to the percentile and average percentile lines for visual consistency.
진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.