MA Sabres TW
Forums › ProRealTime forum Italiano › Supporto ProBuilder › MA Sabres TW
- This topic has 2 replies, 3 voices, and was last updated 1 week ago by Iván.
-
-
12/08/2024 at 12:20 AM #241251
Ciao, chiedo la traduzione di questo indicatore:( https://www.tradingview.com/script/viwa6CR8-MA-Sabres-LuxAlgo/):
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo//@version=5
indicator(‘MA Sabres [LuxAlgo]’, shorttitle=’LuxAlgo – MA Sabres’, max_polylines_count=100, overlay=true)//——————————————————————————
//Settings
//—————————————————————————–{
type = input.string( “TEMA” , ‘MA Type’ , group= ‘MA’
, options = [“SMA”, “EMA”, “SMMA (RMA)”, “HullMA”, “WMA”, “VWMA”, “DEMA”, “TEMA”, “NONE”])
len = input.int ( 50 , ‘Length’ , group= ‘MA’ )
count = input.int ( 20 , ‘Previous Trend Duration’ , group= ‘MA’
, tooltip = ‘Reversal after x bars in the same direction’ )
colUp = input.color (#2962ff, ‘Bullish’ , group=’Colours’)
colDn = input.color (#f23645, ‘Bearish’ , group=’Colours’)
colMa = input.color (#787b86, ‘MA’ , group=’Colours’)//—————————————————————————–}
//Method MA
//—————————————————————————–{
method ma(string type, int length) =>
//
ema1 = ta.ema(close, length)
ema2 = ta.ema(ema1 , length)
ema3 = ta.ema(ema2 , length)
//
switch type
“SMA” => ta.sma (close, length)
“EMA” => ema1
“SMMA (RMA)” => ta.rma (close, length)
“HullMA” => ta.hma (close, length)
“WMA” => ta.wma (close, length)
“VWMA” => ta.vwma(close, length)
“DEMA” => 2 * ema1 – ema2
“TEMA” => (3 * ema1) – (3 * ema2) + ema3
=> na//—————————————————————————–}
//Calculations
//—————————————————————————–{
ma = type.ma(len)
fl = ta.falling(ma , count)
rs = ta.rising (ma , count)
up = fl[1] and ma > ma[1]
dn = rs[1] and ma < ma[1]
atr = ta.atr(14)
n = bar_index//—————————————————————————–}
//Execution
//—————————————————————————–{
if up
p = array.new<chart.point>()
p.push(chart.point.from_index(n – 1 , low [1] – atr / 15 ))
p.push(chart.point.from_index(n + (len / 2 -1) , low [1] + atr / 2.5))
p.push(chart.point.from_index(n + len , low [1] + atr * 2 ))
p.push(chart.point.from_index(n + (len / 2 -1) , low [1] + atr / 2.5))
p.push(chart.point.from_index(n – 1 , low [1] + atr / 15 ))
polyline.new(p
, curved = true
, closed = false
, line_color = colUp
, fill_color = color.new(colUp, 50))if dn
p = array.new<chart.point>()
p.push(chart.point.from_index(n – 1 , high[1] + atr / 15 ))
p.push(chart.point.from_index(n + (len / 2 -1) , high[1] – atr / 2.5))
p.push(chart.point.from_index(n + len , high[1] – atr * 2 ))
p.push(chart.point.from_index(n + (len / 2 -1) , high[1] – atr / 2.5))
p.push(chart.point.from_index(n – 1 , high[1] – atr / 15 ))
polyline.new(p
, curved = true
, closed = false
, line_color = colDn
, fill_color = color.new(colDn, 50))//—————————————————————————–}
//Plots
//—————————————————————————–{
plot (ma , ‘MA’ , color= colMa )plotshape(up ? low [1] : na, ”, color= colUp , location=location.absolute, style=shape.circle, size=size.tiny , offset=-1)
plotshape(up ? low [1] : na, ”, color=color.new(colUp, 50), location=location.absolute, style=shape.circle, size=size.small , offset=-1)
plotshape(up ? low [1] : na, ”, color=color.new(colUp, 65), location=location.absolute, style=shape.circle, size=size.normal, offset=-1)plotshape(dn ? high[1] : na, ”, color= colDn , location=location.absolute, style=shape.circle, size=size.tiny , offset=-1)
plotshape(dn ? high[1] : na, ”, color=color.new(colDn, 50), location=location.absolute, style=shape.circle, size=size.small , offset=-1)
plotshape(dn ? high[1] : na, ”, color=color.new(colDn, 65), location=location.absolute, style=shape.circle, size=size.normal, offset=-1)//—————————————————————————–}
12/09/2024 at 9:57 AM #241267Si può avere anche uno scrinner?
Grazie
12/09/2024 at 11:26 AM #241271Eccolo qui:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128//-------------------------------------////PRC_MA Sabres//version = 0//09.12.2024//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//-------------------------------------//// Inputs//-------------------------------------//len=50count=20UseTEMA=1MaType=2//-------------------------------------////Method MA//-------------------------------------//if UseTEMA thenma=tema[len](close)elsema=average[len,MaType](close)endif//-------------------------------------////Calculations//-------------------------------------//// MA fallingif ma<=lowest[count](ma) thenfl=1elsefl=0endifup=fl[1] and ma>ma[1]// MA risingif ma>=highest[count](ma) thenrs=1elsers=0endifdn=rs[1] and ma<ma[1]//ATR calculationatr=averagetruerange[14](close)n=barindex//-------------------------------------////Calculations//-------------------------------------//if up and summation[len](up)=1 then// Puntos fijosxx1 = n-1xx9 = n+lenyy1 = low[1] - atr / 15yy9 = low[1] + atr * 2// Calcular los puntos intermedios en X (división uniforme)xx2 = xx1 + (xx9 - xx1) * 1 / 8xx3 = xx1 + (xx9 - xx1) * 2 / 8xx4 = xx1 + (xx9 - xx1) * 3 / 8xx5 = xx1 + (xx9 - xx1) * 4 / 8xx6 = xx1 + (xx9 - xx1) * 5 / 8xx7 = xx1 + (xx9 - xx1) * 6 / 8xx8 = xx1 + (xx9 - xx1) * 7 / 8// Ecuación cuadrática para Y (emular parábola)aa = (yy9 - yy1) / pow((xx9 - xx1), 2) // Calcular el coeficiente de la parábolayy2 = yy1 + aa * pow((xx2 - xx1), 2)yy3 = yy1 + aa * pow((xx3 - xx1), 2)yy4 = yy1 + aa * pow((xx4 - xx1), 2)yy5 = yy1 + aa * pow((xx5 - xx1), 2)yy6 = yy1 + aa * pow((xx6 - xx1), 2)yy7 = yy1 + aa * pow((xx7 - xx1), 2)yy8 = yy1 + aa * pow((xx8 - xx1), 2)// Dibujar segmentosdrawsegment(xx1,yy1,xx2,yy2)coloured("blue")drawsegment(xx3,yy3,xx2,yy2)coloured("blue")drawsegment(xx3,yy3,xx4,yy4)coloured("blue")drawsegment(xx5,yy5,xx4,yy4)coloured("blue")drawsegment(xx5,yy5,xx6,yy6)coloured("blue")drawsegment(xx7,yy7,xx6,yy6)coloured("blue")drawsegment(xx7,yy7,xx8,yy8)coloured("blue")drawsegment(xx9,yy9,xx8,yy8)coloured("blue")//DrawPointsdrawpoint(xx1,yy1,1)coloured("blue")drawpoint(xx1,yy1,3)coloured("blue",70)drawpoint(xx1,yy1,5)coloured("blue",30)endifif dn and summation[len](dn) = 1 then// Puntos fijosx1 = n-1x9 = n+leny1 = high[1] + atr / 15y9 = high[1] - atr * 2// Calcular los puntos intermedios en X (división uniforme)x2 = x1 + (x9 - x1) * 1 / 8x3 = x1 + (x9 - x1) * 2 / 8x4 = x1 + (x9 - x1) * 3 / 8x5 = x1 + (x9 - x1) * 4 / 8x6 = x1 + (x9 - x1) * 5 / 8x7 = x1 + (x9 - x1) * 6 / 8x8 = x1 + (x9 - x1) * 7 / 8// Ecuación cuadrática para Y (emular parábola)a = (y9 - y1) / pow((x9 - x1), 2) // Calcular el coeficiente de la parábolay2 = y1 + a * pow((x2 - x1), 2)y3 = y1 + a * pow((x3 - x1), 2)y4 = y1 + a * pow((x4 - x1), 2)y5 = y1 + a * pow((x5 - x1), 2)y6 = y1 + a * pow((x6 - x1), 2)y7 = y1 + a * pow((x7 - x1), 2)y8 = y1 + a * pow((x8 - x1), 2)// Dibujar segmentosdrawsegment(x1,y1,x2,y2)coloured("red")drawsegment(x3,y3,x2,y2)coloured("red")drawsegment(x3,y3,x4,y4)coloured("red")drawsegment(x5,y5,x4,y4)coloured("red")drawsegment(x5,y5,x6,y6)coloured("red")drawsegment(x7,y7,x6,y6)coloured("red")drawsegment(x7,y7,x8,y8)coloured("red")drawsegment(x9,y9,x8,y8)coloured("red")//DrawPointsdrawpoint(x1,y1,1)coloured("red")drawpoint(x1,y1,3)coloured("red",70)drawpoint(x1,y1,5)coloured("red",30)endifreturn ma as "Moving Average" coloured("Grey")style(line,2) -
AuthorPosts
Find exclusive trading pro-tools on