0% found this document useful (0 votes)
83 views13 pages

1112

Uploaded by

Pepin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views13 pages

1112

Uploaded by

Pepin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 13

//Momentum

sz = ta.linreg(srcM - math.avg(math.avg(ta.highest(high, lengthM), ta.lowest(low,


lengthM)), ta.sma(close, lengthM)), lengthM, 0)

//Momentum Conditions
sc1 = sz >= 0
sc2 = sz < 0
sc3 = sz >= sz[1]
sc4 = sz < sz[1]

clr = sc1 and sc3 ? #00FF00 : sc1 and sc4 ? #008000 : sc2 and sc4 ? #FF0000 : sc2
and sc3 ? #800000 : color.gray

plot(show_Momen ? sz : na, title='Squeeze Momentum', color=clr,


style=plot.style_area)

//SQUEEZE

lengths = input(20, title='BB Length')


mult = input(2.0, title='BB MultFactor')
lengthKC = input(20, title='KC Length')
multKC = input(1.5, title='KC MultFactor')

useTrueRange = true

// Calculate BB
source = close
basis = ta.sma(source, lengths)
dev = multKC * ta.stdev(source, lengths)
upperBB = basis + dev
lowerBB = basis - dev

// Calculate KC
ma = ta.sma(source, lengthKC)
range_1 = useTrueRange ? ta.tr : high - low
rangema = ta.sma(range_1, lengthKC)
upperKC = ma + rangema * multKC
lowerKC = ma - rangema * multKC

sqzOn = lowerBB > lowerKC and upperBB < upperKC


sqzOff = lowerBB < lowerKC and upperBB > upperKC
noSqz = sqzOn == false and sqzOff == false

scolor = noSqz ? color.blue : sqzOn ? #000000 : color.gray


//plotshape(show_Momen? true : na, color=scolor, style=shape.xcross)
zLine = plot(show_Momen ? 0 : na, title='Squeeze Zero Line', color=scolor,
linewidth=2, style=plot.style_cross, transp=0)
///// ADX

show_ADX = input(true, title='------------Show ADX------------')


show_di = input(true, title=' Show +DI -DI')
show_aa = input.bool(true, 'Mostrar punto 23 aparte', inline='adx line')
far = input.int(-7, 'Separacion', inline='adx line')
scale = input(75.0, title='Scala for ADX')
adxlen = input(14, title='ADX Smoothing')
dilen = input(14, title='DI Length')
keyLevel = input(23, title='Key level for ADX')
show_bg = input(false, title='Show bg color')

dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(up > down and up > 0 ? up : 0, len) / truerange)
minus = fixnan(100 * ta.rma(down > up and down > 0 ? down : 0, len) /
truerange)
[plus, minus]

adx(dilen, adxlen) =>


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

[adxValue, diplus, diminus] = adx(dilen, adxlen)

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

//[diplus, diminus, adxValue] = dmi(dilen, adxlen)

biggest(series) =>
max = 0.0
max := nz(max[1], series)
if series > max
max := series
max
max

// Calculate ADX Scale


ni = biggest(sz)
far1 = far * ni / scale
adx_scale = (adxValue - keyLevel) * ni / scale

adx_scale2 = (adxValue - keyLevel + far) * ni / scale

dip = (diplus - keyLevel) * ni / scale


dim = (diminus - keyLevel) * ni / scale
plot(show_di ? dip : na, color=color.new(color.green, 0), title='DI+')
plot(show_di ? dim : na, color=color.new(color.red, 0), title='DI+')
plot(show_aa ? far1 : na, color=color.new(color.white, 0), title='Punto 23')
color_ADX = adxValue > adxValue[1] ? #ffffff : #F732DF

bgcolor(adxValue > adxValue[1] and adxValue > 23 and show_Momen and show_bg ? clr :
na, transp=95)

//RSI
show_rsi = input(true, title='------------Show RSI---------')
show_RSIfondo = input(true, title='Show RSI background')
len = input.int(14, minval=1, title='Length RSI 1')
upperR = input(70, title='Upper band')
middleR = input(50, title='Middle band')
lowerR = input(30, title='Lower band')
rsi = ta.rsi(src, len)
rsiColor = rsi <= lowerR ? color.green : rsi >= upperR ? color.red : #da00ff
rsi_scale = rsi * ni / scale

b1s = upperR * ni / scale


bm = middleR * ni / scale
b0s = lowerR * ni / scale

plot(show_rsi ? rsi_scale : na, 'RSI', color=rsiColor)

/////////
/////// estocastico

show_stoch = input(false, title='-------Show Stochastic------')

periodK = input.int(14, title='%K Length', minval=1)


smoothK = input.int(1, title='%K Smoothing', minval=1)
periodD = input.int(3, title='%D Smoothing', minval=1)
k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)
d = ta.sma(k, periodD)

k1 = k * ni / scale
d1 = d * ni / scale
plot(show_stoch ? k1 : na, title='%K', color=color.new(#2962FF, 0))
plot(show_stoch ? d1 : na, title='%D', color=color.new(#FF6D00, 0))
upS = input(80, title='Upper band')
lowS = input(20, title='Lower band')

h1s = upS * ni / scale


h0s = lowS * ni / scale
//plot(show_stoch? h1s : na,color=bar_index % 2 == 0 ? color.white :
#00000000,transp=60)
//plot(show_stoch? h0s : na,color=bar_index % 2 == 0 ? color.white :
#00000000,transp=60)

//band1 = plot(show_rsi? b1s : show_stoch? h1s: na,color=bar_index % 2 == 0 ?


color.white : #00000000,transp=60)
//bandm = plot(show_rsi? bm : na,color=bar_index % 2 == 0 ? color.white :
#00000000,transp=70)
//band0 = plot(show_rsi? b0s : show_stoch ? h0s: na,color=bar_index % 2 == 0 ?
color.white : #00000000,transp=60)
///////

/////////////////AWESOME
show_ao = input(false, title='-----------Show AO-------')
show_aoF = input(false, title='Show ao away 0 point')
farAO = input(-30, title='Away from 0 point')

fastLength = input(5, title='Fast Length')


slowLength = input(34, title='Slow Length')

ao = ta.sma(hl2, fastLength) - ta.sma(hl2, slowLength)


//nia = biggest(aoN)
//ao = aoN*nia/scale

ao_f = ao + farAO * ni / scale

aoColor = ao >= 0 ? ao[1] < ao ? #26A69A : #B2DFDB : ao[1] < ao ? #FFCDD2 : #EF5350

aoPlot = plot(show_aoF and show_ao ? ao_f : show_ao ? ao : na, title='AO',


style=show_aoF ? plot.style_line : show_ao ? plot.style_area : plot.style_area,
color=aoColor, transp=0) //

bandA = plot(show_aoF and show_ao ? farAO * ni / scale : na,


color=color.new(color.white, 60))

fill(aoPlot, bandA, color=show_aoF and show_ao ? aoColor : na, title='AO Fill',


transp=90)

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

////////////////////////////////////
///////MACD
/////////////////////////////
show_macd = input(false, title='-----------Show MACD-------')
show_macdF = input(false, title='Show MACD area away 0 point')
show_macdLF = input(false, title='Show MACD lines away 0 point')
macdF = input(-30, title='Away 0 point')
show_macdL = input(false, title='Show MACD lines')
fast_length = input(title='Fast Length', defval=12)
slow_length = input(title='Slow Length', defval=26)
//src = input(title="Source", type=input.source, defval=close)
signal_length = input.int(title='Signal Smoothing', minval=1, maxval=50, defval=9)
sma_source = input.string(title='Oscillator MA Type', defval='EMA', options=['SMA',
'EMA'])
sma_signal = input.string(title='Signal Line MA Type', defval='EMA',
options=['SMA', 'EMA'])
macdScale = input(2, title='MACD scale')
//calculating
fast_ma = sma_source == 'SMA' ? ta.sma(src, fast_length) : ta.ema(src, fast_length)
slow_ma = sma_source == 'SMA' ? ta.sma(src, slow_length) : ta.ema(src, slow_length)
macd1 = fast_ma - slow_ma
signal = sma_signal == 'SMA' ? ta.sma(macd1, signal_length) : ta.ema(macd1,
signal_length)
hist = macd1 - signal
//color
macdColor = hist >= 0 ? hist[1] < hist ? #26A69A : #B2DFDB : hist[1] < hist ?
#FFCDD2 : #EF5350
histo = hist * macdScale
macd = macd1 * macdScale
sign = signal * macdScale

histo_f = histo + macdF * ni / scale

histoA = plot(show_macdF and show_macd ? histo_f : show_macd ? histo : na,


title='Histogram', style=show_macdF and show_macd ? plot.style_line : show_macd ?
plot.style_columns : plot.style_columns, color=macdColor)
plot(show_macdLF and show_macdL ? macd + macdF * ni / scale : show_macdL ? macd :
na, title='MACD', color=color.new(color.blue, 0))
plot(show_macdLF and show_macdL ? sign + macdF * ni / scale : show_macdL ? sign :
na, title='Signal', color=color.new(color.orange, 0))

band_macd = plot(show_macdF and show_macd ? macdF * ni / scale : na,


color=color.new(color.white, 60))

fill(histoA, band_macd, color=show_macdF and show_macd ? macdColor : na,


title='MACD Fill', transp=90)
////////////////////////////////////////
//////////////////////END MACD
/////////////////////////////////

////////////////////////////////////////
////////////////////// KONOCORDE "Koncorde Inversiones en el Mundo by lkdml all the
credits for them
/////////////////////////////////
show_K = input(true, title='---------------Show Koncorde-------------')
scaleK = input(8, title='Koncorde scale')
showKF = input(true, title='Show Koncorde away 0 point')
fark = input(-40, title='Away from 0 point')
show_KD = input(true, title='Show Koncorde Diamond')
kon_pos = input(30, title='Position diamonds Bull')
kon_posn = input(30, title='Position diamonds Bear')
srcTprice = input(ohlc4, title='Fuente para Precio Total')
srcMfi = input.source(hlc3, title='Fuente MFI', group='Money Flow Index')
tprice = srcTprice

//lengthEMA = input(255, minval=1)

m = input(15, title='Media Exponencial')


longitudPVI = input(90, title='Longitud PVI')
longitudNVI = input(90, title='Longitud NVI')
longitudMFI = input(14, title='Longitud MFI')
multK = input.float(2.0, title='Multiplicador para derivacion estandar',
group='Bollinger Oscillator')
boLength = input.int(25, title='Calculation length ', group='Bollinger Oscillator')
pvim = ta.ema(ta.pvi, m)
pvimax = ta.highest(pvim, longitudPVI)
pvimin = ta.lowest(pvim, longitudPVI)
oscp = (ta.pvi - pvim) * 100 / (pvimax - pvimin)

nvim = ta.ema(ta.nvi, m)
nvimax = ta.highest(nvim, longitudNVI)
nvimin = ta.lowest(nvim, longitudNVI)
azul = (ta.nvi - nvim) * 100 / (nvimax - nvimin)

xmf = ta.mfi(srcMfi, longitudMFI)

// Bands Calculation
basisK = ta.sma(tprice, boLength) //Find the 20-day moving average average (n1 +
n2 ... + n20)/20
devK = mult * ta.stdev(tprice, boLength) //Find the standard deviation of the 20-
days
upper = basisK + devK //Upper Band = 20-day Moving Average + (2 x standard
deviation of the 20-days)
lower = basisK - devK //Lower Band = 20-day Moving Average - (2 x standard
deviation of the 20-days)
OB1 = (upper + lower) / 2.0
OB2 = upper - lower

BollOsc = (tprice - OB1) / OB2 * 100 // percent b


xrsi = ta.rsi(tprice, 14)

calc_stoch(src, length, smoothFastD) =>


ll = ta.lowest(low, length)
hh = ta.highest(high, length)
k = 100 * (src - ll) / (hh - ll)
ta.sma(k, smoothFastD)

stoc = calc_stoch(tprice, 21, 3)


marron = (xrsi + xmf + BollOsc + stoc / 3) / 2
verde = marron + oscp
media = ta.ema(marron, m)
bandacero = showKF ? fark * ni / scale : 0
scaleK1 = ni / scale / scaleK

//vl=plot(show_K ? verde *scaleK1: na, color=#66FF66, style=plot.style_area,


title="verde")// COLOURED(102,255,102) as “verde” , GREEN
//ml=plot(show_K ? marron *scaleK1: na, color= #FFCC99, style=plot.style_area,
title="marron", transp=0) // COLOURED(255,204,153) as"marron" , BEIGE
//al=plot(show_K ? azul *scaleK1: na, color=#126bd6, style=plot.style_area,
title="azul") // COLOURED(0,255,255) as “azul” ,

lk1 = plot(show_K and showKF ? marron * scaleK1 + fark * ni / scale : show_K ?


marron * scaleK1 : na, color=color.new(#330000, 0), style=plot.style_line,
linewidth=3, title='lmarron') // COLOURED(51,0,0) as “lmarron” ,
lk2 = plot(show_K and showKF ? verde * scaleK1 + fark * ni / scale : show_K ? verde
* scaleK1 : na, color=color.new(#006600, 0), style=plot.style_line, linewidth=3,
title='lineav') // COLOURED(0,102,0) as “lineav” ,
lk3 = plot(show_K and showKF ? azul * scaleK1 + fark * ni / scale : show_K ? azul *
scaleK1 : na, color=color.new(#000066, 0), style=plot.style_line,
title='lazul') // COLOURED(0,0,102) as “lazul” ,
plot(show_K and showKF ? media * scaleK1 + fark * ni / scale : show_K ? media *
scaleK1 : na, color=color.new(color.red, 0), title='media', style=plot.style_line,
linewidth=2) // COLOURED(255,0,0) as “media” ,
band0k = plot(bandacero, color=color.new(color.black, 0), title='cero')

fill(lk2, band0k, color=show_K ? #66FF66 : na, title='verde', transp=50)


fill(lk1, band0k, color=show_K ? #FFCC99 : na, title='marron', transp=50)
fill(lk3, band0k, color=show_K ? #00FFFF : na, title='azul', transp=50)

konBull = ta.crossover(marron, media) and show_KD


konBear = ta.crossunder(marron, media) and show_KD

konlBull = kon_pos * ni / scale


konlBear = kon_posn * ni / scale
plotchar(konBull ? konlBull : konBear ? konlBear : na, title='Koncorde diamond',
char='◆', color=konBull ? color.lime : konBear ? color.red : color.white,
location=location.absolute, size=size.tiny, transp=0)

////////////////////////////////////////
////////////////////// END KONCORDE
/////////////////////////////////

////////////////////////////////////////
////////////////////// Elliot oscilator
/////////////////////////////////
show_eo = input(false, title='------------Show Elliot Oscillator---------')

showfeo = input(false, title='Show EO away 0 point')


fareo = input(-70, title='Away 0 point')
sma1length = input(5)
sma2length = input(35)
eo = ta.sma(src, sma1length) - ta.sma(src, sma2length)
eo_f = eo + fareo * ni / scale
col = eo >= 0 ? eo[1] < eo ? #26A69A : #B2DFDB : eo[1] < eo ? #FFCDD2 : #EF5350
eop = plot(showfeo and show_eo ? eo_f : show_eo ? eo : na, color=col, style=showfeo
and show_eo ? plot.style_line : show_eo ? plot.style_columns : plot.style_columns,
linewidth=2)

band_eo = plot(showfeo and show_eo ? fareo * ni / scale : na,


color=color.new(color.white, 60))

fill(eop, band_eo, color=showfeo and show_eo ? col : na, title='EO Fill',


transp=50)

////////////////////////////////////////
////////////////////// END elliot
/////////////////////////////////

////////////////////////////////////////
////////////////////// CCI
/////////////////////////////////
show_cci = input(false, title='------------Show CCI---------')
cci_len = input(14, 'CCI length')
cci_src = input(close, 'CCI source')
upperCCI = input(100, 'CCI Upper band')
lowerCCI = input(-100, 'CCI lower band')
b1cci = upperCCI * ni / scale * 30 / 100
b0cci = lowerCCI * ni / scale * 30 / 100
cci = ta.cci(cci_src, cci_len)

cci_scale = 30 * (cci * ni / scale) / 100


//cci_scale=((cci * ni/scale)/scale) *scale_cci
//(cci / (ni * scale) ) + (50*ni/scale)
//cci_color = c1 ? #F8B856 : c2 ? #F6AD3C : c3 ? #F5A21B : #F39800
plot(show_cci ? cci_scale : na, color=color.new(color.blue, 0), linewidth=2,
title='CCI')

////////////////////////////////////////
////////////////////// END CCI
/////////////////////////////////

///////////////////
////////
////////////////////
colorcm = show_cci ? color.blue : color.white
band1 = plot(show_rsi ? b1s : show_stoch ? h1s : na, color=bar_index % 2 == 0 ?
color.white : #00000000, transp=60)
band0 = plot(show_rsi ? b0s : show_stoch ? h0s : show_cci ? b0cci : na,
color=bar_index % 2 == 0 ? color.white : #00000000, transp=60)
bandm = plot(show_cci ? b1cci : show_rsi ? bm : na, color=bar_index % 2 == 0 ?
colorcm : #00000000, transp=70)
band00 = plot(show_cci ? b0cci : na, color=bar_index % 2 == 0 ? color.blue :
#00000000, transp=60)
fill(band1, band0, color=show_rsi and show_RSIfondo ? color.purple : na, title='RSI
background', transp=90)
//////////////
////////

/////////////////////\/
/////////////MFI i got the code fo=rom the CIPHER indicator by vumanchu
//////////////////////

rsiMFIShow = input(false, title='----------Show MFI---------')


rsiMFIperiod = input(60, title='MFI Period')
rsiMFIMultiplier = input.float(150, title='MFI Area multiplier')
rsiMFIPosY = input(2.5, title='MFI Area Y Pos')

// RSI+MFI
f_rsimfi(_period, _multiplier, _tf) =>
request.security(syminfo.tickerid, _tf, ta.sma((close - open) / (high - low) *
_multiplier, _period) - rsiMFIPosY)

rsiMFI = f_rsimfi(rsiMFIperiod, rsiMFIMultiplier, timeframe.period)


rsiMFIColor = #ffffff
rsiMFIplot = plot(rsiMFIShow ? rsiMFI * ni / scale : na, title='RSI+MFI Area',
color=color.new(rsiMFIColor, 80), style=plot.style_area)
/////////////////////
/////////
//////////////////////

//WT the cipher dots use a indicator by lazy bear


show_cphr = input(false, title='------------Show Cipher dots---------')
n1 = input(9, title='Channel Length')
n2 = input(12, title='Average Length')
smooth = input(3, title='Smooth Factor')

//wt
CALC(n1, n2, smooth) =>
ap = hlc3
esa = ta.ema(ap, n1)
dw = ta.ema(math.abs(ap - esa), n1)
ci = (ap - esa) / (0.015 * dw)
tci = ta.ema(ci, n2)

wt1 = tci
wt2 = ta.sma(wt1, smooth)
wave = wt1 - wt2
wavecolor = wave >= 0 ? color.lime : color.red
[wave, wavecolor]

//CIPHERR
[wave, wavecolor] = CALC(n1, n2, smooth)

middle = 0
condWt = ta.cross(wave, middle) ? true : na
wtjeje = show_Momen ? sz : show_ao ? ao : show_macd ? macd : show_eo ? eo : na
plot(condWt and show_cphr ? wtjeje : na, title='Buy and sell circle',
color=wavecolor, style=plot.style_circles, linewidth=3, transp=15)

/////plot ADX

p1 = plot(show_aa ? adx_scale2 : show_ADX ? adx_scale : na, color=color_ADX,


title='ADX', linewidth=2)

///
///////////////
// ESTADOOO
show_status = input(true, title='------Show STATUS----------')
dist = input(3, title='Distancia del monitor')
dashColor = input.color(color.new(#696969, 90), 'label Color', inline='Dash Line')
dashTextColor = input.color(color.new(#ffffff, 0), 'Text Color', inline='Dash
Line')

if adxValue > adxValue[1] and adxValue > 23


iadx = 'ADX con pendiente positiva por encima punto 23'
iadx
if adxValue > adxValue[1] and adxValue < 23
iadx = 'ADX con pendiente positiva por debajo punto 23'
iadx
if adxValue < adxValue[1] and adxValue < 23
iadx = 'ADX con pendiente negativa por debajo punto 23'
iadx
if adxValue < adxValue[1] and adxValue > 23
iadx = 'ADX con pendiente negativa por encima punto 23'
iadx

a1 = adxValue >= 23
a2 = adxValue < 23
a3 = adxValue >= adxValue[1]
a4 = adxValue < adxValue[1]

iAdx = a1 and a3 ? 'Pendiente positiva ↑ 23' : a1 and a4 ? 'Pendiente negativa ↑


23' : a2 and a4 ? 'Pendiente negativa ↓ 23' : a2 and a3 ? 'Pendiente positiva ↓ 23'
: '-'

iMom = sc1 and sc3 ? 'Direccionalidad alcista' : sc1 and sc4 ? 'Direccionalidad
bajista' : sc2 and sc4 ? 'Direccionalidad bajista' : sc2 and sc3 ? 'Direccinalidad
alcista' : '-'

igral = a1 and a3 and sc1 and sc3 ? 'Fuerte movimiento alcista' : a1 and a3 and sc1
and sc4 ? 'Monitor muestra rango-caida pero\nel movimiento tiene fuerza' : a1 and
a3 and sc2 and sc4 ? 'Fuerte movimiento bajista' : a1 and a3 and sc2 and sc3 ?
'Monitor muestra rango-subida pero\nel movimiento tiene fuerza' : a1 and a4 and sc1
and sc3 ? 'Movimiento alcista sin fuerza' : a1 and a4 and sc1 and sc4 ? 'Monitor
muestra rango-caida\n pendiente negativa en ADX (venta)' : a1 and a4 and sc2 and
sc4 ? 'Movimiento bajista sin fuerza' : a1 and a4 and sc2 and sc3 ? 'Monitor
muestra rango-subida con \npendiente negativa en ADX (compra)' : a2 and a4 and sc1
and sc3 ? 'Movimiento alcista sin fuerza' : a2 and a4 and sc1 and sc4 ? 'Monitor
muestra rango-caida sin fuerza ' : a2 and a4 and sc2 and sc4 ? 'Movimiento bajista
sin fuerza' : a2 and a4 and sc2 and sc3 ? 'Monitor muestra rango-subida sin fuerza
' : a2 and a3 and sc1 and sc3 ? 'Movimiento alcista que \n quiere agarrar fuerza' :
a2 and a3 and sc1 and sc4 ? 'Monitor muestra rango-caida,\n el movimiento quiere
agarrar fuerza' : a2 and a3 and sc2 and sc4 ? 'Movimiento bajista que \n quiere
agarrar fuerza' : a2 and a3 and sc2 and sc3 ? 'Monitor muestra rango-subida,\n el
movimiento quiere agarrar fuerza' : '-'

s = '\n'
scr_label = 'Info ADX: ' + iAdx + s + 'Info monitor: ' + iMom + s + 'Info general:'
+ s + igral
// Plot Label on the chart
// Plot Label on the chart

if show_status

lab_l = label.new(bar_index + dist, 0, '\t Estatus segun estrategia\n\t' +


scr_label, color=dashColor, textcolor=dashTextColor, style=label.style_label_left,
yloc=yloc.price)
label.delete(lab_l[1])

// Send alert only if screener is not empty


if scr_label != ''
alert('Estatus segun estrategia\n' + scr_label,
freq=alert.freq_once_per_bar_close)
//////////////////////////////////

//DIVERGENCIAS BUENNNNNNNAS
show_div = input(false, title='------Divergencias--------')
lbR = input(title='Pivot Lookback Right', defval=1)
lbL = input(title='Pivot Lookback Left', defval=1)
rangeUpper = input(title='Max of Lookback Range', defval=60)
rangeLower = input(title='Min of Lookback Range', defval=1)
plotBull = input(title='Plot Bullish', defval=true)
plotHiddenBull = input(title='Plot Hidden Bullish', defval=true)
plotBear = input(title='Plot Bearish', defval=true)
plotHiddenBear = input(title='Plot Hidden Bearish', defval=true)
plotlab = input(title='Plot label', defval=false)

bearColor = #ff0000
bullColor = #1bff00
hiddenBullColor = #a4ff99
hiddenBearColor = #ff9e9e
textColor = color.white
noneColor = color.new(color.white, 100)

//FUNCTIONS
plFound(osc) =>
na(ta.pivotlow(osc, lbL, lbR)) ? false : true
phFound(osc) =>
na(ta.pivothigh(osc, lbL, lbR)) ? false : true

_inRange(cond) =>
bars = ta.barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper

_findDivRB(osc) =>
// Osc: Higher Low
oscHL = osc[lbR] > ta.valuewhen(plFound(osc), osc[lbR], 1) and
_inRange(plFound(osc)[1])

// Price: Lower Low


priceLL = low[lbR] < ta.valuewhen(plFound(osc), low[lbR], 1)

bullCond = plotBull and priceLL and oscHL and plFound(osc)

//-----------------------------------------------------------------------------
-
// Hidden Bullish

// Osc: Lower Low


oscLL = osc[lbR] < ta.valuewhen(plFound(osc), osc[lbR], 1) and
_inRange(plFound(osc)[1])

// Price: Higher Low


priceHL = low[lbR] > ta.valuewhen(plFound(osc), low[lbR], 1)

hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound(osc)


//-----------------------------------------------------------------------------
-
// Regular Bearish

// Osc: Lower High


oscLH = osc[lbR] < ta.valuewhen(phFound(osc), osc[lbR], 1) and
_inRange(phFound(osc)[1])

// Price: Higher High


priceHH = high[lbR] > ta.valuewhen(phFound(osc), high[lbR], 1)

bearCond = plotBear and priceHH and oscLH and phFound(osc)

//-----------------------------------------------------------------------------
-
// Hidden Bearish

// Osc: Higher High


oscHH = osc[lbR] > ta.valuewhen(phFound(osc), osc[lbR], 1) and
_inRange(phFound(osc)[1])

// Price: Lower High


priceLH = high[lbR] < ta.valuewhen(phFound(osc), high[lbR], 1)

hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound(osc)

[bullCond, hiddenBullCond, bearCond, hiddenBearCond]

[sz_bullCond, sz_hiddenBullCond, sz_bearCond, sz_hiddenBearCond] = _findDivRB(sz)

foundDivBSZ = plFound(sz) and show_Momen and show_div ? true : false


colordivBSZ = sz_bullCond ? bullColor : sz_hiddenBullCond ? hiddenBullColor :
noneColor
foundDivBeSZ = phFound(sz) and show_Momen and show_div ? true : false
colordivBeSZ = sz_bearCond ? bearColor : sz_hiddenBearCond ? hiddenBearColor :
noneColor

plot(foundDivBSZ ? sz[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=1,


color=colordivBSZ, transp=0)
plot(foundDivBeSZ ? sz[lbR] : na, offset=-lbR, title='Regular Bullish',
linewidth=1, color=colordivBeSZ, transp=0)

////////////////////RSI DIV//////////////////
[rsi_bullCond, rsi_hiddenBullCond, rsi_bearCond, rsi_hiddenBearCond] =
_findDivRB(rsi_scale)

foundDivBRSI = plFound(rsi_scale) and show_rsi and show_div ? true : false


colordivBRSI = rsi_bullCond ? bullColor : rsi_hiddenBullCond ? hiddenBullColor :
noneColor
foundDivBeRSI = phFound(rsi_scale) and show_rsi and show_div ? true : false
colordivBeRSI = rsi_bearCond ? bearColor : rsi_hiddenBearCond ? hiddenBearColor :
noneColor

plot(foundDivBRSI ? rsi_scale[lbR] : na, offset=-lbR, title='Regular Bullish',


linewidth=1, color=colordivBRSI, transp=0)
plot(foundDivBeRSI ? rsi_scale[lbR] : na, offset=-lbR, title='Regular Bullish',
linewidth=1, color=colordivBeRSI, transp=0)

////////////////////AWESOME OSCILATOR DIV//////////////////

[ao_bullCond, ao_hiddenBullCond, ao_bearCond, ao_hiddenBearCond] = _findDivRB(ao)

foundDivBao = plFound(ao) and show_ao and show_div ? true : false


colordivBao = ao_bullCond ? bullColor : ao_hiddenBullCond ? hiddenBullColor :
noneColor
foundDivBeao = phFound(ao) and show_ao and show_div ? true : false
colordivBeao = ao_bearCond ? bearColor : ao_hiddenBearCond ? hiddenBearColor :
noneColor

plot(foundDivBao and show_aoF ? ao_f[lbR] : foundDivBao ? ao[lbR] : na, offset=-


lbR, title='Regular Bullish', linewidth=1, color=colordivBao, transp=0)
plot(foundDivBeao and show_aoF ? ao_f[lbR] : foundDivBeao ? ao[lbR] : na, offset=-
lbR, title='Regular Bullish', linewidth=1, color=colordivBeao, transp=0)

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

You might also like