Fórmulas

Para TradingView

Compartimos con toda la comunidad las fórmulas que utilizamos en Clave Bursátil

Hace clic en el botón para copiar la fórmula a tu portapapeles.

ADR CCL

(BCBA:GGAL/NASDAQ:GGAL*10+BCBA:BMA/NYSE:BMA*10+BCBA:YPFD/NYSE:YPF+BCBA:PAMP/NYSE:PAM*25+BCBA:BBAR/NYSE:BBAR*3)/5

CEDEAR EN CCL

(BCBA:AAPL*10/NASDAQ:AAPL+BCBA:TSLA*15/NASDAQ:TSLA+BCBA:KO*5/NYSE:KO+BCBA:GOLD/NYSE:GOLD+BCBA:AMZN*144/NASDAQ:AMZN)/5

MERVAL EN CCL

BCBA:IMV/(BCBA:GGAL/NASDAQ:GGAL*10)

GGAL EN CCL

BCBA:GGAL/NASDAQ:GGAL*10

Pine Script

Editor de código

A continuación te dejamos algunos scripts creados por miembros de la comunidad Clave Bursátil

🙌 🤩

Muchas gracias por el gran aporte a toda la comunidad!

Copia el código del script y pegalo dentro de la ventada del Editor Pine de TradingView.

Atención! En caso de que el script te genere algún error, reemplaza las “comillas dobles” por ‘comillas simple’ en tu Editor Pine.

Semáforo


//@version=4
study(title="SEMAFORO", shorttitle="CB", overlay=true, resolution="")
texto=input (title="texto",type=input.string,defval= "COMUNIDAD CLAVE BURSATIL")
periodo= input(21,"Período corto",input.integer)
periodo2= input(50,"Período mediano",input.integer)
periodo3= input(200,"Período largo",input.integer)

////////////////////////////////////////////////////////////////////////////////////////////////
suavizado = input(title="Media móvil corta ", defval="WMA", options=["WMA","EMA", "SMA", "RMA"])
suavizado2 = input(title="Media móvil mediana ", defval="SMA", options=["SMA","EMA", "WMA", "RMA"])
suavizado3 = input(title="Media móvil larga ", defval="SMA", options=["SMA","EMA", "WMA", "RMA"])

////////////////////////////////////////////////////////////////////////////////////////////////

primero(source, length) =>
    if suavizado == "WMA"
        wma(source, length)
    else
        if suavizado  == "EMA"
            ema(source, length)
        else
            if suavizado == "SMA"
                sma(source, length)
            else
                rma(source, length)

////////////////////////////////////////////////////////////////////////////////////////////////

segundo(source, length) =>
    if suavizado2 == "SMA"
        sma(source, length)
    else
        if suavizado2  == "EMA"
            ema(source, length)
        else
            if suavizado2 == "WMA"
                wma(source, length)
            else
                rma(source, length)

////////////////////////////////////////////////////////////////////////////////////////////////

tercero(source, length) =>
    if suavizado3 == "SMA"
        sma(source, length)
    else
        if suavizado3  == "EMA"
            ema(source, length)
        else
            if suavizado3 == "WMA"
                wma(source, length)
            else
                rma(source, length)

////////////////////////////////////////////////////////////////////////////////////////////////
mm = primero(close, periodo)
mm2 = segundo(close, periodo2)
mm3 = tercero(close, periodo3)

////////////////////////////////////////////////////////////////////////////////////////////////

plot(mm,color=#FFEB3B)
plot(mm2,color=#4CAF50)
plot(mm3,color=#FF5252)

medias bollinger psar


// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © facien - powered by © fpucci

//@version=4
study("MA's BOL PSAR CROSS - FAcien FPucci", shorttitle='MultiIndicator - FAcien FPucci',max_bars_back=1000, overlay=true)

//Inputs
Bollinger_MA_type = input("EMA",title='Bollinger MA type', options=["OFF","SMA","EMA","WMA","VWMA","RMA"])
Bollinger_MA_value = input(21,title='Bollinger MA value')

MA_type_1 = input("EMA",title="1st Type of MA's", options=["OFF","SMA","EMA","WMA","VWMA","RMA"])
m1 = input(8,title="Moving Average 1")
m2 = input(21,title="Moving Average 2")
m3 = input(50,title="Moving Average 3")
m4 = input(100,title="Moving Average 4")
m5 = input(200,title="Moving Average 5")

MA_type_2 = input("OFF",title="2nd Type of MA's", options=["OFF","SMA","EMA","WMA","VWMA","RMA"])
m6 = input(10,title="Moving Average 6")
m7 = input(30,title="Moving Average 7")
m8 = input(200,title="Moving Average 8")

show_Golden = input(true,title='Show Golden Crossing')
show_Death = input(true,title='Show Death Crossing')
Crossing_1 = input("OFF",title="1st Crossing MA", options=["OFF","MA 1 <=> MA 2","MA 1 <=> MA 3","MA 1 <=> MA 4","MA 1 <=> MA 5","MA 2 <=> MA 3","MA 2 <=> MA 4","MA 2 <=> MA 5","MA 3 <=> MA 4","MA 3 <=> MA 5","MA 4 <=> MA 5"])
Crossing_2 = input("OFF",title="2nd Crossing MA", options=["OFF","MA 1 <=> MA 2","MA 1 <=> MA 3","MA 1 <=> MA 4","MA 1 <=> MA 5","MA 2 <=> MA 3","MA 2 <=> MA 4","MA 2 <=> MA 5","MA 3 <=> MA 4","MA 3 <=> MA 5","MA 4 <=> MA 5"])
Crossing_3 = input("OFF",title="3rd Crossing MA", options=["OFF","MA 1 <=> MA 2","MA 1 <=> MA 3","MA 1 <=> MA 4","MA 1 <=> MA 5","MA 2 <=> MA 3","MA 2 <=> MA 4","MA 2 <=> MA 5","MA 3 <=> MA 4","MA 3 <=> MA 5","MA 4 <=> MA 5"])
Crossing_4 = input("OFF",title="4th Crossing MA", options=["OFF","MA 1 <=> MA 2","MA 1 <=> MA 3","MA 1 <=> MA 4","MA 1 <=> MA 5","MA 2 <=> MA 3","MA 2 <=> MA 4","MA 2 <=> MA 5","MA 3 <=> MA 4","MA 3 <=> MA 5","MA 4 <=> MA 5"])
Crossing_5 = input("OFF",title="5th Crossing MA", options=["OFF","MA 1 <=> MA 2","MA 1 <=> MA 3","MA 1 <=> MA 4","MA 1 <=> MA 5","MA 2 <=> MA 3","MA 2 <=> MA 4","MA 2 <=> MA 5","MA 3 <=> MA 4","MA 3 <=> MA 5","MA 4 <=> MA 5"])

//selected_ma function
selected_ma(type, value) => 
    if type=='EMA'
        ema(close, value)
    else if type=='WMA'
        wma(close, value)
    else if type=='SMA'
        sma(close, value)
    else if type=='VWMA'
        vwma(close, value)
    else if type=='RMA'
        rma(close, value)
    else
        na
        

///////// BOLLINGER /////////
//Calculo Bollinger
bolliMax = selected_ma(Bollinger_MA_type, Bollinger_MA_value) + 2* stdev(close, Bollinger_MA_value)
bolliMin = selected_ma(Bollinger_MA_type, Bollinger_MA_value) - 2* stdev(close, Bollinger_MA_value)

//Plot Bollinger
b1 = plot(bolliMax, color=color.silver, linewidth=1, title='Bollinger_Max')
b2 = plot(bolliMin, color=color.silver, linewidth=1, title='Bollinger_Min')
fill(b1,b2,color=color.white, title='Bollinger_Background')

///////// MOVING AVERAGES //////////
//MA_type_1
ma1 = selected_ma(MA_type_1, m1)
ma2 = selected_ma(MA_type_1, m2)
ma3 = selected_ma(MA_type_1, m3)
ma4 = selected_ma(MA_type_1, m4)
ma5 = selected_ma(MA_type_1, m5)

//MA_type_2
ma6 = selected_ma(MA_type_2, m6)
ma7 = selected_ma(MA_type_2, m7)
ma8 = selected_ma(MA_type_2, m8)


//Plot EMAs
plot(ma1, color=color.green, linewidth=1, title="Moving Average 1")
plot(ma2, color=color.red, linewidth=1, title="Moving Average 2")
plot(ma3, color=color.purple, linewidth=1, title="Moving Average 3")
plot(ma4, color=color.orange, linewidth=1, title="Moving Average 4")
plot(ma5, color=color.yellow, linewidth=1, title="Moving Average 5")
plot(ma6, color=color.aqua, linewidth=1, title="Moving Average 6")
plot(ma7, color=color.blue, linewidth=1, title="Moving Average 7")
plot(ma8, color=color.fuchsia, linewidth=1, title="Moving Average 8")


//Golden Crossing
golden_Crossing(media1, media2) => 
    mean1 = selected_ma(MA_type_1, media1)
    mean2 = selected_ma(MA_type_1, media2)
    if crossover(mean1,mean2) and show_Golden
        label.new(bar_index, selected_ma(MA_type_1, media1), yloc=yloc.belowbar, color=color.white, style=label.style_label_up, text=(tostring(media1)+"▲"+tostring(media2)), textcolor=color.green)

//Death_Crossing
death_Crossing(media1, media2) => 
    mean1 = selected_ma(MA_type_1, media1)
    mean2 = selected_ma(MA_type_1, media2)
    if crossunder(mean1,mean2) and show_Death
        label.new(bar_index, mean1, yloc=yloc.abovebar, color=color.white, style=label.style_label_down, text=(tostring(media1)+"▼"+tostring(media2)), textcolor=color.red)

selected_Crossing(Cossing) =>
    if Cossing == "MA 1 <=> MA 2"
        golden_Crossing(m1,m2)
        death_Crossing(m1,m2)
    else if Cossing == "MA 1 <=> MA 3"
        golden_Crossing(m1,m3)
        death_Crossing(m1,m3)
    else if Cossing == "MA 1 <=> MA 4"
        golden_Crossing(m1,m4)
        death_Crossing(m1,m4)
    else if Cossing == "MA 1 <=> MA 5"
        golden_Crossing(m1,m5)
        death_Crossing(m1,m5)
    else if Cossing == "MA 2 <=> MA 3"
        golden_Crossing(m2,m3)
        death_Crossing(m2,m3)
    else if Cossing == "MA 2 <=> MA 4"
        golden_Crossing(m2,m4)
        death_Crossing(m2,m4)
    else if Cossing == "MA 2 <=> MA 5"
        golden_Crossing(m2,m5)
        death_Crossing(m2,m5)
    else if Cossing == "MA 3 <=> MA 4"
        golden_Crossing(m3,m4)
        death_Crossing(m3,m4)
    else if Cossing == "MA 3 <=> MA 5"
        golden_Crossing(m3,m5)
        death_Crossing(m3,m5)
    else if Cossing == "MA 4 <=> MA 5"
        golden_Crossing(m4,m5)
        death_Crossing(m4,m5)
    else
        na

selected_Crossing(Crossing_1)
selected_Crossing(Crossing_2)
selected_Crossing(Crossing_3)
selected_Crossing(Crossing_4)
selected_Crossing(Crossing_5)

/////////// Parabollic SAR /////////////
showSAR = input(true,title='Parabollic SAR')
start = input(title = "Parabollic SAR - Start", defval = 0.02, step = 0.001)
increment = input(title = "Parabollic SAR - Increment", defval = 0.02, step = 0.001)
maximum = input(title = "Parabollic SAR - Max Value", defval = 0.2, step = 0.01)
putlabel = input(title = "Parabollic SAR - Show Labels", defval = true)

int trend = 0
float sar = 0.0
float ep = 0.0
float af = 0.0

trend := nz(trend[1])
ep := nz(ep[1])
af :=nz(af[1])
sar := sar[1]

if trend == 0 and not na(high[1])
    trend := high >= high[1] or low >= low[1] ? 1 : -1
    sar := trend > 0 ? low[1] : high[1]
    ep := trend > 0 ? high[1] : low[1]
    af := start
else 
    nextsar = sar
    if trend > 0
        if high[1] > ep
            ep := high[1]
            af := min(maximum, af + increment)
            
        nextsar := sar + af * (ep - sar)
        nextsar := min(min(low[1], low[2]), nextsar)
        
        //Reversal
        if nextsar > low
            trend := -1
            nextsar := ep
            ep := low
            af := start
    else 
        if low[1] < ep
            ep := low[1]
            af := min(maximum, af + increment)
        
        nextsar := sar + af * (ep - sar)
        nextsar := max(max(high[1], high[2]), nextsar)
        
        //Reversal
        if nextsar < high
            trend := 1
            nextsar := ep
            ep := high
            af := start
    sar := nextsar

plot(iff(showSAR,sar,na), title = "Parabolic SAR", color = trend > 0 ? color.green : color.red, linewidth = 1, style = plot.style_circles)

if change(trend) > 0 and putlabel
    label.new(bar_index, sar, color = color.lime, style=label.style_labelup, size = size.tiny)
if change(trend) < 0 and putlabel
    label.new(bar_index, sar, color = color.red, style=label.style_labeldown, size = size.tiny)

RSI MACD KONCORD


//@version=4
study(title="Konkord + MACD + RSI + STOCH - FAcien/Fromhell", shorttitle="Macd/Konkorde/Rsi")

//KONCORDE
showkoncorde = input(true, title='Koncorde')
deltaKon = input(-350, title="KONCORDE - Desfase")

calc_mfi(length) => rsi(sum(volume * (change(hlc3) <= 0 ? 0 : hlc3), length), sum(volume * (change(hlc3) >= 0 ? 0 : hlc3), length))

tprice=ohlc4
lengthEMA = 255
m=15
pvim = ema(pvi, m)
pvimax = highest(pvim, 90)
pvimin = lowest(pvim, 90)
oscp = (pvi - pvim) * 100/ (pvimax - pvimin)
nvim = ema(nvi, m)
nvimax = highest(nvim, 90)
nvimin = lowest(nvim, 90)
azul = (nvi - nvim) * 100 / (nvimax - nvimin)
xmf = calc_mfi(14)
mult=2.0
basis = sma(tprice, 25)
dev = mult * stdev(tprice, 25)
upper = basis + dev
lower = basis - dev
OB1 = (upper + lower) / 2.0
OB2 = upper - lower
BollOsc = ((tprice - OB1) / OB2 ) * 100
xrsi = rsi(tprice, 14)
calc_stoch(src, length,smoothFastD ) => sma(100 * (src - lowest(low, length)) / (highest(high, length) - lowest(low, length)), smoothFastD)

stoc = calc_stoch(tprice, 21, 3)
marron = (xrsi + xmf + BollOsc + (stoc / 3))/2
verde = marron + oscp
media = ema(marron,m)

vl=plot(iff(showkoncorde,verde+deltaKon,na),color=#66FF66,style=plot.style_area,histbase=deltaKon, linewidth=2,title="Koncorde - verde")// COLOURED(102,255,102) as “verde” , GREEN
ml=plot(iff(showkoncorde,marron+deltaKon,na), color=#FFCC99,style=plot.style_area,histbase=deltaKon, linewidth=2,  title="Koncorde - marron", transp=0) // COLOURED(255,204,153) as"marron" , BEIGE
al=plot(iff(showkoncorde,azul+deltaKon,na), color=#00FFFF,style=plot.style_area,histbase=deltaKon, linewidth=2,  title="Koncorde - azul") // COLOURED(0,255,255) as “azul” ,
plot(iff(showkoncorde,marron+deltaKon,na), color=color.maroon, linewidth=2, title="Koncorde - lmarron") // COLOURED(51,0,0) as “lmarron” ,
plot(iff(showkoncorde,verde+deltaKon,na), color=#006600, linewidth=2, title="Koncorde - lineav") // COLOURED(0,102,0) as “lineav” ,
plot(iff(showkoncorde,azul+deltaKon,na), color=#000066, linewidth=2, title="Koncorde - lazul") // COLOURED(0,0,102) as “lazul” ,
plot(iff(showkoncorde,media+deltaKon,na), color=color.red, linewidth=2, title="Koncorde - media")  // COLOURED(255,0,0) as “media” ,

// MACD
// Getting inputs
showmacd = input(true, title='MADC')
deltaMacd = input(300, title="MACD - Desfase")
multMacd = input(5, title="MACD - Escala")
fast_length = input(title="MACD - Fast Length", type=input.integer, defval=12)
slow_length = input(title="MACD - Slow Length", type=input.integer, defval=26)
src = input(title="MACD - Source", type=input.source, defval=close)
signal_length = input(title="MACD - Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)
sma_source = input(title="MACD - Simple MA(Oscillator)", type=input.bool, defval=false)
sma_signal = input(title="MACD - Simple MA(Signal Line)", type=input.bool, defval=false)

// Plot colors
col_grow_above = #26A69A
col_grow_below = #FFCDD2
col_fall_above = #B2DFDB
col_fall_below = #EF5350
col_macd = #0094ff
col_signal = #ff6a00

// Calculating
//[outMacD, outSignal, outHist] = macd(close, fastLength, slowLength, signalLength)
fast_ma = sma_source ? sma(src, fast_length) : ema(src, fast_length)
slow_ma = sma_source ? sma(src, slow_length) : ema(src, slow_length)
macd = (fast_ma - slow_ma) / slow_ma * 1000 * multMacd
signal = sma_signal ? sma(macd, signal_length) : ema(macd, signal_length)
hist = macd - signal


plot(iff(showmacd,hist ? hist + deltaMacd : na,na), title="MACD - Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : (hist[1] < hist ? col_grow_below : col_fall_below) ), transp=0,histbase=deltaMacd )
plot(iff(showmacd,macd ? macd + deltaMacd: na,na), title="MACD", color=col_macd, transp=0)
plot(iff(showmacd,signal ? signal + deltaMacd: na,na), title="MACD - Signal", color=col_signal, transp=0)


// STOCH (14,3,1)
showrsi = input(true, title='RSI - STOCH')
deltaRSI = input(0, title="RSI/STOCH - Desfase")
multip = input(5, title="RSI/STOCH - Escalado")
deltaSTOCH = deltaRSI-50*multip/2
length = input(14, minval=1, title="STOCH - Periodo")
smoothK = input(1, minval=1, title="STOCH - Smooth K")
smoothD = input(3, minval=1, title="STOCH - Smooth D")
k = sma ( stoch (close, high, low, length), smoothK)
d = sma (k, smoothD)

// RSI

hline(iff(showrsi,0+deltaRSI,na), color=color.yellow, linestyle=hline.style_dashed,linewidth=1)
hline(iff(showrsi,-20*multip+deltaRSI,na), color=color.green, linestyle=hline.style_dashed)
hline(iff(showrsi,20*multip+deltaRSI,na), color=color.red, linestyle=hline.style_dashed)
lengthRSI = input(14, minval=1, title="RSI - Periodo")
RSIMain = (rsi(close, lengthRSI) - 50)
rsiPlot = plot(iff(showrsi,RSIMain*multip+deltaRSI,na), color=color.purple, linewidth  = 3)

Compartí con la comunidad

Publica tu Fórmula o Script

Envíanos en un archivo TXT la fórmula o el script que hayas creado y nosotros lo publicaremos en esta sección, para compartir con toda la comunidad

    Seguinos en las redes

    19205

    Facebook

    15400

    Twitter

    22800

    YouTube

    11300

    Instagram