Professional Documents
Culture Documents
0 at
https://mozilla.org/MPL/2.0/
// © Lupown
//i got the adx scale idea from @oskarGallard
//@version=4
study(shorttitle="SQZ MOM + ADX + RSI + Stoch + STATUS + DIV ", title="Squeeze
momentum + ADX + RSI + Stochastic +status + Divergencias", overlay=false)
show_Momen = input(true, title="-----------Show squeeze momentum-------")
int lengthM = input(20, title="MOM Length", minval=1, step=1)
srcM = input(close, title="MOM Source", type=input.source)
int length = input(20, title="SQZ Length", minval=1, step=1)
src = input(close, title="SQZ Source", type=input.source)
//Momentum
sz = linreg(srcM - avg(avg(highest(high, lengthM), lowest(low, lengthM)),
sma(close, lengthM)), lengthM, 0)
//Momentum Conditions
sc1 = sz >= 0
sc2 = sz < 0
sc3 = sz >= sz[1]
sc4 = sz < sz[1]
//SQUEEZE
useTrueRange = true
// Calculate BB
source = close
basis = sma(source, lengths)
dev = multKC * stdev(source, lengths)
upperBB = basis + dev
lowerBB = basis - dev
// Calculate KC
ma = sma(source, lengthKC)
range = useTrueRange ? tr : (high - low)
rangema = sma(range, lengthKC)
upperKC = ma + rangema * multKC
lowerKC = ma - rangema * multKC
///// 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]
///////////////////////////////////////////////////////////////
biggest(series) =>
max = 0.0
max := nz(max[1], series)
if series > max
max := series
max
//RSI
show_rsi = input(true, title="------------Show RSI---------")
show_RSIfondo=input(true, title="Show RSI background")
len = input(14, minval=1, title="Length")
rsi = rsi(src, len)
rsiColor = rsi <= 30 ? color.green : rsi >= 70 ? color.red : #da00ff
rsi_scale=(rsi)* ni/scale
b1s=70 * ni/scale
bm= 50 * ni/scale
b0s=30 * ni/scale
/////////
/////// estocastico
show_stoch=input(false,title="-------Show Stochastic------")
periodK = input(14, title="%K Length", minval=1)
smoothK = input(1, title="%K Smoothing", minval=1)
periodD = input(3, title="%D Smoothing", minval=1)
k = sma(stoch(close, high, low, periodK), smoothK)
d = sma(k, periodD)
k1=k* ni/scale
d1=d* ni/scale
plot(show_stoch?k1:na, title="%K", color=#2962FF)
plot(show_stoch?d1:na, title="%D", color=#FF6D00)
h1s=80 * ni/scale
h0s=20 * 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)
///////
// ESTADOOO
show_status = input(true, title = "------Show STATUS----------")
dist= input(10,title="Distancia del monitor")
dashColor = input(color.new(#696969, 90), "label Color", inline="Dash Line")
dashTextColor = input(color.new(#ffffff, 0), "Text Color", inline="Dash Line")
a1=adxValue >= 23
a2=adxValue < 23
a3=adxValue >= adxValue[1]
a4=adxValue < adxValue[1]
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])
//////////////////////////////////
//DIVERGENCIAS BUENNNNNNNAS
show_div=input(true,title="------Divergencias--------")
lbR = input(title="Pivot Lookback Right", defval=5)
lbL = input(title="Pivot Lookback Left", defval=5)
rangeUpper = input(title="Max of Lookback Range", defval=60)
rangeLower = input(title="Min of Lookback Range", defval=5)
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(pivotlow(osc, lbL, lbR)) ? false : true
phFound(osc) => na(pivothigh(osc, lbL, lbR)) ? false : true
_inRange(cond) =>
bars = barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper
_findDivRB(osc)=>
// Osc: Higher Low
oscHL = osc[lbR] > valuewhen(plFound(osc), osc[lbR], 1) and
_inRange(plFound(osc)[1])
//-----------------------------------------------------------------------------
-
// Hidden Bullish
//-----------------------------------------------------------------------------
-
// Regular Bearish
//-----------------------------------------------------------------------------
-
// Hidden Bearish
[bullCond,hiddenBullCond,bearCond,hiddenBearCond]
[sz_bullCond,sz_hiddenBullCond,sz_bearCond,sz_hiddenBearCond]=_findDivRB(sz)
_findDivRB(rsi_scale)
plot(
plFound(sz) and show_Momen and show_div ? sz[lbR] : na,
offset=-lbR,
title="Regular Bullish",
linewidth=2,
color=(sz_bullCond ? bullColor : noneColor),
transp=0
)
plotshape(
sz_bullCond and plotlab and show_Momen and show_div ? sz[lbR] : na,
offset=-lbR,
title="Regular Bullish Label",
text="D",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=color.black,
transp=0
)
plot(
plFound(sz) and show_Momen and show_div ? sz[lbR] : na,
offset=-lbR,
title="Hidden Bullish",
linewidth=1,
color=(sz_hiddenBullCond ? hiddenBullColor : noneColor),
transp=0
)
plotshape(
sz_hiddenBullCond and plotlab and show_Momen and show_div ? sz[lbR] : na,
offset=-lbR,
title="Hidden Bullish Label",
text="H",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=color.black,
transp=0
)
plot(
phFound(sz) and show_Momen and show_div ? sz[lbR] : na,
offset=-lbR,
title="Regular Bearish",
linewidth=2,
color=(sz_bearCond ? bearColor : noneColor),
transp=0
)
plotshape(
sz_bearCond and plotlab and show_Momen and show_div ? sz[lbR] : na,
offset=-lbR,
title="Regular Bearish Label",
text="D",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor,
transp=0
)
plot(
phFound(sz) and show_Momen and show_div ? sz[lbR] : na,
offset=-lbR,
title="Hidden Bearish",
linewidth=1,
color=(sz_hiddenBearCond ? hiddenBearColor : noneColor),
transp=0
)
plotshape(
sz_hiddenBearCond and plotlab and show_Momen and show_div ? sz[lbR] :
na,
offset=-lbR,
title="Hidden Bearish Label",
text="H",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor,
transp=0
)
////////////////////RSI DIV//////////////////
[rsi_bullCond,rsi_hiddenBullCond,rsi_bearCond,rsi_hiddenBearCond]=_findDivRB(rsi_sc
ale)
plot(
plFound(rsi_scale) and show_rsi and show_div ? rsi_scale[lbR] : na,
offset=-lbR,
title="Regular Bullish",
linewidth=2,
color=(rsi_bullCond ? bullColor : noneColor),
transp=0
)
plotshape(
rsi_bullCond and plotlab and show_rsi and show_div ? rsi_scale[lbR] :
na,
offset=-lbR,
title="Regular Bullish Label",
text="D",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=color.black,
transp=0
)
plot(
plFound(rsi_scale) and show_rsi and show_div ? rsi_scale[lbR] : na,
offset=-lbR,
title="Hidden Bullish",
linewidth=1,
color=(rsi_hiddenBullCond ? hiddenBullColor : noneColor),
transp=0
)
plotshape(
rsi_hiddenBullCond and plotlab and show_rsi and show_div ?
rsi_scale[lbR] : na,
offset=-lbR,
title="Hidden Bullish Label",
text="H",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=color.black,
transp=0
)
plot(
phFound(rsi_scale) and show_rsi and show_div ? rsi_scale[lbR] : na,
offset=-lbR,
title="Regular Bearish",
linewidth=2,
color=(rsi_bearCond ? bearColor : noneColor),
transp=0
)
plotshape(
rsi_bearCond and plotlab and show_rsi and show_div ? rsi_scale[lbR] : na,
offset=-lbR,
title="Regular Bearish Label",
text="D",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor,
transp=0
)
plot(
phFound(rsi_scale) and show_rsi and show_div ? rsi_scale[lbR] : na,
offset=-lbR,
title="Hidden Bearish",
linewidth=1,
color=(rsi_hiddenBearCond ? hiddenBearColor : noneColor),
transp=0
)
plotshape(
rsi_hiddenBearCond and plotlab and show_rsi and show_div ?
rsi_scale[lbR] : na,
offset=-lbR,
title="Hidden Bearish Label",
text="H",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor,
transp=0
)