CONVERSION INDICADOR TRADINGVIEW:Regression Indicator
Forums › ProRealTime foro Español › Soporte ProBuilder › CONVERSION INDICADOR TRADINGVIEW:Regression Indicator
- This topic has 3 replies, 2 voices, and was last updated 2 months ago by Iván.
-
-
09/03/2024 at 1:38 PM #237045
Solicito, si es posible, convertir el indicador adjunto:
Descripción general del indicador:
El indicador de regresión está diseñado para ayudar a los operadores a identificar tendencias y posibles reversiones en los movimientos de precios. Al calcular una línea de regresión y un indicador de regresión normalizado, proporciona señales visuales claras para la dirección del mercado, lo que ayuda a tomar decisiones comerciales informadas. El indicador se actualiza dinámicamente con los últimos datos del mercado, lo que garantiza señales oportunas y relevantes.https://es.tradingview.com/script/rFrilcDi-Regression-Indicator-BigBeluga/
A ver si Iván el moderador tiene un hueco libre y lo puede traducir.
Muchas gracias.09/03/2024 at 1:39 PM #237046// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BigBeluga//@version=5
indicator(“Regression Indicator [BigBeluga]”, overlay = false, max_bars_back = 500)// =====================================================================================================================}
// INPUTS
// ====================================================================================================================={int length = input.int(400, “Regression Length”)
int length1 = input.int(100, “Regression Normalization”)
int length2 = input.int(50, “Signal Line”)color m_color = #049ef7
// =====================================================================================================================}
// CALCULATIONS
// ====================================================================================================================={// @function regression_indicator is a Normalized Ratio of Regression Lines with close
regression_indicator(src, length) =>
sum_x = 0.0
sum_y = 0.0
sum_xy = 0.0
sum_x_sq = 0.0
distance = 0.0
// Calculate Sum
for i = 0 to length – 1 by 1
sum_x += i + 1
sum_y += src[i]
sum_xy += (i + 1) * src[i]
sum_x_sq += math.pow(i + 1, 2)// Calculate linear regression coefficients
slope = (length * sum_xy – sum_x * sum_y)
/ (length * sum_x_sq – math.pow(sum_x, 2))
intercept = (sum_y – slope * sum_x) / length// Calculate Regression Indicator
y1 = intercept + slope
distance := (close – y1)
distance_n = ta.sma((distance – ta.sma(distance, length1))
/ ta.stdev(distance, length1), 10)[distance_n, y1]
[y, y1] = regression_indicator(close, length)
// Signal Lines
mean = ta.sma(y, length2)
mean1 = ta.ema(y, 5)
// Conditions
cond1 = ta.crossunder(mean1, mean) and y > 0
cond2 = ta.crossover(mean1, mean) and y < 0
cond3 = ta.crossover(y, 0)
cond4 = ta.crossunder(y, 0)// =====================================================================================================================}
// PLOT
// ====================================================================================================================={
// Candles Colors
color = y > 0 ? color.from_gradient(y, 0, 1, na, m_color) : color.from_gradient(y, -1, 0, chart.fg_color, na)barcolor(color)
plotcandle(open, high, low, close, “Color Candles”,
color = color,
wickcolor = color,
bordercolor = color,
force_overlay = true
)// Plot Regression Line
plot(series = y1,
title = “Regression Line”,
color = color,
linewidth = 2,
force_overlay = true
)
// Plot Regression Indicator
p1 = plot(series = y,
title = “Regression Indicator”,
color = color,
linewidth = 1
)p0 = plot(series = 0,
title = “Zero Line”,
color = color,
linewidth = 1
)// Fill Color Regression Indicator
fill(p1, p0, 2.5, 0, m_color, na, title = “Upper Fill”)
fill(p1, p0, 0, -2.5, na, chart.fg_color, title = “Lower Fill”)// Signal Line
plot(mean, color = color.rgb(3, 100, 165, 52), linewidth = 2)// Arrow Trend Direction
var txt = “”
switch
cond3 => txt := “➚”
cond4 => txt := “➘”if barstate.islast
label.delete(
label.new(
x = bar_index+3,
y = y1,
text = txt,
style = label.style_label_center,
color = color(na),
textcolor = color,
size = size.huge,
force_overlay = true
)[1]
)// Reversion Signals
if cond1
label.new(
x = bar_index,
y = high,
text = “◓”,
style = label.style_label_down,
color = color(na),
textcolor = chart.fg_color,
size = size.large,
force_overlay = true
)if cond2
label.new(
x = bar_index,
y = low,
text = “◒”,
style = label.style_label_up,
color = color(na),
textcolor = m_color,
size = size.large,
force_overlay = true
)// Trend Signals
plotchar(cond3 ? 0 : na, “TrendUp”, “⦿”,
location = location.absolute,
size = size.small,
color = #0364a5
)
plotchar(cond3 ? close : na, “TrendUp”, “⦿”,
location = location.absolute,
size = size.small,
color = #0364a5,
force_overlay = true
)plotchar(cond4 ? 0 : na, “TrendDn”, “⦿”,
location = location.absolute,
size = size.small,
color = chart.fg_color
)
plotchar(cond4 ? close : na, “TrendDn”, “⦿”,
location = location.absolute,
size = size.small,
color = chart.fg_color,
force_overlay = true
)// =====================================================================================================================}
09/05/2024 at 9:30 AM #237117Buenas! Aquí tienes la traducción
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374//-------------------------------------------------------////PRC_Regression Oscilator//version = 0//05.09.2024//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//-------------------------------------------------------////-----Inputs--------------------------------------------////-------------------------------------------------------//length=400 //regression Lengthlength1=100 //regression normalizationlength2=50 //signal lane//-------------------------------------------------------////-----Regression Calculation----------------------------////-------------------------------------------------------//src=closesumx=0sumy=0sumxy=0sumxsq=0distance=0//Calculate sumfor i=0 to length-1 dosumx=sumx+i+1sumy=sumy+src[i]sumxy=sumxy+(i+1)*src[i]sumxsq=sumxsq+pow(i+1,2)next//Calculate linear regression coefficientsslope=(length*sumxy-sumx*sumy)/(length*sumxsq-pow(sumx,2))intercept=(sumy-slope*sumx)/length//Calculate Regression indicatory1=intercept+slopedistance=(close-y1)distanceN=average[10]((distance-average[length1](distance))/std[length1](distance))//-------------------------------------------------------////-----Signal Lines--------------------------------------////-------------------------------------------------------//y=distanceNmean=average[length2](y)mean1=average[5](y)//-------------------------------------------------------////-----Conditions----------------------------------------////-------------------------------------------------------//cond1=mean1 crosses under mean and y>0cond2=mean1 crosses over mean and y<0cond3=y crosses over 0cond4=y crosses under 0//-------------------------------------------------------////-----Plot----------------------------------------------////-------------------------------------------------------//if y>0 thenr=0g=255b=255elser=255g=0b=255endif//Reversion Signalsif cond1 thendrawtext("▼",barindex,mean)coloured("fuchsia")elsif cond2 thendrawtext("▲",barindex,mean)coloured(0,255,255)endif//Trend Signalsif cond3 thendrawpoint(barindex,0,3)coloured("lightgreen")elsif cond4 thendrawpoint(barindex,0,3)coloured("red")endif//-------------------------------------------------------//return y as "Regression Line" coloured(r,g,b)style(line,3), 0 as "Zero" style(dottedline), mean as "mean"coloured(3,100,165)style(line,2)1 user thanked author for this post.
09/05/2024 at 9:38 AM #237118Y este sería el mismo indicador pero en precio
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081//-------------------------------------------------------////PRC_Regression Oscilator on Price//version = 0//05.09.2024//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//-------------------------------------------------------////-----Inputs--------------------------------------------////-------------------------------------------------------//length=400 //regression Lengthlength1=100 //regression normalizationlength2=50 //signal lanecolorcandle=1trendsignal=1revsignal=1//-------------------------------------------------------////-----Regression Calculation----------------------------////-------------------------------------------------------//src=closesumx=0sumy=0sumxy=0sumxsq=0distance=0//Calculate sumfor i=0 to length-1 dosumx=sumx+i+1sumy=sumy+src[i]sumxy=sumxy+(i+1)*src[i]sumxsq=sumxsq+pow(i+1,2)next//Calculate linear regression coefficientsslope=(length*sumxy-sumx*sumy)/(length*sumxsq-pow(sumx,2))intercept=(sumy-slope*sumx)/length//Calculate Regression indicatory1=intercept+slopedistance=(close-y1)distanceN=average[10]((distance-average[length1](distance))/std[length1](distance))//-------------------------------------------------------////-----Signal Lines--------------------------------------////-------------------------------------------------------//y=distanceNmean=average[length2](y)mean1=average[5](y)//-------------------------------------------------------////-----Conditions----------------------------------------////-------------------------------------------------------//cond1=mean1 crosses under mean and y>0cond2=mean1 crosses over mean and y<0cond3=y crosses over 0cond4=y crosses under 0//-------------------------------------------------------////-----Plot----------------------------------------------////-------------------------------------------------------//if y>0 thenr=0g=255b=255elser=255g=0b=255endif//Reversion Signalsif revsignal and cond1 thendrawtext("▼",barindex,high+0.25*tr)coloured("fuchsia")elsif revsignal and cond2 thendrawtext("▲",barindex,low-0.25*tr)coloured(0,255,255)endif//Trend Signalsif trendsignal and cond3 thendrawpoint(barindex,close,3)coloured("lightgreen")elsif trendsignal and cond4 thendrawpoint(barindex,close,3)coloured("red")endif//Draw candlesif colorcandle thendrawcandle(open,high,low,close)coloured(r,g,b,150)endif//-------------------------------------------------------//return y1 as "Regression Line" coloured(r,g,b)style(line,3)1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on