Fórmulas

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

Datos de mercados por TradingView, una plataforma para inversores con herramientas como el scanner de acciones o el calendario económico

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

BRECHA CAMBIARIA (OFICIAL vs CCL)

((BCBA:AAPL/NASDAQ:AAPL*20+BCBA:YPFD/NYSE:YPF)/2-FX_IDC:USDARS)/FX_IDC:USDARS*100

DÓLAR CCL DE ACCIONES

(BCBA:YPFD/NYSE:YPF+BCBA:PAMP/NYSE:PAM*25+BCBA:SUPV/NYSE:SUPV*5)/3

DÓLAR CCL DE CEDEARS

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

DÓLAR CCL AJUSTADO POR INFLACIÓN (ARGENTINA)

BCBA:YPFD/NYSE:YPF/(ECONOMICS:ARCPI/7122)

MERVAL EN CCL

BCBA:IMV/(BCBA:AAPL/NASDAQ:AAPL*20)

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.

//========================================================================================================
//= 1 - 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)


//========================================================================================================
//= 2 - 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)




//========================================================================================================
//= 3 - 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)





//========================================================================================================
//= 4 - Clave MACD KKD RSI SToch NORB
//========================================================================================================

//@version=4
study(title="Clave MACD KKD RSI SToch NORB", shorttitle="Macd/Konkorde/Rsi/Stoch")

//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='MACD')
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)
showrsiStoch = input(true, title='RSI - STOCH')

deltaRSI = input(0, title="RSI/STOCH - Desfase")
multip = input(5, title="RSI/STOCH - Escalado")

deltaSTOCH = deltaRSI-50*multip/2

smoothK = input(3, "K", minval=1)
smoothD = input(3, "D", minval=1)
lengthRSI = input(14, "RSI Length", minval=1)
lengthStoch = input(14, "Stochastic Length", minval=1)
srcx = input(close, title="RSI Source")
rsi1 = rsi(srcx, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)-50
d = sma(k, smoothD)

// RSI
showrsi = input(true, title='RSI')
hline(iff(showrsi,0+deltaRSI,na), color=color.yellow, linestyle=hline.style_dashed,linewidth=1)
band0 = hline(iff(showrsi,-25*multip+deltaRSI,na), color=color.green, linestyle=hline.style_dashed)
band1 = hline(iff(showrsi,25*multip+deltaRSI,na), color=color.red, linestyle=hline.style_dashed)

fill(band1, band0, color=#9915FF, transp=90, title="Background")

RSIMain = (rsi(close, lengthRSI) - 50)
rsiPlot = plot(iff(showrsi,RSIMain*multip+deltaRSI,na), color=color.purple, linewidth  = 3)
plot(iff(showrsiStoch, k*multip+deltaRSI, na) , "K", color=#0094FF)
plot(iff(showrsiStoch, d*multip+deltaRSI, na) , "D", color=#FF6A00)




//========================================================================================================
//= 5- MEDIAS FIJAS
//========================================================================================================

//@version=4
study("Medias fijas", overlay=true)
src = close,
emaCorta = input(5, minval=1, title="ema semanal corta")
emaMedia = input(10, minval=1, title="ema semanal media")
emaLarga = input(30, minval=1, title="ema semanal larga")

//emaDCorta = input(5, minval=1, title="ema diaria corta")
emaDMedia = input(21, minval=1, title="ema diaria media")
emaDLarga = input(200, minval=1, title="ema diaria larga")

out = ema(close, emaCorta)
out1 = ema(close, emaMedia)
out2 = ema(close, emaLarga)

//Dout = ema(close, emaDCorta)
Dout1 = ema(close, emaDMedia)
Dout2 = ema(close, emaDLarga)

cierreAnterior = security(syminfo.tickerid, 'M', close)
mediaSC = security(syminfo.tickerid, 'W', out)
mediaSM = security(syminfo.tickerid, 'W', out1)
mediaSL = security(syminfo.tickerid, 'W', out2)

cierreSemanaAnterior = security(syminfo.tickerid, 'W', close)
//mediaDC = security(syminfo.tickerid, 'D', Dout)
mediaDM = security(syminfo.tickerid, 'D', Dout1)
mediaDL = security(syminfo.tickerid, 'D', Dout2)

plot(cierreAnterior, color=color.gray)
plot(cierreSemanaAnterior, color=color.purple)

plot(mediaSC, color=color.green)
plot(mediaSM, color=color.orange)
plot(mediaSL, color=color.red,linewidth=2 )

// plot(mediaDC, color=color.lime,  linewidth=1, style=plot.style_circles)
plot(mediaDM, color=color.red, linewidth=1, style=plot.style_circles)
plot(mediaDL, color=color.black, linewidth=1, style=plot.style_circles)




//========================================================================================================
//= 6 - EMAs, P.SAR & Vol.Prof.
//========================================================================================================

//@version=4
// STUDY
//----------//
study(title          = "[francrypto® strategy] 4 Exponential Moving Average, Parabolic SAR & Volume Profile (VP developed by kv4coins)",
     shorttitle      = "[francrypto® strategy] 4 EMAs, P.SAR & Vol.Prof. (VP dev. by kv4coins)",
     overlay         = true,
     precision       = 4,
     linktoseries    = true,
     max_bars_back   = 1000,
     max_lines_count = 500)
//----------//

//----------//
// EMA's (public domain)
// VARIABLES
Length_Longitud_EMA_1 = input(10, minval=1, maxval=500)
Length_Longitud_EMA_2 = input(21, minval=1, maxval=500)
Length_Longitud_EMA_3 = input(55, minval=1, maxval=500)
Length_Longitud_EMA_4 = input(200, minval=1, maxval=500)

EMA1 = ema(close, Length_Longitud_EMA_1)
EMA2 = ema(close, Length_Longitud_EMA_2)
EMA3 = ema(close, Length_Longitud_EMA_3)
EMA4 = ema(close, Length_Longitud_EMA_4)

// PLOTING
plot(EMA1, color=#ffff00, linewidth=1, title='1° Exponential Moving Average // Media Móvil Exponencial')
plot(EMA2, color=#00e6ff, linewidth=1, title='2° Exponential Moving Average // Media Móvil Exponencial')
plot(EMA3, color=#ffa600, linewidth=1, title='3° Exponential Moving Average // Media Móvil Exponencial')
plot(EMA4, color=#001eff, linewidth=1, title='4° Exponential Moving Average // Media Móvil Exponencial')
//----------//

//----------//
// PSAR (public domain)
start = input(0.02, "PSAR Start // Parabólica de SAR Comienzo")
increment = input(0.02, "PSAR Increment // Parabólica de SAR Incremento")
maximum = input(0.2, "PSAR Max Value // Parabólica de SAR Valor Máximo")
out = sar(start, increment, maximum)
plot(out, "PSAR // Parabólica de SAR", style=plot.style_circles, color=#ffffff)
//----------//

//----------//
// VOLUME PROFILE (VP developed by @kv4coins)
//
// my changes to his code
// 1) bilingual titles: added spanish (SPA) ones
// 2) default value of 'vp_lookback': 250 specially for stocks (according to business days)
// 3) default value of 'vp_bar_offset': 40 for a simplified screen
// 4) default value of 'vp_bar_width': 1 for more accuracy
// 5) placed 'vp_bar_color' in aqua and 'vp_poc_color' in white
//
// INPUTS
vp_lookback   = input(defval = 250,
                     title   = "Volume Lookback Depth // Retrospectiva Profundidad del Volumen [10-1000]",
                     type    = input.integer,
                     minval  = 10,
                     maxval  = 1000)

vp_max_bars   = input(defval = 500,
                     title   = "Number of Bars // Cantidad de Barras [10-500]",
                     type    = input.integer,
                     minval  = 10,
                     maxval  = 500)

vp_bar_mult   = input(defval = 50,
                     title   = "Bar Length Multiplier // Longitud de las Barras [10-100]",
                     type    = input.integer,
                     minval  = 10,
                     maxval  = 100)

vp_bar_offset = input(defval = 40,
                     title   = "Bar Horizontal Offset // Distancia en Eje Horizontal de las Barras [0-100]",
                     type    = input.integer,
                     minval  = 0,
                     maxval  = 100)

vp_bar_width  = input(defval = 1,
                     title   = "Bar Width // Ancho de las Barras [1-20]",
                     type    = input.integer,
                     minval  = 1,
                     maxval  = 20)

// As suggested by @NXT2017 to @kv4coins
vp_delta_type = input(defval = "Both // Ambos",
                     title   = "Delta Type",
                     type    = input.string,
                     options = ['Both // Ambos', 'Bullish // Toros', 'Bearish // Osos'])

vp_poc_show   = input(defval = true,
                     title   = "Show POC Line // Mostrar Línea del Punto de Control",
                     type    = input.bool)

vp_bar_color  = input(defval = color.new(color.aqua, 60) ,
                     title   = "Bar Color // Color de la Barra",
                     type    = input.color)

vp_poc_color  = input(defval = color.new(color.white, 10),
                     title   = "POC Color // Color del Punto de control",
                     type    = input.color)

// VARIABLES
float vp_Vmax = 0.0
int vp_VmaxId = 0
int vp_N_BARS = vp_max_bars

var int vp_first = time

vp_a_P = array.new_float((vp_N_BARS + 1), 0.0)
vp_a_V = array.new_float(vp_N_BARS, 0.0)
vp_a_D = array.new_float(vp_N_BARS, 0.0)
vp_a_W = array.new_int(vp_N_BARS, 0)

// CALCULATIONS
float vp_HH = highest(high, vp_lookback)
float vp_LL = lowest(low, vp_lookback)

if barstate.islast
	float vp_HL = (vp_HH - vp_LL) / vp_N_BARS
    for j = 1 to (vp_N_BARS + 1)
        array.set(vp_a_P, (j-1), (vp_LL + vp_HL * j))
	for i = 0 to (vp_lookback - 1)
		int Dc = 0
		array.fill(vp_a_D, 0.0)
		for j = 0 to (vp_N_BARS - 1)
			float Pj = array.get(vp_a_P, j)
			if low[i] < Pj and high[i] > Pj and (vp_delta_type == "Bullish // Toros" ?
			 close[i] >= open[i] : (vp_delta_type == "Bearish // Osos" ? close[i] <= open[i] : true))
				float Dj = array.get(vp_a_D, j)
				float dDj = Dj + nz(volume[i])
				array.set(vp_a_D, j, dDj)
				Dc := Dc + 1
		for j = 0 to (vp_N_BARS - 1)
			float Vj = array.get(vp_a_V, j)
			float Dj = array.get(vp_a_D, j)
			float dVj = Vj + ((Dc > 0) ? (Dj / Dc) : 0.0)
			array.set(vp_a_V, j, dVj)
	vp_Vmax := array.max(vp_a_V)
    vp_VmaxId := array.indexof(vp_a_V, vp_Vmax)
    for j = 0 to (vp_N_BARS - 1)
        float Vj = array.get(vp_a_V, j)
        int Aj = round(vp_bar_mult * Vj / vp_Vmax)
        array.set(vp_a_W, j, Aj)

// PLOTING
if barstate.isfirst
    vp_first := time
vp_change = change(time)
vp_x_loc = timenow + round(vp_change * vp_bar_offset)

f_setup_bar(n) =>
    x1 = ((vp_VmaxId == n) and vp_poc_show) ? max(time[vp_lookback], vp_first) :
		 (timenow + round(vp_change * (vp_bar_offset - array.get(vp_a_W, n))))
	ys = array.get(vp_a_P, n)
    line.new(x1     = x1,
             y1     = ys,
             x2     = vp_x_loc,
             y2     = ys,
             xloc   = xloc.bar_time,
             extend = extend.none,
             color  = (vp_VmaxId == n ? vp_poc_color : vp_bar_color),
             style  = line.style_solid,
             width  = vp_bar_width)

if barstate.islast
    for i = 0 to (vp_N_BARS - 1) by 1
        f_setup_bar(i)
//----------//
// END




//========================================================================================================
//= 7 - RSI+Stochastic+ADX-DMI
//========================================================================================================
//RSI
//@version=4
study(title="Relative Strength Index + Stochastic + ADX/DMI", shorttitle="RSI/Stochastic/ADX-DMI", format=format.price, precision=2, resolution="")
len = input(14, minval=1, title="Length")
src = input(close, "Source", type = input.source)
rsi_up = rma(max(change(src), 0), len)
rsi_down = rma(-min(change(src), 0), len)
rsi = rsi_down == 0 ? 100 : rsi_up == 0 ? 0 : 100 - (100 / (1 + rsi_up / rsi_down))
plot(rsi, "RSI", color=#B666D2,linewidth=2)
band1 = hline(70, "Upper Band", color=#C0C0C0)
band0 = hline(30, "Lower Band", color=#C0C0C0)
fill(band1, band0, color=#9915FF, transp=90, title="Background")

//Media Simple RSI
//plot_media_larga = input(title="Plot Media Larga", type=input.bool, defval=true)
tipo_media_larga_rsi = input(title="Tipo Media RSI",defval="SMA", options=["SMA","EMA","WMA"])
long_media_larga_rsi = input(title="Período Media RSI", defval=55, minval=1, maxval=500)
f_media(source, tipo_media_rsi, length) =>
    if tipo_media_rsi == "SMA"
        sma(source, length)
    else
        if tipo_media_rsi  == "EMA"
            ema(source, length)
        else
            wma(source, length)

media_larga_rsi = f_media(rsi, tipo_media_larga_rsi, long_media_larga_rsi)
hline(50, color=#8C92AC, linewidth=1, linestyle=hline.style_solid, title="Nivel RSI")
//plot(plot_media_larga? media_larga_rsi: na, color=#446CCF, linewidth=1, title='Media RSI')
plot(media_larga_rsi, color=#FFB300, linewidth=1, title='Media RSI')


//////////////////
// Stochastic RSI
smoothK = input(5, "K", minval=1)
smoothD = input(3, "D", minval=1)
lengthRSI = input(14, "RSI Length", minval=1)
lengthStoch = input(14, "Stochastic Length", minval=1)
src2 = input(close, title="RSI Source")
rsi1 = rsi(src2, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)

// Can't set opacity with color(, )... ;(
plot(k, "K", color=color(#0094FF))
plot(d, "D", color=color(#FF6A00))


/////////////////////////
// DMI/ADX
//Study("Average Directional Index with Threshold", shorttitle="DMI/ADX")
adxlen = input(14, title="ADX Smoothing")
dilen = input(14, title="DI Length")
keyLevel = input(23, title="Nivel ADX")
dirmov(len) =>
	up = change(high)
	down = -change(low)
	truerange = rma(tr, len)
	plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
	minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)
	[plus, minus]

adx(dilen, adxlen) =>
	[plus, minus] = dirmov(dilen)
	sum = plus + minus
	adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
	[adx, plus, minus]

[sig, up, down] = adx(dilen, adxlen)

plot(sig, color=#446CCF, title="ADX", linewidth=2)
plot(up, color=#138808, title="+DI")
plot(down, color=#AE0C00, title="-DI")
hline(keyLevel, color=#8C92AC, title="Nivel ADX", linestyle=hline.style_solid)
//plot(keyLevel, color=#8C92AC, title="Key Level")



//Volume Srength Colored CandleStick/ VSCC-Wal


// Marca el interior de la Vela Japonesa de un color (sugiero negro) 
// si el volumen en dicha vela es 1,5 veces mayor que el promedio de los volumenes 
// anteriores y marca de otro color (sugiero blanco) si es 2,3 veces mayor que el 
// promedio de los volumenes anteriores.
// Es una herramienta bastante útil al momento de ver un gráfico ya que las velas 
// presentan su contorno característico si son alcistas o bajistas con el agregado de 
// destacar por el color del interior del cuerpo cuando su volumen es destacado.


//========================================================================================================
//= 8 - Vela japonesa resaltada según volumen
//========================================================================================================
//@version=5
indicator("Coloreo barras x Volumen")
// *** coloreo de barras por tamaño de volumen
length=input(20, "length volumen")
avrg=ta.sma(volume,length)

bear_big = volume >= avrg*2.3 and close < open
bear_med = volume < avrg*2.3 and volume >= avrg*1.5 and close= avrg*2.3 and close>open
bull_med = volume < avrg*2.3 and volume >= avrg*1.5 and close>open
big_up=color.black
big_down = color.white
medium_up=color.lime
medium_down = color.orange

color = bear_big ? big_down : bear_med ? medium_down : bull_big ? big_up : bull_med ? medium_up : na

barcolor(color)


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

    +19000

    Facebook

    +35800

    Instagram

    +34800

    Twitter

    +103000

    YouTube