Purpose: Identifies the direction, strength, and potential reversal points of a trend.
Since ProRealCode does not have a native “curvature” function like some TradingView indicators, we approximate it using a combination of moving averages, volatility (such as ATR), and dynamic adjustments to replicate the described behavior.
An EMA (Exponential Moving Average) is used as the central line, similar to how the Radius Trend establishes a dynamic base.
ATR (Average True Range) is used to adjust the bands according to volatility, mimicking the adaptability of the original indicator.
Returns three lines: the upper band, the primary trend (curvature), and the lower band, which can be visualized on the chart.
// Indicador Curvature Trend adaptado para ProRealCode por @mboliart (https://x.com/mboliart)
// Parámetros ajustables
StartDistance = 2.0 // Distancia inicial (multiplicador)
StepCurvature = 0.1 // Paso de ajuste de la curvatura
ATRPeriod = 14 // Período del ATR para medir volatilidad
TrendLength = 20 // Longitud de la tendencia base
// Calcular la base de la tendencia (media móvil exponencial)
TrendBase = ExponentialAverage[TrendLength](Close)
// Calcular la volatilidad (ATR)
Vola = AverageTrueRange[ATRPeriod]
// Ajustar dinámicamente las bandas superior e inferior
UpperBand = TrendBase + (StartDistance * Vola)
LowerBand = TrendBase - (StartDistance * Vola)
// Ajuste de la "curvatura" dinámica basado en la dirección del precio
PriceChange = Close - Close[1]
IF PriceChange > 0 THEN
UpperBand = UpperBand + (StepCurvature * Vola)
LowerBand = LowerBand + (StepCurvature * Vola * 0.5)
ENDIF
IF PriceChange < 0 THEN
LowerBand = LowerBand - (StepCurvature * Vola)
UpperBand = UpperBand - (StepCurvature * Vola * 0.5)
ENDIF
// Devolver las bandas
RETURN UpperBand coloured(154,205,50,150) AS "Banda Superior", TrendBase AS "Tendencia Principal", LowerBand coloured(255,20,147,150) AS "Banda Inferior"