
Author Message:
The Radius Trend [ChartPrime] indicator is an innovative technical analysis tool designed to visualize market trends using a dynamic, radius-based approach. By incorporating adaptive bands that adjust based on price action and volatility, this indicator provides traders with a unique perspective on trend direction, strength, and potential reversal points.
The Radius Trend concept involves creating a dynamic trend line that adjusts its angle and position based on market movements, similar to a radius sweeping across a chart. This approach allows for a more fluid and adaptive trend analysis compared to traditional linear trend lines.
CODE:
CSS:
#// Indicator For TOS
#// ©ChartPrime
#indicator("Radius Trend [ChartPrime]", overlay = true)
# Convertted by Sam4Cok@Samer800 - 08/2024
input RadiusStep = 0.15; # "Radius Step"
input StartPointsDistance = 2.0; # "Start Points Distance"
def na = Double.NaN;
def x = x[1] + 1;
def bar = CompoundValue(1, x , 1); #if !isNaN(close) then BarNumber() else bar[1];
#// Initialize variables
#bool trend = na
def multi1; # = 0.
def multi2; # = 0.
def n = 3;
def band; # = 0.
#// 𝙄𝙉𝘿𝙄𝘾𝘼𝙏𝙊𝙍 𝘾𝘼𝙇𝘾𝙐𝙇𝘼𝙏𝙄𝙊𝙉𝙎
#// Calculate distances for band placement
def tr = AbsValue(high - low);
def lookback = 100;
def distance = Average(tr, lookback) * StartPointsDistance;
def distance1 = Average(tr, lookback) * 0.2;
def trend = CompoundValue(1, if close < (if !band[1] then low * 0.8 else band[1]) then no else
if close > (if !band[1] then low * 0.8 else band[1]) then yes else trend[1], yes);
#// Adjust band on trend changes
if trend[1] == no and (trend - trend[1]) {
multi1 = multi1[1];
multi2 = multi2[1];
band = low - distance;
} else
if trend[1] == yes and (trend - trend[1]) {
multi1 = multi1[1];
multi2 = multi2[1];
band = high + distance;
} else
if (bar % n) == 0 and trend {
multi1 = 0;
multi2 = multi2[1] + RadiusStep;
band = band[1] + distance1 * multi2;
} else
if (bar % n) == 0 and !trend {
multi1 = multi1[1] + RadiusStep;
multi2 = 0 ;
band = band[1] - distance1 * multi1;
} else {
multi1 = multi1[1];
multi2 = multi2[1];
band = (if !band[1] then low * 0.8 else band[1]);
}
#// Smooth the band
def Sband = Average(band, n);
#// Calculate upper and lower bands
def band_upper = if bar < 1 then Average(band + atr(lookback) * 0.5, n) else Average(band + distance * 0.5, n);
def band_lower = if bar < 1 then Average(band - atr(lookback) * 0.5, n) else Average(band - distance * 0.5, n);
def band1 = if trend then band_upper else band_lower;
#// Plot the outer band
plot radius1 = if (trend == trend[1]) and band1 then band1 else na;
plot trendLine = if (trend - trend[1]) then na else Sband;
def p2 = Average(hl2, 20);
radius1.SetStyle(Curve.LONG_DASH);
radius1.SetDefaultColor(Color.GRAY);
trendLine.AssignValueColor(if trend then Color.GREEN else Color.RED);
def trend2 = trend;
def diff = band - p2;
AddCloud(if trend2 then trendLine else na, p2 + (trendLine - p2) / 1.5, Color.DARK_GREEN, Color.DARK_GREEN);
AddCloud(if !trend2 then trendLine else na, p2 + (trendLine - p2) / 1.5, Color.DARK_RED, Color.DARK_RED);
AddCloud(radius1, trendLine, Color.DARK_GREEN, Color.DARK_RED);
#-- END of CODE