You are on page 1of 19

//

===================================================================================
=====================
//= 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,his
tbase=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,his
tbase=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

-------------------------------------------------------------

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

----------------------------------------------------------

//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.

study("Volume Srength Colored CandleStick", shorttitle="VSCC-Wal", overlay=true)


length=input(20, "length", minval=1)
avrg=sma(volume,length)

bear1 = volume > avrg*2.3 and close= avrg*1.5 and volume<=avrg*2.3 and close
avrg*2.3 and close>open
bull2 = volume >= avrg*1.5 and volume<=avrg*2.3 and close>open

big=black
medium=blue
color = bear1 ? big : bear2 ? medium : bull1 ? big : bull2 ? medium : na

barcolor(color)

You might also like