1. Input & Setup Length Parameter: The script uses an input called “Length” (default 14) that governs the period for all moving averages and channel calculations.
Study Declaration: The study is set with overlay=true so that all plots and labels are drawn directly on the price chart.
2. Calculating the “Real Power” Indicator Real Power Calculation:
The script calculates a value called realPower by dividing the running moving average (RMA) of the current close by the RMA of the previous close over the specified length. This ratio gives a sense of the momentum or “power” behind the price move from one bar to the next. Long and Short Power:
longPower is computed as the simple moving average (SMA) of the realPower over the full length period. shortPower is calculated as the SMA of the realPower over half of that length. These two smoothed values are used to compare short-term versus longer-term momentum. 3. Donchian Channel Middle Donchian Calculation: The indicator computes the middle line of the Donchian channel over the same period by averaging the highest high and the lowest low over the defined length. This middle band acts as a dynamic reference level. 4. Signal Generation Buy Signal (Bullish):
A buy condition is triggered when the short-term momentum (shortPower) exceeds the long-term momentum (longPower) and the current close is above the Donchian middle. This combination suggests that buyers have taken control and the price is trading above a key channel midpoint. Sell Signal (Bearish):
Conversely, a sell condition occurs when shortPower is lower than longPower and the current close is below the Donchian middle. This indicates that sellers are dominant and the price is trading beneath the channel’s midpoint. Preventing Repeated Signals:
The script tracks the previous bar’s signal state (using buyConditionPrev and sellConditionPrev) so that a new label is only drawn when the condition transitions from false to true. 5. Visual Output Signal Labels:
When a buy signal occurs (and wasn’t present in the prior bar), a green label reading “AL” (meaning “Buy”) is drawn at the current bar’s low. For a sell signal, a red label reading “SAT” (meaning “Sell”) is drawn at the current bar’s high. Donchian Middle Line:
The indicator also plots the Donchian middle line in orange, providing a visual reference for the dynamic channel. Summary The “AstroTrading_HighwayRat” indicator combines a custom momentum measure—derived from the ratio of moving averages of the close—with the Donchian channel’s midline to generate trading signals. A bullish signal (buy) is given when short-term momentum is strong and price is above the channel’s midpoint, while a bearish signal (sell) is generated when momentum is weak and the price falls below that midpoint. This dual-condition approach helps traders identify potential trend reversals or continuations based on momentum divergence relative to a dynamic support/resistance level.
This detailed explanation is intended to help traders understand how the indicator processes price data, calculates key levels, and generates actionable signals on the chart.
Script protegido
This script is published as closed-source. However, you can use it freely and without any limitations – learn more here.
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.