//@version=5
indicator(title="Insane Oscillator", shorttitle="Insane Oscillator v2.1",
format=format.price, precision=2)
bShowTrend = input.bool(true, "Show trend color", group="Basic Settings")
bShowTramp = input.bool(true, "Show trampoline", group="Basic Settings")
bShowSqueeze = input.bool(true, "Show squeeze dot", group="Basic Settings")
bShowBB = input.bool(true, "Show bollinger bands wicking", group="Basic Settings")
bShowWAE = input.bool(true, "Show waddah explosion", group="Basic Settings")
showDashboard = input(true, "Smart Panel", group="+++++++++++++ DISPLAY
SETTINGS +++++++++++++" , inline = "Features1")
locationDashboard = input.string("Middle Right", "Dashboard Location", ["Top
Right", "Middle Right", "Bottom Right", "Top Center", "Middle Center", "Bottom
Center", "Top Left", "Middle Left", "Bottom Left"], group="+++++++++++++ DISPLAY
SETTINGS +++++++++++++" , tooltip="Smart Panel")
sizeDashboard = input.string("Tiny", "Dashboard Size", ["Large", "Normal",
"Small", "Tiny"], group="+++++++++++++ DISPLAY SETTINGS +++++++++++++" ,
tooltip="Smart Panel")
bShowRSI = input.bool(true, "Show RSI line", group="Basic Settings")
bShowMFI = input.bool(false, "Show MFI line", group="Basic Settings")
bShowVector = input.bool(false, "Show vector candles", group="Basic Settings")
bShowDivies = input.bool(false, "Show divergence background bars", group="Basic
Settings")
bShowBuySellies = input.bool(false, "Show buy/sell background bars", group="Basic
Settings")
bgTrans = input.int(85, minval=1, title="Background Transparency (100=invisible,
0=opaque)", group="Basic Settings")
Theme = input.string(title="Color Theme", options=["Standard", "Pinky and the
Brain", "Color Blind", "Eye Popper"], defval="Standard")
thickWaddah = input.int(2, minval=1, title="Waddah Explosion Thickness",
group="Basic Settings")
threshold = input.int(120, title="Threshold to trigger (lower is more sensitive)",
group="Basic Settings")
//bShowHMA = input.bool(false, "Show Hull Moving Average", group="Basic Settings")
rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
rsiOS = input.int(30, minval=1, title="RSI Oversold", group="RSI Settings")
rsiOB = input.int(70, minval=1, title="RSI Overbought", group="RSI Settings")
rsiLowerW = input.int(30, "Lower Limit of RSI", minval = 1, maxval = 500,
group="Wicking Settings")
rsiUpperW = input.int(70, "Upper Limit of RSI", minval = 1, maxval = 500,
group="Wicking Settings")
mfiLength = input.int(title="MFI Length", defval=14, minval=1, maxval=2000,
group="Money Flow Index")
mfi = ta.mfi(hlc3, mfiLength)
// c1 = Theme == "Standard" ? color1 : Theme == "Classic" ? color3 : Theme ==
"Lemon" ? color5 : Theme == "Silver Surfer" ? color7 : Theme == "Watermelon" ?
color9 : Theme == "Ethereal" ? color11 : na
// c2 = Theme == "Standard" ? color2 : Theme == "Classic" ? color4 : Theme ==
"Lemon" ? color6 : Theme == "Silver Surfer" ? color8 : Theme == "Watermelon" ?
color10 : Theme == "Ethereal" ? color12 : na
colorMildGreen = Theme == "Standard" ? color.new(#66ff00, 40) : Theme == "Pinky and
the Brain" ? color.new(#00f5f1, 40) : Theme == "Color Blind" ? color.new(#03fcf4,
40) : Theme == "Eye Popper" ? color.new(#f8fc03, 40) : na
colorBigGreen = Theme == "Standard" ? color.new(#66ff00, 0) : Theme == "Pinky and
the Brain" ? color.new(#00f5f1, 0) : Theme == "Color Blind" ? color.new(#03fcf4, 0)
: Theme == "Eye Popper" ? color.new(#f8fc03, 0) : na
colorMildRed = Theme == "Standard" ? color.new(#ff0000, 40) : Theme == "Pinky and
the Brain" ? color.new(#fc03f8, 40) : Theme == "Color Blind" ? color.new(#fca903,
40) : Theme == "Eye Popper" ? color.new(#df03fc, 40) : na
colorBigRed = Theme == "Standard" ? color.new(#ff0000, 0) : Theme == "Pinky and the
Brain" ? color.new(#fc03f8, 0) : Theme == "Color Blind" ? color.new(#fca903, 0) :
Theme == "Eye Popper" ? color.new(#df03fc, 0) : na
colorInvisible = color.new(color.black, 100)
upperColor = color.new(#787B86, 0)
lowerColor = color.new(#787B86, 0)
showMeUp = false
// CCI DOUBLE CROSS
ma1 = ta.sma(hlc3, 14)
cci1 = (hlc3 - ma1) / (0.015 * ta.dev(hlc3, 14))
ma2 = ta.sma(hlc3, 100)
cci2 = (hlc3 - ma1) / (0.015 * ta.dev(hlc3, 100))
cci1WasGreen = cci1[1] > cci2[1] or cci1[2] > cci2[2] or cci1[3] > cci2[3] or
cci1[4] > cci2[4] or cci1[5] > cci2[5] or cci1[6] > cci2[6] or cci1[7] > cci2[7]
if (cci1 > cci2 and cci1 >= 100)
lowerColor := colorBigRed
showMeUp := true
if (cci1 < cci2 and cci1 < -100 and cci1WasGreen)
upperColor := colorBigRed
up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
mfiColor = #828282
if (mfi > 70)
mfiColor := color.rgb(0, 148, 76)
if (mfi < 30)
mfiColor := color.rgb(147, 0, 0)
//plot(bShowMFI ? mfi : na, "MFI", color=mfiColor)
lengthHMA = input.int(9, minval=1, title="HMA Length", group="HMA Settings")
srcHMA = input(close, title="HMA Source", group="HMA Settings")
hullma = ta.wma(2*ta.wma(srcHMA, lengthHMA/2)-ta.wma(srcHMA, lengthHMA),
math.floor(math.sqrt(lengthHMA)))
hmaColor = hullma > hullma[1] ? colorBigGreen : colorBigRed
//plot(bShowHMA ? hullma : na, color=hmaColor, linewidth=1)
// Divergence
lookbackRight = 5
lookbackLeft = 5
rangeUpper = 60
rangeLower = 5
bearColor = colorMildRed
bullColor = colorMildGreen
textColor = color.white
noneColor = color.new(color.white, 100)
plFound = na(ta.pivotlow(rsi, lookbackLeft, lookbackRight)) ? false : true
phFound = na(ta.pivothigh(rsi, lookbackLeft, lookbackRight)) ? false : true
_inRange(cond) =>
bars = ta.barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper
rsiHL = rsi[lookbackRight] > ta.valuewhen(plFound, rsi[lookbackRight], 1) and
_inRange(plFound[1])
priceLL = low[lookbackRight] < ta.valuewhen(plFound, low[lookbackRight], 1)
bullCondAlert = priceLL and rsiHL and plFound
rsiLH = rsi[lookbackRight] < ta.valuewhen(phFound, rsi[lookbackRight], 1) and
_inRange(phFound[1])
priceHH = high[lookbackRight] > ta.valuewhen(phFound, high[lookbackRight], 1)
bearCondAlert = priceHH and rsiLH and phFound
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= TRAMPOLINE =-=-=-=-=-=-=-=-=-=-=-=-=-
=-=-=-=-=-=-=-=-=-=-= //
// Idea from "Serious Backtester" - https://www.youtube.com/watch?v=2hX7qTamOAQ
// Defaults are optimized for 30 min candles
// CONFIG
iBBThreshold = input.float(0.0015, minval=0.0, title="Bollinger Lower Threshold",
tooltip="0.003 for daily, 0.0015 for 30 min candles", group="TRAMPOLINE Settings")
RSIThreshold = input.int(25, minval=1, title="RSI Lower Threshold",
tooltip="Normally 25", group="TRAMPOLINE Settings")
RSIDown = input.int(72, minval=1, title="RSI Upper Threshold", tooltip="Normally
75", group="TRAMPOLINE Settings")
lengthBB = input.int(20, minval=1, group="TRAMPOLINE Bollinger Bands")
srcBB = input(close, title="Source", group="TRAMPOLINE Bollinger Bands")
multBB = input.float(2.0, minval=0.001, maxval=50, title="StdDev",
group="TRAMPOLINE Bollinger Bands")
offsetBB = input.int(0, "Offset", minval = -500, maxval = 500, group="TRAMPOLINE
Bollinger Bands")
isRed = close < open
isGreen = close > open
// STANDARD BOLLINGER BANDS
basisBB = ta.sma(srcBB, lengthBB)
devBB = multBB * ta.stdev(srcBB, lengthBB)
upperBB = basisBB + devBB
lowerBB = basisBB - devBB
downBB = low < lowerBB or high < lowerBB
upBB = low > upperBB or high > upperBB
bbw = (upperBB - lowerBB) / basisBB
back1 = isRed[1] and rsi[1] <= RSIThreshold and close[1] < lowerBB[1] and bbw[1] >
iBBThreshold
back2 = isRed[2] and rsi[2] <= RSIThreshold and close[2] < lowerBB[2] and bbw[2] >
iBBThreshold
back3 = isRed[3] and rsi[3] <= RSIThreshold and close[3] < lowerBB[3] and bbw[3] >
iBBThreshold
back4 = isRed[4] and rsi[4] <= RSIThreshold and close[4] < lowerBB[4] and bbw[4] >
iBBThreshold
back5 = isRed[5] and rsi[5] <= RSIThreshold and close[5] < lowerBB[5] and bbw[5] >
iBBThreshold
for1 = isGreen[1] and rsi[1] >= RSIDown and close[1] > upperBB[1] and bbw[1] >
iBBThreshold
for2 = isGreen[2] and rsi[2] >= RSIDown and close[2] > upperBB[2] and bbw[2] >
iBBThreshold
for3 = isGreen[3] and rsi[3] >= RSIDown and close[3] > upperBB[3] and bbw[3] >
iBBThreshold
for4 = isGreen[4] and rsi[4] >= RSIDown and close[4] > upperBB[4] and bbw[4] >
iBBThreshold
for5 = isGreen[5] and rsi[5] >= RSIDown and close[5] > upperBB[5] and bbw[5] >
iBBThreshold
weGoUp = isGreen and (back1 or back2 or back3 or back4 or back5) and (high >
high[1]) and barstate.isconfirmed
upThrust = weGoUp and not weGoUp[1] and not weGoUp[2] and not weGoUp[3] and not
weGoUp[4]
weGoDown = isRed and (for1 or for2 or for3 or for4 or for5) and (low < low[1]) and
barstate.isconfirmed
downThrust = weGoDown and not weGoDown[1] and not weGoDown[2] and not weGoDown[3]
and not weGoDown[4]
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Squeeze Relaxer version 2.1 =-=-=-=-
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
// Average Directional Index
sqTolerance = input.int(2, title="Squeeze Tolerance (lower = more sensitive)",
group="Relaxing Settings", tooltip="How many bars to look back on the squeeze
indicator")
adxSqueeze = input.int(21, title="ADX Threshold for TTM Squeeze", group="Relaxing
Settings", tooltip="Anything over 19 filters out low volume periods. Set to 11 as a
default, feel free to increase to get less noise")
adxlen = input(14, title="ADX Smoothing", group="ADX")
dilen = input(14, title="DI Length", group="ADX")
dirmov(len) =>
up5 = ta.change(high)
down5 = -ta.change(low)
plusDM = na(up5) ? na : (up5 > down5 and up5 > 0 ? up5 : 0)
minusDM = na(down5) ? na : (down5 > up5 and down5 > 0 ? down5 : 0)
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
minus = fixnan(100 * ta.rma(minusDM, 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)
adxValue = adx(dilen, adxlen)
sigabove19 = adxValue > adxSqueeze
var cGreen = 0
var cRed = 0
var pos = false
var neg = false
sqlength = 20
multQ = 2.0
lengthKC = 20
multKC = 1.5
useTrueRange = true
source = close
basis = ta.sma(source, sqlength)
dev1 = multKC * ta.stdev(source, sqlength)
upperBBsq = basis + dev1
lowerBBsq = basis - dev1
ma = ta.sma(source, lengthKC)
rangeQ = high - low
rangema = ta.sma(rangeQ, lengthKC)
upperKC = ma + rangema * multKC
lowerKC = ma - rangema * multKC
sqzOn1 = (lowerBBsq > lowerKC) and (upperBBsq < upperKC)
sqzOff1 = (lowerBBsq < lowerKC) and (upperBBsq > upperKC)
noSqz = (sqzOn1 == false) and (sqzOff1 == false)
avg1 = math.avg(ta.highest(high, lengthKC), ta.lowest(low, lengthKC))
avg2 = math.avg(avg1, ta.sma(close, lengthKC))
val = ta.linreg(close - avg2, lengthKC, 0)
pos := false
neg := false
// if squeeze is bright RED, increment by one
if (val < nz(val[1]) and val < 5 and not sqzOn1)
cRed := cRed + 1
// if squeeze is bright GREEN, increment by one
if (val > nz(val[1]) and val > 5 and not sqzOn1)
cGreen := cGreen + 1
// if bright RED squeeze is now dim, momentum has changed. Is ADX also above 19? -
add a marker to chart
if (val > nz(val[1]) and cRed > sqTolerance and val < 5 and not pos[1] and
sigabove19 == true)
cRed := 0
pos := true
// if bright GREEN squeeze is now dim, momentum has changed. Is ADX also above 19?
- add a marker to chart
if (val < nz(val[1]) and cGreen > sqTolerance and val > 5 and not neg[1] and
sigabove19 == true)
cGreen := 0
neg := true
buySignal1 = pos and barstate.isconfirmed
sellSignal1 = neg and barstate.isconfirmed
// JOHN WICK BOLLINGER BANDS
wlengthBB = input.int(20, minval=1, group="Wicking Bollinger Bands")
wsrcBB = input(close, title="Source", group="Wicking Bollinger Bands")
wmultBB = input.float(2.5, minval=0.001, maxval=50, title="StdDev", group="Wicking
Bollinger Bands")
woffsetBB = input.int(0, "Offset", minval = -500, maxval = 500, group="Wicking
Bollinger Bands")
wbasisBB = ta.sma(wsrcBB, wlengthBB)
wdevBB = wmultBB * ta.stdev(wsrcBB, wlengthBB)
wupperBB = wbasisBB + wdevBB
wlowerBB = wbasisBB - wdevBB
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= VECTOR CANDLES =-=-=-=-=-=-=-=-=-=-=-
=-=-=-=-=-=-=-=-=-=-=-=-= //
import TradersReality/Traders_Reality_Lib/2 as trLib
color redVectorColor = colorBigRed
color greenVectorColor = colorBigGreen
color violetVectorColor = color.fuchsia
color blueVectorColor = color.rgb(83, 144, 249)
color regularCandleUpColor = color.new(#999999, 99)
color regularCandleDownColor = color.new(#4d4d4d, 99)
bool overrideSym = false
string pvsraSym = 'INDEX:BTCUSD'
bool colorOverride = true
pvsraVolume(overrideSymbolX, pvsraSymbolX, tickerIdX) =>
request.security(overrideSymbolX ? pvsraSymbolX : tickerIdX, '',
[volume,high,low,close,open], barmerge.gaps_off, barmerge.lookahead_off)
[pvsraVolume, pvsraHigh, pvsraLow, pvsraClose, pvsraOpen] =
pvsraVolume(overrideSym, pvsraSym, syminfo.tickerid)
[pvsraColor, alertFlag, averageVolume, volumeSpread, highestVolumeSpread] =
trLib.calcPvsra(pvsraVolume, pvsraHigh, pvsraLow, pvsraClose, pvsraOpen,
redVectorColor, greenVectorColor, violetVectorColor, blueVectorColor,
regularCandleDownColor, regularCandleUpColor)
// IMPULSE MACD
calc_smma(src, len) =>
smma = 0.0
smma := na(smma[1]) ? ta.sma(src, len) : (smma[1] * (len - 1) + src) / len
smma
calc_zlema(src, length) =>
ema1 = ta.ema(src, length)
ema2 = ta.ema(ema1, length)
d = ema1 - ema2
ema1 + d
srcMCD = hlc3
hiMCD = calc_smma(high, 34)
loMCD = calc_smma(low, 34)
miMCD = calc_zlema(srcMCD, 34)
mdMCD = (miMCD>hiMCD) ? (miMCD-hiMCD) : (miMCD<loMCD) ? (miMCD-loMCD) : 0
sbMCD = ta.sma(mdMCD, 9)
shMCD = mdMCD - sbMCD
// TRIPLE SUPERTREND
atr25 = ta.sma(ta.tr, 10)
atr= atr25
tx=hl2-(1*atr)
tx1 = nz(tx[1],tx)
tx := close[1] > tx1 ? math.max(tx,tx1) : tx
ty=hl2+(1*atr)
ty1 = nz(ty[1], ty)
ty := close[1] < ty1 ? math.min(ty, ty1) : ty
trend5 = 1
trend5 := nz(trend5[1], trend5)
trend5 := trend5 == -1 and close > ty1 ? 1 : trend5 == 1 and close < tx1 ? -1 :
trend5
changeCond = trend5 != trend5[1]
atr20 = ta.sma(ta.tr, 11)
atr0 = atr20
tx0 =hl2-(2*atr)
tx10 = nz(tx0[1],tx0)
tx0 := close[1] > tx10 ? math.max(tx0,tx10) : tx0
ty0=hl2+(2*atr)
ty10 = nz(ty0[1], ty0)
ty0 := close[1] < ty10 ? math.min(ty0, ty10) : ty0
trend0 = 1
trend0 := nz(trend0[1], trend0)
trend0 := trend0 == -1 and close > ty10 ? 1 : trend0 == 1 and close < tx10 ? -1 :
trend0
changeCond0 = trend0 != trend0[1]
atr29 = ta.sma(ta.tr, 12)
atr9 = atr29
tx9=hl2-(3*atr)
tx19 = nz(tx9[1],tx9)
tx9 := close[1] > tx19 ? math.max(tx9,tx19) : tx9
ty9=hl2+(3*atr)
ty19 = nz(ty9[1], ty9)
ty9 := close[1] < ty19 ? math.min(ty9, ty19) : ty9
trend9 = 1
trend9 := nz(trend9[1], trend9)
trend9 := trend9 == -1 and close > ty19 ? 1 : trend9 == 1 and close < tx19 ? -1 :
trend9
changeCond9 = trend9 != trend9[1]
var tripBuy = false
var tripSell = false
tripBuy := (trend9==1 and tx9 and trend5==1 and tx and trend0==1 and tx0) or
(trend9==1 and tx9 and trend5==1 and tx) or (trend9==1 and tx9 and trend0==1 and
tx0) or (trend5==1 and tx and trend0==1 and tx0)
tripSell := (trend9!=1 and ty9 and trend5!=1 and ty and trend0!=1 and ty0) or
(trend9!=1 and ty9 and trend5!=1 and ty) or (trend9!=1 and ty9 and trend0!=1 and
ty0) or (trend5!=1 and ty and trend0!=1 and ty0)
// Halftrend
amplitude = input(title="Amplitude", defval=2, group="Halftrend")
channelDeviation = input(title="Channel Deviation", defval=2, group="Halftrend")
var int trend = 0
var int nextTrend = 0
var float maxLowPrice = nz(low[1], low)
var float minHighPrice = nz(high[1], high)
var float up1 = 0.0
var float down1 = 0.0
float atrHigh = 0.0
float atrLow = 0.0
float arrowUp = na
float arrowDown = na
atr2 = ta.atr(100) / 2
dev = channelDeviation * atr2
highPrice = high[math.abs(ta.highestbars(amplitude))]
lowPrice = low[math.abs(ta.lowestbars(amplitude))]
highma = ta.sma(high, amplitude)
lowma = ta.sma(low, amplitude)
if nextTrend == 1
maxLowPrice := math.max(lowPrice, maxLowPrice)
if highma < maxLowPrice and close < nz(low[1], low)
trend := 1
nextTrend := 0
minHighPrice := highPrice
else
minHighPrice := math.min(highPrice, minHighPrice)
if lowma > minHighPrice and close > nz(high[1], high)
trend := 0
nextTrend := 1
maxLowPrice := lowPrice
if trend == 0
if not na(trend[1]) and trend[1] != 0
up1 := na(down1[1]) ? down1 : down1[1]
arrowUp := up1 - atr2
else
up1 := na(up1[1]) ? maxLowPrice : math.max(maxLowPrice, up1[1])
atrHigh := up1 + dev
atrLow := up1 - dev
else
if not na(trend[1]) and trend[1] != 1
down1 := na(up1[1]) ? up1 : up1[1]
arrowDown := down1 + atr2
else
down1 := na(down1[1]) ? minHighPrice : math.min(minHighPrice, down1[1])
atrHigh := down1 + dev
atrLow := down1 - dev
HalfTrue = trend == 0
htColor = trend == 0 ? colorBigGreen : colorBigRed
// BULL RUSH
bullUp = (ta.ema(close, 9) > ta.ema(close, 21) and close > ta.ema(close, 50) and
open > ta.ema(close, 50))
bullDown = (ta.ema(close, 9) < ta.ema(close, 21) and close < ta.ema(close, 50) and
open < ta.ema(close, 50))
// KNOW SURE THING
roclen1 = 10
roclen2 = 15
roclen3 = 20
roclen4 = 30
smalen1 = 10
smalen2 = 10
smalen3 = 10
smalen4 = 15
siglen = 9
smaroc(roclen, smalen) => ta.sma(ta.roc(close, roclen), smalen)
kst = smaroc(roclen1, smalen1) + 2 * smaroc(roclen2, smalen2) + 3 * smaroc(roclen3,
smalen3) + 4 * smaroc(roclen4, smalen4)
sig = ta.sma(kst, siglen)
KSTTrue = kst >= sig
// ===================================== VODKA SHOT
==================================================================
var isLong = false
var isShort = false
// =================================== NEGLECTED VOL by DGT
======================================--
nzVolume = nz(volume)
source5 = barstate.isconfirmed ? close : close[1]
vsource = nzVolume ? barstate.isconfirmed ? ta.obv : ta.obv[1] : na
corr = ta.correlation(source5, vsource, 14)
volAvgS = ta.sma(nzVolume, 14)
volAvgL = ta.sma(nzVolume, 14 * 5)
volDev = (volAvgL + 1.618034 * ta.stdev(volAvgL, 14 * 5)) / volAvgL * 11 / 100
volRel = nzVolume / volAvgL
momentum = ta.change(vsource, 14) / 14
momOsc = ta.linreg(momentum / volAvgS * 1.618034, 5, 0)
vbcbColor = if close < open
if nzVolume > volAvgS * 1.618034
#910000
else if nzVolume >= volAvgS * .618034 and nzVolume <= volAvgS * 1.618034
color.red
else
color.orange
else
if nzVolume > volAvgS * 1.618034
#006400
else if nzVolume >= volAvgS * .618034 and nzVolume <= volAvgS * 1.618034
color.green
else
#7FFFD4
bColor5 = color.new(color.black, 25)
gColor = color.new(color.gray, 50)
// =================================== RedK Dual VADER with Energy Bars [VADER-
DEB] ======================================--
f_derma(_data, _len, MAOption) =>
value =
MAOption == 'SMA' ? ta.sma(_data, _len) :
MAOption == 'EMA' ? ta.ema(_data, _len) :
ta.wma(_data, _len)
rlength = input.int(12, minval=1)
DER_avg = input.int(5, 'Average', minval=1, inline='DER', group='RedK Dual VADER')
MA_Type5 = input.string('WMA', 'DER MA type', options=['WMA', 'EMA', 'SMA'],
inline='DER', group='RedK Dual VADER')
rsmooth = input.int(3, 'Smooth', minval=1, inline='DER_1', group='RedK Dual
VADER')
show_senti = input.bool(true, 'Sentiment', inline='DER_s', group='RedK Dual
VADER')
senti = input.int(20, 'Length', minval=1, inline='DER_s', group='RedK Dual
VADER')
v_calc = input.string('Relative', 'Calculation', options=['Relative', 'Full',
'None'], group='RedK Dual VADER')
vlookbk = input.int(20, 'Lookback (for Relative)', minval=1,
group='RedK Dual VADER')
v5 = volume
vola =
v_calc == 'None' or na(volume) ? 1 :
v_calc == 'Relative' ? ta.stoch(v5, v5, v5, vlookbk) / 100 :
v5
R = (ta.highest(2) - ta.lowest(2)) / 2 // R is the 2-bar
average bar range - this method accomodates bar gaps
sr = ta.change(close) / R // calc ratio of
change to R
rsr = math.max(math.min(sr, 1), -1) // ensure ratio is
restricted to +1/-1 in case of big moves
c = fixnan(rsr * vola)
c_plus = math.max(c, 0) // calc directional
vol-accel energy
c_minus = -math.min(c, 0)
avg_vola = f_derma(vola, rlength, MA_Type5)
dem = f_derma(c_plus, rlength, MA_Type5) / avg_vola //
directional energy ratio
sup = f_derma(c_minus, rlength, MA_Type5) / avg_vola
adp = 100 * ta.wma(nz(dem), DER_avg) // average DER
asp = 100 * ta.wma(nz(sup), DER_avg)
anp = adp - asp // net DER..
anp_s = ta.wma(anp, rsmooth)
s_adp = 100 * ta.wma(nz(dem), senti) // average
DER for sentiment length
s_asp = 100 * ta.wma(nz(sup), senti)
V_senti = ta.wma(s_adp - s_asp, rsmooth)
c_adp = color.new(#11ff20, 30)
c_asp = color.new(#ff1111, 30)
c_fd = color.new(color.green, 80)
c_fs = color.new(color.red, 80)
c_zero = color.new(#ffee00, 70)
c_up5 = color.new(#11ff20, 0)
c_dn5 = color.new(#ff1111, 0)
up5 = anp_s >= 0
s_up = V_senti >= 0
c_grow_above = #1b5e2080
c_grow_below = #dc4c4a80
c_fall_above = #66bb6a80
c_fall_below = #ef8e9880
sflag_up = math.abs(V_senti) >= math.abs(V_senti[1])
bo = fixnan(asp)
bc = fixnan(adp)
bh = math.max(bo, bc)
bl = math.min(bo, bc)
rising = ta.change(bc) > 0
c_barup = #11ff2088
c_bardn = #ff111188
c_bardj = #ffffff88
barcolor = bc > bo and rising ? c_barup : bc < bo and not rising ? c_bardn :
c_bardj
// =================================== RedK Slow_Smooth WMA, RSS_WMA v3
======================================--
f_LazyLine(_data, _length) =>
w1 = 0, w2 = 0, w3 = 0
L1 = 0.0, L2 = 0.0, L3 = 0.0
w = _length / 3
if _length > 2
w2 := math.round(w)
w1 := math.round((_length-w2)/2)
w3 := int((_length-w2)/2)
L1 := ta.wma(_data, w1)
L2 := ta.wma(L1, w2)
L3 := ta.wma(L2, w3)
else
L3 := _data
L3
LL = f_LazyLine(close, 21)
lc_up = color.new(#33ff00, 0)
lc_dn = color.new(#ff1111, 0)
luptrend = LL > LL[1]
SigMulti = 1.0
SignalOn = barstate.isconfirmed
SwingDn = luptrend[1] and not(luptrend) and barstate.isconfirmed
SwingUp = luptrend and not(luptrend[1]) and barstate.isconfirmed
dl = SigMulti / 100 * LL
upwards = LL > LL[1] and (barcolor == c_barup) and up and (open < close and volRel
* .145898 > volDev)
downwards = LL < LL[1] and (barcolor == c_bardn) and (open > close and volRel
* .145898 > volDev)
// WAE - Waddah Attar Explosion v1 by LazyBear
sensitivity = input.int(150, title="Sensitivity", group="WAE")
fastLength=input.int(20, title="FastEMA Length", group="WAE")
slowLength=input.int(40, title="SlowEMA Length", group="WAE")
channelLength=input.int(20, title="BB Channel Length", group="WAE")
multWAE=input.float(2.0, title="BB Stdev Multiplier", group="WAE")
calc_macd(source, fastLength, slowLength) =>
fastMA = ta.ema(source, fastLength)
slowMA = ta.ema(source, slowLength)
fastMA - slowMA
calc_BBUpper(source, length, mult) =>
basis = ta.sma(source, length)
dev = mult * ta.stdev(source, length)
basis + dev
calc_BBLower(source, length, mult) =>
basis = ta.sma(source, length)
dev = mult * ta.stdev(source, length)
basis - dev
t1 = (calc_macd(close, fastLength, slowLength) - calc_macd(close[1], fastLength,
slowLength))*sensitivity
e1 = (calc_BBUpper(close, channelLength, multWAE) - calc_BBLower(close,
channelLength, multWAE))
trendUpWAE = (t1 >= 0) ? t1 : 0
trendDownWAE = (t1 < 0) ? (-1*t1) : 0
waeColor = trendUpWAE >= threshold ? colorBigGreen : trendDownWAE >= threshold ?
colorBigRed : color.new(color.gray, 80)
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= SHARK WAVE TREND =-=-=-=-=-=-=-=-=-=-
=-=-=-=-=-=-=-=-=-=-=-=-=-= //
wtChannelLen = input.int(9, title = 'WT Channel Length', group="SharkWaveTrend")
wtAverageLen = input.int(12, title = 'WT Average Length', group="SharkWaveTrend")
wtMASource = input.source(hlc3, title = 'WT MA Source', group="SharkWaveTrend")
wtMALen = input.int(3, title = 'WT MA Length', group="SharkWaveTrend")
c_intense_red = colorBigRed
c_regular_red = colorMildRed
c_intense_green = colorBigGreen
c_regular_green = colorMildGreen
obLevel = input.int(53, title = 'WT Overbought Level 1', group="SharkWaveTrend")
osLevel = input.int(-53, title = 'WT Oversold Level 1', group="SharkWaveTrend")
wtDivOBLevel = input.int(45, title = 'WT Bearish Divergence min',
group="SharkWaveTrend")
wtDivOSLevel = input.int(-65, title = 'WT Bullish Divergence min',
group="SharkWaveTrend")
wtDivOBLevel_add = input.int(15, title = 'WT 2nd Bearish Divergence',
group="SharkWaveTrend")
wtDivOSLevel_add = input.int(-40, title = 'WT 2nd Bullish Divergence 15 min',
group="SharkWaveTrend")
rsiMFIperiod = input.int(60,title = 'MFI Period', group="SharkWaveTrend")
rsiMFIMultiplier = input.int(150, title = 'MFI Area multiplier',
group="SharkWaveTrend")
rsiMFIPosY = input.float(2.5, title = 'MFI Area Y Pos', group="SharkWaveTrend")
rsiSRC = input.source(close, title = 'RSI Source', group="SharkWaveTrend")
rsiLen = input.int(14, title = 'RSI Length', group="SharkWaveTrend")
rsiOversold = input.int(30, title = 'RSI Oversold', minval = 0, maxval = 50,
group="SharkWaveTrend")
rsiOverbought = input.int(60, title = 'RSI Overbought', minval = 50, maxval = 100,
group="SharkWaveTrend")
rsiDivOBLevel = input.int(60, title = 'RSI Bearish Divergence min',
group="SharkWaveTrend")
rsiDivOSLevel = input.int(30, title = 'RSI Bullish Divergence min',
group="SharkWaveTrend")
stochSRC = input.source(close, title = 'Stochastic RSI Source',
group="SharkWaveTrend")
stochLen = input.int(14, title = 'Stochastic RSI Length', group="SharkWaveTrend")
stochRsiLen = input.int(14, title = 'RSI Length ', group="SharkWaveTrend")
stochKSmooth = input.int(3, title = 'Stochastic RSI K Smooth',
group="SharkWaveTrend")
stochDSmooth = input.int(3, title = 'Stochastic RSI D Smooth',
group="SharkWaveTrend")
colorRedWT = colorBigRed
colorGreenWT = colorBigGreen
f_top_fractal(src) => src[4] < src[2] and src[3] < src[2] and src[2] > src[1] and
src[2] > src[0]
f_bot_fractal(src) => src[4] > src[2] and src[3] > src[2] and src[2] < src[1] and
src[2] < src[0]
f_fractalize(src) => f_top_fractal(src) ? 1 : f_bot_fractal(src) ? -1 : 0
f_findDivs(src, topLimit, botLimit, useLimits) =>
fractalTop = f_fractalize(src) > 0 and (useLimits ? src[2] >= topLimit :
true) ? src[2] : na
fractalBot = f_fractalize(src) < 0 and (useLimits ? src[2] <= botLimit :
true) ? src[2] : na
highPrev = ta.valuewhen(fractalTop, src[2], 0)[2]
highPrice = ta.valuewhen(fractalTop, high[2], 0)[2]
lowPrev = ta.valuewhen(fractalBot, src[2], 0)[2]
lowPrice = ta.valuewhen(fractalBot, low[2], 0)[2]
bearSignal = fractalTop and high[2] > highPrice and src[2] < highPrev
bullSignal = fractalBot and low[2] < lowPrice and src[2] > lowPrev
bearDivHidden = fractalTop and high[2] < highPrice and src[2] > highPrev
bullDivHidden = fractalBot and low[2] > lowPrice and src[2] < lowPrev
[fractalTop, fractalBot, lowPrev, bearSignal, bullSignal, bearDivHidden,
bullDivHidden]
f_rsimfi(_period, _multiplier, _tf) => request.security(syminfo.tickerid, _tf,
ta.sma(((close - open) / (high - low)) * _multiplier, _period) - rsiMFIPosY)
f_wavetrend(src, chlen, avg, malen, tf) =>
tfsrc = request.security(syminfo.tickerid, tf, src)
esa = ta.ema(tfsrc, chlen)
de = ta.ema(math.abs(tfsrc - esa), chlen)
ci = (tfsrc - esa) / (0.015 * de)
wt1 = request.security(syminfo.tickerid, tf, ta.ema(ci, avg))
wt2 = request.security(syminfo.tickerid, tf, ta.sma(wt1, malen))
wtVwap = wt1 - wt2
wtOversold = wt2 <= osLevel
wtOverbought = wt2 >= obLevel
wtCross = ta.cross(wt1, wt2)
wtCrossUp = wt2 - wt1 <= 0
wtCrossDown = wt2 - wt1 >= 0
wtCrosslast = ta.cross(wt1[2], wt2[2])
wtCrossUplast = wt2[2] - wt1[2] <= 0
wtCrossDownlast = wt2[2] - wt1[2] >= 0
[wt1, wt2, wtOversold, wtOverbought, wtCross, wtCrossUp, wtCrossDown,
wtCrosslast, wtCrossUplast, wtCrossDownlast, wtVwap]
f_stochrsi(_src, _stochlen, _rsilen, _smoothk, _smoothd, _log, _avg) =>
src = _log ? math.log(_src) : _src
rsiWT = ta.rsi(src, _rsilen)
kk = ta.sma(ta.stoch(rsiWT, rsiWT, rsiWT, _stochlen), _smoothk)
d1 = ta.sma(kk, _smoothd)
avg_1 = math.avg(kk, d1)
k = _avg ? avg_1 : kk
[k, d1]
rsiWT = ta.rsi(rsiSRC, rsiLen)
[wt1, wt2, wtOversold, wtOverbought, wtCross, wtCrossUp, wtCrossDown, wtCross_last,
wtCrossUp_last, wtCrossDown_last, wtVwap] = f_wavetrend(wtMASource, wtChannelLen,
wtAverageLen, wtMALen, timeframe.period)
[stochK, stochD] = f_stochrsi(stochSRC, stochLen, stochRsiLen, stochKSmooth,
stochDSmooth, true, true)
[wtFractalTop, wtFractalBot, wtLow_prev, wtBearDiv, wtBullDiv, wtBearDivHidden,
wtBullDivHidden] = f_findDivs(wt2, wtDivOBLevel, wtDivOSLevel, true)
[wtFractalTop_add, wtFractalBot_add, wtLow_prev_add, wtBearDiv_add, wtBullDiv_add,
wtBearDivHidden_add, wtBullDivHidden_add] = f_findDivs(wt2, wtDivOBLevel_add,
wtDivOSLevel_add, true)
[wtFractalTop_nl, wtFractalBot_nl, wtLow_prev_nl, wtBearDiv_nl, wtBullDiv_nl,
wtBearDivHidden_nl, wtBullDivHidden_nl] = f_findDivs(wt2, 0, 0, false)
[rsiFractalTop, rsiFractalBot, rsiLow_prev, rsiBearDiv, rsiBullDiv,
rsiBearDivHidden, rsiBullDivHidden] = f_findDivs(rsi, rsiDivOBLevel, rsiDivOSLevel,
true)
[rsiFractalTop_nl, rsiFractalBot_nl, rsiLow_prev_nl, rsiBearDiv_nl, rsiBullDiv_nl,
rsiBearDivHidden_nl, rsiBullDivHidden_nl] = f_findDivs(rsi, 0, 0, false)
[stochFractalTop, stochFractalBot, stochLow_prev, stochBearDiv, stochBullDiv,
stochBearDivHidden, stochBullDivHidden] = f_findDivs(stochK, 0, 0, false)
buySignal = wtCross and wtCrossUp and wtOversold
buySignalDiv = (wtBullDiv or wtBullDiv_add or stochBullDiv or rsiBullDiv)
sellSignal = wtCross and wtCrossDown and wtOverbought
sellSignalDiv = wtBearDiv or wtBearDiv_add or stochBearDiv or rsiBearDiv
length2 = input.int(30, minval=1, group="Shark")
src = input.source(close, title="Source", group="Shark")
mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev", group="Shark")
offset = input.int(0, "Offset", minval = -500, maxval = 500, group="Shark")
HighlightBreaches = input.bool(true, title="Highlight Oversold/Overbought",
group="Shark")
bApply25and75 = input.bool(true, title="Apply 25/75 RSI rule", group="Shark")
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
ema400 = ta.ema(close, 400)
ema800 = ta.ema(close, 800)
wapwap = ta.vwap(close)
bTouchedLine = (ema50<high and ema50>low) or (ema200<high and ema200>low) or
(ema400<high and ema400>low) or (ema800<high and ema800>low) or (wapwap<high and
wapwap>low)
upTR = ta.rma(math.max(ta.change(close), 0), 14)
downTR = ta.rma(-math.min(ta.change(close), 0), 14)
rsiM = downTR == 0 ? 100 : upTR == 0 ? 0 : 100 - (100 / (1 + upTR / downTR))
basisWT = ta.sma(rsiM, length2)
devWT = mult * ta.stdev(rsiM, length2)
upperWT = basisWT + devWT
lowerWT = basisWT - devWT
bBelow25 = rsiM < 26
bAbove75 = rsiM > 74
if not bApply25and75
bBelow25 := true
bAbove75 := true
b_color = (rsiM > upperWT and bAbove75) ? c_regular_red : (rsiM < lowerWT and
bBelow25) ? c_regular_green : na
if bTouchedLine and b_color == color.new(color.red, transp=60)
b_color := c_intense_red
if bTouchedLine and b_color == color.new(color.green, transp=60)
b_color := c_intense_green
// bgcolor(HighlightBreaches ? b_color : na)
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= FINAL DISPLAY =-=-=-=-=-=-=-=-=-=-=-
=-=-=-=-=-=-=-=-=-=-=-=-= //
colorGreen = colorMildGreen
colorRed = colorMildRed
upWick50PercentLarger = close > open and math.abs(high - close) > math.abs(open -
close)
downWick50PercentLarger = close < open and math.abs(low - close) > math.abs(open -
close)
if (upWick50PercentLarger and rsi > rsiUpperW)
colorGreen := colorBigGreen
if (downWick50PercentLarger and rsi < rsiLowerW)
colorRed := colorBigRed
rsiColor = rsi > rsiOB ? colorBigGreen : rsi < rsiOS ? colorBigRed : mfi > 50 ?
colorMildGreen : mfi < 50 ? colorMildRed : color.gray
rsiPlot = plot(bShowRSI ? rsi : na, "RSI", color=rsiColor, linewidth=3)
//midlinePlot = plot(bShowRSI ? 50 : na, "RSI Middle Band",
color=color.new(#787B86, 50))
//fill(rsiPlot, midlinePlot, 100, 70, top_color = colorBigGreen, bottom_color =
colorInvisible, title = "Overbought Gradient Fill")
//fill(rsiPlot, midlinePlot, 30, 0, top_color = colorInvisible, bottom_color =
colorBigRed, title = "Oversold Gradient Fill")
plotchar(upThrust and bShowTramp ? -65 : na, title = 'Trampoline', char='T', color
= color.white, location = location.absolute, size = size.tiny)
plotchar(downThrust and bShowTramp ? 65 : na , title = 'Trampoline', char = 'T',
color = color.white, location = location.absolute, size = size.tiny)
//plotshape((pvsraColor == greenVectorColor) and bShowVector ? 50 : na,
title="Vector Candle", location=location.absolute, style=shape.labelup,
color=colorMildGreen)
//plotshape((pvsraColor == redVectorColor) and bShowVector ? 50 : na, title="Vector
Candle", location=location.absolute, style=shape.labeldown, color=colorMildRed)
plotshape(rsi > rsiOB ? 55 : na, title = 'RSI Overbought Square', style =
shape.square, color = colorGreen, location = location.absolute, size = size.tiny)
plotshape(rsi < rsiOS ? -55 : na , title = 'RSI Oversold Square', style =
shape.square, color = colorRed, location = location.absolute, size = size.tiny)
plotshape(buySignal1 and bShowSqueeze ? -65 : na, title="Squeeze Buy Signal",
style=shape.diamond, location=location.absolute, color=color.yellow,
size=size.tiny)
plotshape(sellSignal1 and bShowSqueeze ? 65 : na, title="Squeeze Sell Signal",
style=shape.diamond, location=location.absolute, color=color.yellow,
size=size.tiny)
plotchar(low <= wlowerBB and close >= wlowerBB and close < open and bShowBB ? -46 :
na, char="ß", title="Bollinger Bands", location=location.absolute, size=size.tiny,
color=colorBigRed)
plotchar(high >= wupperBB and close < wupperBB and close > open and bShowBB ? 46 :
na, char="ß", title="Bollinger Bands", location=location.absolute, size=size.tiny,
color=colorBigGreen)
//plotshape(bullCondAlert ? 0 : na,offset=-lookbackRight,title="Regular Bullish
Label",text="
Bull",style=shape.labelup,location=location.absolute,color=bullColor,textcolor=text
Color)
//plotshape(bearCondAlert ? 50 : na,offset=-lookbackRight,title="Regular Bearish
Label",text="
Bear",style=shape.labeldown,location=location.absolute,color=bearColor,textcolor=te
xtColor)
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= OUTSIDE LINE PLOTS =-=-=-=-=-=-=-=-=-
=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
//EverColor = EverestDown ? colorBigRed : EverestUp ? colorBigGreen :
colorInvisible
vodkaColor = upwards ? colorBigGreen : downwards ? colorBigRed : colorInvisible
imdColor = srcMCD > miMCD ? srcMCD > hiMCD ? colorBigGreen : colorMildGreen :
srcMCD < loMCD ? colorBigRed : colorMildRed
KSTColor = KSTTrue ? colorBigGreen : colorBigRed
bullColor1 = bullDown ? colorBigRed : bullUp ? colorBigGreen : colorInvisible
tripColor = tripBuy ? colorBigGreen : tripSell ? colorBigRed : colorInvisible
cciDoubleColor = colorInvisible
if (cci1 > cci2 and cci1 >= 100)
cciDoubleColor := colorBigGreen
if (cci1 < cci2 and cci1 < -100 and cci1WasGreen)
cciDoubleColor := colorBigRed
if (cci1 > 0)
cci1 := cci1 - 200
if (cci1 < 0)
cci1 := cci1 + 200
cci1 := cci1 + 50
// plot (cci1, color=color.lime)
//plot(71, "Vodka Shot", color=vodkaColor, linewidth=2)
newTrip = ((tripBuy and tripSell[0]) or (tripSell and tripBuy[0]))
plot(55, "Triple Supertrend", color=tripColor, linewidth=1)
plot(newTrip ? 55 : na, "Triple Supertrend", color=tripColor, linewidth=5)
plot(53, "Half Trend", color=htColor, linewidth=1)
plot(51, "CCI Double Cross", color=cciDoubleColor, linewidth=1)
//plot(-53, "Impulse MACD", color=imdColor, linewidth=1)
plot(-55, "Bull Rush", color=bullColor1, linewidth=1)
//plot(29, "Everest", color=EverColor, linewidth=2)
//plot(bShowWAE ? 50 : na, "Waddah Explosion", color=waeColor,
linewidth=thickWaddah)
bgcolor(buySignalDiv and bShowDivies ? color.new(colorMildGreen, bgTrans-10) : na)
bgcolor(sellSignalDiv and bShowDivies ? color.new(colorMildRed, bgTrans-10) : na)
bgcolor(buySignal and bShowBuySellies ? color.new(colorMildGreen, bgTrans) : na)
bgcolor(sellSignal and bShowBuySellies ? color.new(colorMildRed, bgTrans) : na)
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= DASHBOARD =-=-=-=-=-=-=-=-=-=-=-=-=-
=-=-=-=-=-=-=-=-=-=-= //
/////////////////
///////////////////////////////////////////////////////////////////////////////////
/////////////
// Get user input
indicatorTF = "Chart"
// Functions
f_chartTfInMinutes() =>
float _resInMinutes = timeframe.multiplier * (
timeframe.isseconds ? 1. / 60 :
timeframe.isminutes ? 1. :
timeframe.isdaily ? 60. * 24 :
timeframe.isweekly ? 60. * 24 * 7 :
timeframe.ismonthly ? 60. * 24 * 30.4375 : na)
vosc = ta.obv - ta.ema(ta.obv, 20)
bs = ta.ema(nz(math.abs((open - close) / (high - low) * 100)), 3)
ema = ta.ema(close, 200)
emaBull = close > ema
equal_tf(res) => str.tonumber(res) == f_chartTfInMinutes()
higher_tf(res) => str.tonumber(res) > f_chartTfInMinutes()
too_small_tf(res) => (timeframe.isweekly and res=="1") or (timeframe.ismonthly and
str.tonumber(res) < 10)
securityNoRep(sym, res, src) =>
bool bull = na
bull := equal_tf(res) ? src : bull
bull := higher_tf(res) ? request.security(sym, res, src, barmerge.gaps_off,
barmerge.lookahead_on) : bull
bull_array = request.security_lower_tf(syminfo.tickerid, higher_tf(res) ?
str.tostring(f_chartTfInMinutes()) : too_small_tf(res) ? (timeframe.isweekly ?
"3" : "10") : res, src)
if array.size(bull_array) > 1 and not equal_tf(res) and not higher_tf(res)
bull := array.pop(bull_array)
array.clear(bull_array)
bull
TF1Bull = securityNoRep(syminfo.tickerid, "1" , emaBull)
TF5Bull = securityNoRep(syminfo.tickerid, "5" , emaBull)
TF15Bull = securityNoRep(syminfo.tickerid, "15" , emaBull)
TF30Bull = securityNoRep(syminfo.tickerid, "30" , emaBull)
TF60Bull = securityNoRep(syminfo.tickerid, "60" , emaBull)
TF120Bull = securityNoRep(syminfo.tickerid, "120" , emaBull)
TF240Bull = securityNoRep(syminfo.tickerid, "240" , emaBull)
TFDBull = securityNoRep(syminfo.tickerid, "1440", emaBull)
// Functions
sqz(bbLen, bbMult, kcLen, kcMult, source) =>
upperBB = ta.sma(source, bbLen) + ta.stdev(source, bbLen) * bbMult
lowerBB = ta.sma(source, bbLen) - ta.stdev(source, bbLen) * bbMult
upperKC = ta.sma(source, kcLen) + ta.sma(ta.tr, kcLen) * kcMult
lowerKC = ta.sma(source, kcLen) - ta.sma(ta.tr, kcLen) * kcMult
sqzOn = lowerBB > lowerKC and upperBB < upperKC
sqzOff = lowerBB < lowerKC and upperBB > upperKC
[sqzOn, sqzOff]
qqe(rsiLen, rsiSmooth, factor, source, bbLen, bbMult) =>
rsiMa = ta.ema(ta.rsi(source, rsiLen), rsiSmooth)
delta = ta.ema(ta.ema(math.abs(ta.mom(rsiMa, 1)), rsiLen * 2 - 1), rsiLen *
2 - 1) * factor
longBand = 0.0, longBand := rsiMa > longBand[1] and rsiMa[1] >
longBand[1] ? math.max(longBand[1], rsiMa - delta) : rsiMa - delta
shortBand = 0.0, shortBand := rsiMa < shortBand[1] and rsiMa[1] <
shortBand[1] ? math.min(shortBand[1], rsiMa + delta) : rsiMa + delta
cross1 = ta.cross(rsiMa, shortBand[1])
cross2 = ta.cross(rsiMa, longBand[1])
trend = 0.0, trend := cross1 ? 1 : cross2 ? -1 : nz(trend[1], 1)
fastDelta = trend == 1 ? longBand : shortBand
_hist = rsiMa - 50
_line = fastDelta - 50
[_, upper, lower] = ta.bb(_line, bbLen, bbMult)
[_hist, _line, upper, lower]
// Get components
cond(_offset) =>
top = ta.highest(high, 10)
bot = ta.lowest(low, 10)
osc = ta.ema(hlc3, 5) - ta.ema(ohlc4, 20)
oscRis = osc > osc[1]
oscFal = osc < osc[1]
oscA0 = osc > 0
oscB0 = osc < 0
oscTop = oscFal and oscRis[1]
oscBot = oscRis and oscFal[1]
bullR = oscB0 and oscBot and ((osc > ta.valuewhen(oscB0 and oscBot, osc, 1)
and bot < ta.valuewhen(oscB0 and oscBot, bot, 1)))
bearR = oscA0 and oscTop and ((osc < ta.valuewhen(oscA0 and oscTop, osc, 1)
and top > ta.valuewhen(oscA0 and oscTop, top, 1)))
bullH = oscB0 and oscBot and ((osc < ta.valuewhen(oscB0 and oscBot, osc, 1)
and bot > ta.valuewhen(oscB0 and oscBot, bot, 1)))
bearH = oscA0 and oscTop and ((osc > ta.valuewhen(oscA0 and oscTop, osc, 1)
and top < ta.valuewhen(oscA0 and oscTop, top, 1)))
[sqzOn, sqzOff] = sqz(20, 2, 20, 2, close)
[_hist1, _line1, upper1, lower1] = qqe(6, 6, 3, close, 50, 0.001)
[_hist2, _line2, upper2, lower2] = qqe(6, 5, 1.618, close, 50, 1)
[_, _, tvr] = ta.dmi(14, 14)
[osc[_offset], oscRis[_offset], oscFal[_offset], oscA0[_offset],
oscB0[_offset], oscTop[_offset], oscBot[_offset], bullR[_offset], bearR[_offset],
bullH[_offset], bearH[_offset], sqzOn[_offset], sqzOff[_offset], _hist1[_offset],
upper1[_offset], lower1[_offset], _hist2[_offset], _line2[_offset], tvr[_offset]]
tf = indicatorTF == "Chart" ? timeframe.period : indicatorTF == "1 minute" ? "1" :
indicatorTF == "3 minutes" ? "3" : indicatorTF == "5 minutes" ? "5" : indicatorTF
== "10 minutes" ? "10" : indicatorTF == "15 minutes" ? "15" : indicatorTF == "30
minutes" ? "30" : indicatorTF == "45 minutes" ? "45" : indicatorTF == "1 hour" ?
"60" : indicatorTF == "2 hours" ? "120" : indicatorTF == "3 hours" ? "180" :
indicatorTF == "4 hours" ? "240" : indicatorTF == "12 hours" ? "720" : indicatorTF
== "1 day" ? "1D" : indicatorTF == "1 week" ? "1W" : indicatorTF == "1 month" ?
"1M" : na
[osc, oscRis, oscFal, oscA0, oscB0, oscTop, oscBot, bullR, bearR, bullH, bearH,
sqzOn, sqzOff, _hist1, upper1, lower1, _hist2, _line2, tvr] =
request.security(syminfo.tickerid, tf, cond(indicatorTF != "Chart" and
barstate.isrealtime ? 1 : 0))
//colorTVR = tvr < 15 ? #F6525F : tvr > 15 and tvr < 25 ? #B2B5BE : #66BB6A
// Plots
//plot(Presets == "Money Moves TrendVR" ? tvr : na, "", colorTVR, editable=false)
[_, _, adx] = ta.dmi(14, 14)
consFilter = adx > 20
TrendText = "Trending 🚀"
if adx <20
TrendText := "Ranging ⚠️"
//---------------------------------------------------------------------------------
---------------------- Volatitiry
//Calculates Volatility for Dashboard
atrr = 3 * ta.atr(10)
stdAtr = 2 * ta.stdev(atrr, 20)
smaAtr = ta.sma(atrr, 20)
topAtrDev = smaAtr + stdAtr
bottomAtrDev = smaAtr - stdAtr
calcDev = (atrr - bottomAtrDev) / (topAtrDev - bottomAtrDev)
percentVol = 40 * calcDev + 30
//////////////////////////////////////////
adxl=input(14, title='ADX/DMI length', group='Settings: ADX')
adxs=input(14, title='ADX/DMI smooth length', group='Settings: ADX')
adxHighLevel = input(50, title="High ADX Level")
adxExhaustionLevel = input(25, title="ADX Exhaustion Level")
TrueRange = math.max(math.max(high - low, math.abs(high - nz(close[1]))),
math.abs(low - nz(close[1])))
DirectionalMovementPlus = high - nz(high[1]) > nz(low[1]) - low ? math.max(high -
nz(high[1]), 0) : 0
DirectionalMovementMinus = nz(low[1]) - low > high - nz(high[1]) ?
math.max(nz(low[1]) - low, 0) : 0
SmoothedTrueRange = 0.0
SmoothedTrueRange := nz(SmoothedTrueRange[1]) - nz(SmoothedTrueRange[1]) / adxl +
TrueRange
SmoothedDirectionalMovementPlus = 0.0
SmoothedDirectionalMovementPlus := nz(SmoothedDirectionalMovementPlus[1]) -
nz(SmoothedDirectionalMovementPlus[1]) / adxl + DirectionalMovementPlus
SmoothedDirectionalMovementMinus = 0.0
SmoothedDirectionalMovementMinus := nz(SmoothedDirectionalMovementMinus[1]) -
nz(SmoothedDirectionalMovementMinus[1]) / adxl + DirectionalMovementMinus
DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
DX1 = math.abs(DIPlus - DIMinus) / (DIPlus + DIMinus) * 100
ADX1 = ta.sma(DX1, adxl)
adxColor = ADX1 > 50 ? (DIPlus > DIMinus ? color.new(#00ff00, 10) :
color.new(#e60bdb, 0)) : ADX1 > 25 ? (DIPlus > DIMinus ? (ADX1[1] < ADX1 ?
color.new(#00ff00, 30) : color.new(#00ff00, 0)) : (ADX1[1] < ADX1 ?
color.new(color.rgb(255, 0, 0), 30) : color.new(color.rgb(255, 0, 0), 0))) : ADX1 >
10 ? (DIPlus > DIMinus ? color.new(#008000, 0) : color.new(color.rgb(255, 0, 0),
50)) : color.gray // Neutral trend
// Volume compared to avgVolume Block //
//---------//
avgArrayVolumeValues = ta.ema(volume, 14)
volumeStatus = volume > avgArrayVolumeValues*1.8 ? "Very high volume" : volume >
avgArrayVolumeValues*1.4 ? "High volume" : volume < avgArrayVolumeValues*0.6 ?
"Very low volume" : volume < avgArrayVolumeValues*0.8 ? "Low volume" : "Normal
volume"
colorVolume = volumeStatus == "Very high volume" ? color.new(color.green,60) :
volumeStatus == "High volume" ? color.new(color.green,80) : volumeStatus == "Very
low volume" ? color.new(color.red,80) : volumeStatus == "Low volume" ?
color.new(color.red,60): color.gray
totalSentTxt = volumeStatus
// # ============================[DASHBOARD]============================ #
// RSI Block //
//---------//
rsiStatus = rsi > 85 ? "Very overbought" : rsi > 70 ? "Overbought" : rsi < 15 ?
"Very oversold" : rsi < 30 ? "Oversold" : "Neutral"
rsiColor1 = rsiStatus == "Very overbought" ? color.new(color.red,60) : rsiStatus ==
"Overbought" ? color.new(color.red,80) : rsiStatus == "Very oversold" ?
color.new(color.green,60) : rsiStatus == "Oversold" ? color.new(color.green,80) :
color.gray
// EMA Block //
//---------//
ema1 = ta.ema(close, 9)
ema1Status = close > ema1 ? "closed above" : "closed below"
ema2 = ta.ema(close, 21)
ema2Status = close > ema2 ? "closed above" : "closed below"
ema3 = ta.ema(close, 50)
ema3Status = close > ema3 ? "closed above" : "closed below"
ema4Status = close > ema ? "closed above" : "closed below"
emaAboveCount = 0
emaAboveCount += ema1Status == "closed above" ? 1 : 0
emaAboveCount += ema2Status == "closed above" ? 1 : 0
emaAboveCount += ema3Status == "closed above" ? 1 : 0
emaAboveCount += ema4Status == "closed above" ? 1 : 0
emaColor = emaAboveCount > 3 ? color.new(color.green, 60) : emaAboveCount > 2 ?
color.new(color.green, 80) : emaAboveCount < 1 ? color.new(color.red, 60) :
emaAboveCount < 2 ? color.new(color.red, 80) : color.gray
emaStatus = emaAboveCount > 3 ? "Very bullish" : emaAboveCount > 2 ? "Bullish" :
emaAboveCount < 1 ? "Very bearish" : emaAboveCount < 2 ? "Bearish" : "Neutral"
// MFI Block //
//---------//
mfiStatus = mfi > 90 ? "Very overbought" : mfi > 80 ? "Overbought" : mfi < 10 ?
"Very oversold" : mfi < 20 ? "Oversold" : "Neutral"
mfiColor1 = mfiStatus == "Very overbought" ? color.new(color.red,60) : mfiStatus ==
"Overbought" ? color.new(color.red,80) : mfiStatus == "Very oversold" ?
color.new(color.green,60) : mfiStatus == "Oversold" ? color.new(color.green,80) :
color.gray
//-----------------------------------------------------------------------------}
//Overlays color.green : color.red
//
var dashboard_loc = locationDashboard == "Top Right" ? position.top_right :
locationDashboard == "Middle Right" ? position.middle_right : locationDashboard ==
"Bottom Right" ? position.bottom_right : locationDashboard == "Top Center" ?
position.top_center : locationDashboard == "Middle Center" ? position.middle_center
: locationDashboard == "Bottom Center" ? position.bottom_center : locationDashboard
== "Top Left" ? position.top_left : locationDashboard == "Middle Left" ?
position.middle_left : position.bottom_left
var dashboard_size = sizeDashboard == "Large" ? size.large : sizeDashboard ==
"Normal" ? size.normal : sizeDashboard == "Small" ? size.small : size.tiny
var dashboard = showDashboard ? table.new(dashboard_loc, 3, 9, color.rgb(30,
34, 45 , 60), #3d384300, 2, color.rgb(30, 34, 45 , 60), 1) : na
dashboard_cell(column, row, txt, signal=false) => table.cell(dashboard, column,
row, txt, 0, 0, signal ? #000000 : color.white, text_size=dashboard_size)
dashboard_cell_bg(column, row, col) => table.cell_set_bgcolor(dashboard, column,
row, col)
if barstate.islast and showDashboard
// MTF Trend
dashboard_cell(0, 0 , "MTF")
dashboard_cell(0, 2 , "M1") , dashboard_cell_bg(0, 2 , TF1Bull ? color.green :
color.red)
dashboard_cell(0, 3 , "M5") , dashboard_cell_bg(0, 3 , TF5Bull ? color.green :
color.red)
dashboard_cell(0, 4 , "M15") , dashboard_cell_bg(0, 4 , TF15Bull ? color.green
: color.red)
dashboard_cell(0, 5 , "M30") , dashboard_cell_bg(0, 5 , TF30Bull ? color.green
: color.red)
dashboard_cell(0, 6 , "1H") , dashboard_cell_bg(0, 6, TF60Bull ? color.green :
color.red)
dashboard_cell(0, 7 , "4H") , dashboard_cell_bg(0, 7 , TF240Bull ? color.green
: color.red)
dashboard_cell(0, 8 , "1D") , dashboard_cell_bg(0, 8 , TFDBull ? color.green :
color.red)
// Middel part
dashboard_cell(1, 0 , "Signals")
dashboard_cell(1, 2 , "🔥 Market State ")
dashboard_cell(1, 3 , "⚠️ Volatility ")
dashboard_cell(1, 4 , "RSI")
dashboard_cell(1, 5 , "ADX")
dashboard_cell(1, 6 , "Volume")
dashboard_cell(1, 7 , "EMA")
dashboard_cell(1, 8 , "MFI")
// End part
dashboard_cell(2, 0 , "")
dashboard_cell(2, 2 , TrendText) , dashboard_cell_bg(2, 2, adx > 20 ?
color.new(color.green,50) : color.new(color.orange,50))
dashboard_cell(2, 3 , str.tostring(percentVol, '##.##') + '%')
dashboard_cell(2, 4 , rsiStatus+" ["+str.tostring(math.round(rsi))+"]") ,
dashboard_cell_bg(2, 4 , rsiColor1)
dashboard_cell(2, 5 , str.tostring(math.round(ADX1))) , dashboard_cell_bg(2,
5 , adxColor)
dashboard_cell(2, 6 , totalSentTxt) , dashboard_cell_bg(2, 6, colorVolume)
dashboard_cell(2, 7 , emaStatus) , dashboard_cell_bg(2, 7, emaColor)
dashboard_cell(2, 8 , mfiStatus) , dashboard_cell_bg(2, 8, mfiColor1)
///////////////////
dwTL = "Length of the hyper wave"
smTL = "[SMA] Smooth signal with a simple moving average\n[EMA] Smooth signal with
an exponential moving average\n[Input] Length of the smooth"
dvTL = "Sensibility of the real time divergence : less sensibility = more short
term divs; more sensibility = more long term divs"
cmTL = "Show confluence meter at the side of the oscillator"
caTL = "Show confluence area at the bottom/top of the oscillator"
rfTL = "More factor will return in less signals but in a stronger way, less factor
will return more signal with less strength"
simple bool dW = input.bool (true , "Main Length
", inline = "1 ", group = "HYPER WAVE" , tooltip =
dwTL)
simple int mL = input.int (7 , "
", inline = "1 ", group = "HYPER WAVE", minval = 5, maxval = 4999)
simple string sT = input.string("SMA" , "Signal
", inline = "s ", group = "HYPER WAVE", options = ["SMA", "EMA"], tooltip =
smTL)
simple int sL = input.int (3 , "
", inline = "s ", group = "HYPER WAVE", minval = 2, maxval = 4999)
simple color fCSS = input.color (#51B155 , "Colors
", inline = "css ", group = "HYPER WAVE")
simple color sCSS = input.color (#80828D , "
", inline = "css ", group = "HYPER WAVE")
simple int tCSS = input.int (80 , "
", inline = "css ", group = "HYPER WAVE", minval = 0, maxval = 100)
simple int dvT = input.int (20 , "Divergence
Sensibility ", inline = "x ", group = "HYPER WAVE", minval = 20, maxval = 40 ,
tooltip = dvTL)
simple bool sDiv = input.bool (true , "Show Divergences
", inline = "div ", group = "HYPER WAVE")
simple color blDv = colorBigGreen
simple color brDv = input.color (color.new(#f23645, 20), "
", inline = "div ", group = "HYPER WAVE")
simple bool Smf = input.bool (true , "Money Flow Length
", inline = "mfi ", group = "SMART MONEY FLOW")
simple int mfL = input.int (35 , "
", inline = "mfi ", group = "SMART MONEY FLOW", minval = 10, maxval = 55)
simple int mfS = input.int (6 , "Smooth
", inline = "mfx ", group = "SMART MONEY FLOW", minval = 2 , maxval = 10)
simple color mfBL = colorBigGreen
simple color mfBR = colorBigRed
simple color cnBL = colorBigGreen
simple color cnBR = colorBigRed
simple bool sCNF = input.bool (true , "Show Confluence
Meter ", inline = "zf ", group = "CONFLUENCE", tooltip = cmTL)
simple bool sCNB = input.bool (true , "Show Confluence
Areas ", inline = "zx ", group = "CONFLUENCE", tooltip = caTL)
simple bool rsS = input.bool (true , "Reversal Factor
", inline = "rv ", group = "REVERSAL")
simple int rsF = input.int (4 , "
", inline = "rv ", group = "REVERSAL", options = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
tooltip = rfTL)
simple color rsBL = input.color (#089981 , "Reversal
Colors ", inline = "rc ", group = "REVERSAL")
simple color rsBR = input.color (#f23645 , "
", inline = "rc ", group = "REVERSAL")
type oL
float sig
float sgD
color cO
type dP
int n
float src
float p
type smf
float mfi
color mfc
float blMFI
float brMFI
type cnf
color up
color dn
float[] blT
float[] brT
var oL osc1 = oL.new (na, na, na )
var dP div = dP.new (na, na, na )
var smf mf = smf.new(na, na, na, na)
var cnf cf = cnf.new(
color.rgb(54, 58, 69, 60)
, color.rgb(54, 58, 69, 60)
, array.new<float>(1, na)
, array.new<float>(1, na)
)
mfT() =>
switch
mf.mfi > 0 =>
if cf.brT.size() > 1
cf.brT.pop()
if cf.blT.size() > mfL
cf.blT.pop()
if mf.mfi > cf.blT.avg()
cf.blT.unshift(mf.mfi)
else
cf.blT.unshift(mf.mfi[mfL] > 0
? mf.mfi[mfL]
: mf.mfi
)
mf.mfi < 0 =>
if cf.blT.size() > 1
cf.blT.pop()
if cf.brT.size() > mfL
cf.brT.pop()
if mf.mfi < cf.blT.avg()
cf.brT.unshift(mf.mfi)
else
cf.brT.unshift(mf.mfi[mfL] < 0
? mf.mfi[mfL]
: mf.mfi
)
method st(simple string src, float osc1, simple int len) =>
float o = switch src
"SMA" => ta.sma(osc1, len)
"EMA" => ta.ema(osc1, len)
method css(color x, int inv) =>
color out = inv == 1
? color.new(x, tCSS)
: color.new(x, 0 )
method transp(color x, int t) =>
color.new(x, t)
rv() =>
vMA = ta.sma(volume, 7)
rsi = ta.rsi(vMA, 7) - 50
tMj = volume > vMA * ( rsF != 10 ? 1 + (rsF / 10) : 2) ? true :
false
tMn = volume > vMA * ( rsF != 10 ? 0 + (rsF / 10) : 2) and not tMj ? true :
false
mjBR = tMj and osc1.sig > rsF and mf.mfi > cf.blT.avg() ? true :
false
mjBL = tMj and osc1.sig < -rsF and mf.mfi < cf.brT.avg() ? true :
false
mnBR = tMn and osc1.sig > 20 and osc1.sig > osc1.sgD and rsi > 20 ? true :
false
mnBL = tMn and osc1.sig < -20 and osc1.sig < osc1.sgD and rsi < -20 ? true :
false
[mjBL, mjBR, mnBR, mnBL]
osc(simple int len, simple int smt) =>
float hi = ta.highest( len)
float lo = ta.lowest ( len)
float av = ta.sma (hl2, len)
osc1.sig := ta.ema(ta.linreg((close - math.avg(hi, lo, av)) / (hi - lo) * 100,
len, 0), sL)
osc1.sgD := sT.st(osc1.sig, 2)
osc1.cO := osc1.sig > osc1.sgD ? fCSS.css(1) : sCSS.css(1)
mfi() =>
mf.mfi := ta.sma(ta.mfi(hl2, mfL) - 50, mfS)
mf.mfc := mf.mfi > 0
? mfBL
: mfBR
bL = mf.mfi - 10
bR = mf.mfi + 10
mf.blMFI := mf.mfi > 0 and mf.mfi > cf.blT.avg()
? bL
: 0
mf.brMFI := mf.mfi < 0 and mf.mfi < cf.brT.avg()
? bR
: 0
cDiv() =>
mx = math.max(osc1.sig, osc1.sgD, osc1.sig[1], osc1.sgD[1])
mn = math.min(osc1.sig, osc1.sgD, osc1.sig[1], osc1.sgD[1])
mxid = mx == osc1.sig[1] or mx == osc1.sgD[1] ? 1 : 0
mnid = mn == osc1.sig[1] or mn == osc1.sgD[1] ? 1 : 0
switch
osc1.sig > dvT =>
if ta.crossunder(osc1.sig, osc1.sgD)
switch
na(div.src) =>
div.n := bar_index - mxid
div.src := math.max(open[mxid], close[mxid])
div.p := mx
not na(div.src) =>
if math.max(open[mxid], close[mxid]) > div.src and
not(osc1.sig[mxid] > div.p)
line.new(x1 = div.n, x2 = bar_index - mxid, y1 = div.p,
y2 = mx, color = brDv)
div.n := na
div.src := na
div.p := na
else
div.n := bar_index - mxid
div.src := math.max(open[mxid], close[mxid])
div.p := mx
osc1.sig < -dvT =>
if ta.crossover (osc1.sig, osc1.sgD)
switch
na(div.src) =>
div.n := bar_index - mnid
div.src := math.min(open[mnid], close[mnid])
div.p := mn
not na(div.src) =>
if math.min(open[mnid], close[mnid]) < div.src and
not(osc1.sig[mnid] < div.p)
line.new(x1 = div.n, x2 = bar_index - mnid, y1 = div.p,
y2 = mn, color = blDv)
div.n := na
div.src := na
div.p := na
else
div.n := bar_index - mnid
div.src := math.min(open[mnid], close[mnid])
div.p := mn
osc(mL, sL)
mfi()
mfT()
if sDiv
cDiv()
[mjBL, mjBR, mnBR, mnBL] = rv()
// REVERSAL SIGNAL
//plotshape(mjBL and rsS ? -65 : na, location = location.absolute, color = rsBL,
size = size.tiny, style = shape.triangleup, title = "Bearish Reversal")
//plotshape(mjBR and rsS ? 65 : na, location = location.absolute, color = rsBR,
size = size.tiny, style = shape.triangledown, title = "Bullish Reversal")
//plot(mnBL and rsS ? -65 : na, color = rsBL, linewidth = 1, style =
plot.style_circles, title = "Minor Bullish Reversal")
//plot(mnBR and rsS ? 65 : na, color = rsBR, linewidth = 1, style =
plot.style_circles, title = "Minor Bearish Reversal")
// HYPER WAVE
plot(ta.crossover (osc1.sig, osc1.sgD) and dW ? math.min(osc1.sig, osc1.sgD) : na,
style = plot.style_circles, linewidth = 2, color = osc1.cO.css(0), offset = 0)
plot(ta.crossunder(osc1.sig, osc1.sgD) and dW ? math.max(osc1.sig, osc1.sgD) : na,
style = plot.style_circles, linewidth = 2, color = osc1.cO.css(0), offset = 0)
pO = plot(dW ? osc1.sig : na, color = osc1.cO.css(0) , title
= "Hyper Wave 1")
iO = plot(dW ? osc1.sgD : na, color = osc1.cO.css(1), display = display.none, title
= "Hyper Wave 2")
bL = plot(0 , color = color.black )
fill(pO, iO, color = dW ? osc1.cO : na)
//SMART MONEY FLOW
pmf = plot(Smf ? mf.mfi : na, color = mf.mfc
)
blT = plot(mf.blMFI > 0 and mf.mfi > 0 ? mf.blMFI : 0 , color = na, display =
display.none)
brT = plot(mf.brMFI < 0 and mf.mfi < 0 ? mf.brMFI : 0 , color = na, display =
display.none)
fill(bL, pmf, mf.mfc.transp(Smf ? 50 : 100))
fill(bL, blT, mf.mfc.transp(Smf ? 0 : 100))
fill(bL, brT, mf.mfc.transp(Smf ? 0 : 100))
cf.up := color.rgb(54, 58, 69, 60)
//cf.dn := color.rgb(54, 58, 69, 60)
switch
osc1.sig > 0 and mf.mfi > 0 => cf.up := cnBL
osc1.sig < 0 and mf.mfi < 0 => cf.up := cnBR
=>
cf.dn := cnBR.transp(60)
cf.up := cnBL.transp(60)
//tLv = plot( 57, color = sCNB ? cf.up : na)
//bLv = plot(57, color = sCNB ? cf.dn : na)
//tfL = plot( 50, display = display.none)
//dfL = plot(-50, display = display.none)
//fill(tLv, tfL, color = sCNB ? cf.up : na)
//fill(bLv, dfL, color = sCNB ? cf.dn : na)
plot(mf.mfi > 0 and Smf ? cf.blT.avg() : na, color = mfBL, style =
plot.style_linebr, title = "Bullish Threshold")
plot(mf.mfi < 0 and Smf ? cf.brT.avg() : na, color = mfBR, style =
plot.style_linebr, title = "Bearish Threshold")
//CONFLUENCE METER
if barstate.islast
line.new(x1 = last_bar_index, x2 = bar_index - 1, y1 = 20, y2 = 20, color =
chart.fg_color.transp(50), style = line.style_dashed, extend = extend.right)
line.new(x1 = last_bar_index, x2 = bar_index - 1, y1 = -20, y2 = -20, color =
chart.fg_color.transp(50), style = line.style_dashed, extend = extend.right)
if sCNF
var line[] ln = array.new<line>()
for j in ln
j.delete()
ln.clear()
var label lb = na
lb.delete()
lb := na
for i = 0 to 21
int id = switch i
0 => 55
1 => 50
2 => 45
3 => 40
4 => 35
5 => 30
6 => 25
7 => 20
8 => 15
9 => 10
10 => 5
11 => 0
12 => -5
13 => -10
14 => -15
15 => -20
16 => -25
17 => -30
18 => -35
19 => -40
20 => -45
21 => -50
ln.unshift(
line.new(
x1 = bar_index + 2
, x2 = bar_index + 2
, y1 = id
, y2 = id - 5
, color = color.from_gradient(id, -50, 55, cnBR, cnBL)
, width = 4
)
)
cnfP = switch
osc1.sig > 0 and mf.mfi > 0 and mf.mfi > cf.blT.avg() => 40
osc1.sig < 0 and mf.mfi < 0 and mf.mfi < cf.brT.avg() => -40
osc1.sig > 0 and mf.mfi > 0 => 20
osc1.sig < 0 and mf.mfi < 0 => -20
osc1.sig > 0 and mf.mfi < 0 => 0
osc1.sig < 0 and mf.mfi > 0 => 0
lb := label.new(
x = bar_index + 3
, y = cnfP
, text = "◀"
, color = na
, textcolor = chart.fg_color
, size = size.small
, style = label.style_label_left
)
///////////////
/////////////////////SCRIPT END//////////////////////////
//@version=5
//indicator("Volume Based Buy and Sell Momentum by 2tm", shorttitle="VBSM",
overlay=false)
EMA_Len = input.int(15, title="ROC MA Length", minval=1)
Delta_MA = input.int(6, title="Delta MA Length", minval=1)
Avg_Delta_MA = input.int(8, title="Avg Delta MA Length", minval=1)
ColorBars = input.bool(true, title="Color Bars")
xROC = ta.roc(close, 1)
var float nRes1 = na
var float nRes2 = na
var float nRes3 = na
var float nResEMA3 = na
var float PNVI_PEMA_Diff = na
var float PNVI_PEMA_Diff_Hist = na
var color lightUpColor = na
var color lightDownColor = na
var color bullBrush = color.new(color.lime, 0)
var color bearBrush = color.new(color.red, 0)
var color noTrendBrush = color.new(color.gray, 0)
if (na(nRes1))
nRes1 := 0.0
nRes2 := 0.0
nRes3 := 0.0
nResEMA3 := 0.0
PNVI_PEMA_Diff := 0.0
PNVI_PEMA_Diff_Hist := 0.0
lightUpColor := color.new(bullBrush, 60)
lightDownColor := color.new(bearBrush, 60)
nRes1 := volume < volume[1] ? nz(nRes1[1]) + xROC : nz(nRes1[1])
nRes2 := volume > volume[1] ? nz(nRes2[1]) + xROC : nz(nRes2[1])
nRes3 := nRes1 + nRes2
nResEMA3 := ta.sma(nRes1, EMA_Len) + ta.sma(nRes2, EMA_Len)
PNVI_PEMA_Diff := nRes3 - nResEMA3
PNVI_PEMA_Diff_Hist := PNVI_PEMA_Diff * 0.5
PVI_NVI = ta.ema(PNVI_PEMA_Diff, Delta_MA)
PEMA = ta.ema(PVI_NVI, Avg_Delta_MA)
//plot(-51, title="PVI PEMA Diff Histogram", color=PNVI_PEMA_Diff > 0 and PVI_NVI >
PEMA ? colorBigGreen:PNVI_PEMA_Diff < 0 and PVI_NVI < PEMA ? colorBigRed :
PNVI_PEMA_Diff > 0?colorMildGreen: PNVI_PEMA_Diff < 0? colorMildRed:noTrendBrush,
style=plot.style_line,linewidth=2)
plot(-51, title="PVI PEMA Diff Histogram", color=PNVI_PEMA_Diff > 0 and PVI_NVI >
PEMA ? colorBigGreen:PNVI_PEMA_Diff < 0 and PVI_NVI < PEMA ? colorBigRed :
noTrendBrush, style=plot.style_line,linewidth=2)
barcolor(ColorBars and PNVI_PEMA_Diff > 0 and PVI_NVI > PEMA ? colorBigGreen :
ColorBars and PNVI_PEMA_Diff < 0 and PVI_NVI < PEMA ? colorBigRed : color.purple)
//waeColor1 = s.h?color.purple:PNVI_PEMA_Diff > 0 and PVI_NVI > PEMA ?
color.green:PNVI_PEMA_Diff < 0 and PVI_NVI < PEMA ? colorBigRed : PNVI_PEMA_Diff >
0?colorMildGreen: PNVI_PEMA_Diff < 0? colorMildRed:color.gray
//barcolor(waeColor1)
//////////////////////////////////////////////////////////////////////////////////
_
='
+-----------------------+
┃ Constants ┃
+-----------------------+
'//{
const string tg = 'Choose how to display the Confluence Gauges.'
const string tm = 'Calibrates the length of the main oscillator ribbon as well as
the period for the squeeze algorithm.'
const string ts = 'Controls the width of the ribbon.\nLower values result in
faster responsiveness at the cost of premature positives.'
const string td = 'Adjusts a threshold to limit the amount of divergences detected
based on strength.\nHigher values result in less detections.'
const string go = 'Squeeze Momentum'
const string gd = 'Directional Flux'
const string gl = 'Divergences'
const string gg = 'Gauges'
const string ss = 'Sell Signal'
const string sb = 'Buy Signal'
const string sob = 'Momentum Bullish'
const string sos = 'Momentum Bearish'
const string sfb = 'Flux Bullish'
const string sfs = 'Flux Bearish'
const string ssb = 'Bullish Swing'
const string sss = 'Bearish Swing'
const string sgb = 'Strong Bull Gauge'
const string sgs = 'Strong Bear Gauge'
const string swb = 'Weak Bull Gauge'
const string sws = 'Weak Bear Gauge'
const string shs = 'High Squeeze'
const string sms = 'Normal Squeeze'
const string sls = 'Low Squeeze'
const string sds = 'Bearish Divergence'
const string sdb = 'Bullish Divergence'
const color colup = #ffcfa6
const color coldn = #419fec
const color colpf = #ffd0a6
const color coldf = #4683b4
const color colps = #169b5d
const color colng = #970529
const color colpo = #11cf77
const color colno = #d11645
const color colsh = #ff1100
const color colsm = #ff5e00
const color colsl = #ffa600
const color colnt = #787b8635
var color coltx = chart.fg_color
var color trnsp = chart.bg_color
//}
_
='
+-----------------------+
┃ Inputs ┃
+-----------------------+
+-----------------------+'//{
dfb = input.bool (true , "" ,
inline = '1', group = gd)
dfl = input.int (7 , "Length " , 7 , 50, 1 ,
inline = '1', group = gd)
dfh = input.bool (false , "Trend Bias" ,
group = gd)
cps = input.color (colps , "" ,
inline = '2', group = gd)
cng = input.color (colng , "" ,
inline = '2', group = gd)
cpo = input.color (colpo , "" ,
inline = '3', group = gd)
cno = input.color (colno , "" ,
inline = '3', group = gd)
smb = input.bool (true , "" ,
inline = '1', group = go)
len = input.int (20 , "Length " , 7 , 50, 1 , tm,
'1', go)
sig1 = input.int (3 , "Signal " , 2 , 7, 1 , ts,
group = go)
cup = input.color (colup , "" ,
inline = '2', group = go)
cdn = input.color (coldn , "" ,
inline = '2', group = go)
cpf = input.color (colpf , "" ,
inline = '3', group = go)
cdf = input.color (coldf , "" ,
inline = '3', group = go)
trs = input.int (25 , "Sensitivity ", 20, 40, 1 , td,
group = gl)
dbl = input.bool (true , "Lines" ,
group = gl)
dbs = input.bool (true , "Labels" ,
group = gl)
cdu = input.color (colpo , "" ,
inline = '1', group = gl)
cdd = input.color (colno , "" ,
inline = '1', group = gl)
gds = input.string('Both', "Showcase " , ['Both', 'Bull', 'Bear', 'None'], tg,
'4', gg)
cgp = input.color (colps , "" ,
inline = '2', group = gg)
cgn = input.color (colng , "" ,
inline = '2', group = gg)
//}
_
='
+-----------------------+
┃ UDTs ┃
+-----------------------+
'//{
type bar
float o = open
float h = high
float l = low
float c = close
int i = bar_index
type osc2
float o = na
float s = na
type squeeze
bool h = false
bool m = false
bool l = false
type gauge
float u = na
float l = na
color c = chart.fg_color
bool p = true
type divergence
float p = na
float s = na
int i = na
type alerts
bool b = false
bool s = false
bool u = false
bool d = false
bool p = false
bool n = false
bool x = false
bool y = false
bool a = false
bool c = false
bool q = false
bool w = false
bool h = false
bool m = false
bool l = false
bool e = false
bool f = false
type prompt
string s = ''
bool c = false
//}
_
='
+-----------------------+
┃ Methods ┃
+-----------------------+
'//{
method any(alerts a) =>
string s = switch
a.s => ss
a.b => sb
a.u => sob
a.d => sos
a.p => sfb
a.n => sfs
a.x => sss
a.y => ssb
a.q => sgb
a.w => sgs
a.a => swb
a.c => sws
a.h => shs
a.m => sms
a.l => sls
a.e => sds
a.f => sdb
=> na
prompt.new(s, not na(s))
method src(bar b, simple string src) =>
float x = switch src
'oc2' => math.avg(b.o, b.c )
'hl2' => math.avg(b.h, b.l )
'hlc3' => math.avg(b.h, b.l, b.c )
'ohlc4' => math.avg(b.o, b.h, b.l, b.c)
'hlcc4' => math.avg(b.h, b.l, b.c, b.c)
method ha(bar b, simple bool p = true) =>
var bar x = bar.new( )
x.c := b .src('ohlc4')
x := bar.new(
na(x.o[1]) ? b.src('oc2') : nz(x.src('oc2')[1]),
math.max(b.h, math.max(x.o, x.c)) ,
math.min(b.l, math.min(x.o, x.c)) ,
x.c )
p ? x : b
method atr(bar b, simple int len = 1) =>
float tr =
na ( b.h[1] ) ?
b.h - b.l :
math.max(
math.max(
b.h - b.l ,
math.abs( b.h - b.c[1])) ,
math.abs( b.l - b.c[1]))
len == 1 ? tr : ta.rma(tr, len)
method stdev(float src, simple int len) =>
float sq = 0.
float psq = 0.
float sum = 0.
for k = 0 to len - 1
val = nz(src[k])
psq := sq
sq += (val - sq) / (1 + k )
sum += (val - sq) * (val - psq)
math.sqrt(sum / (len - 1))
method osc2(bar b, simple int sig1, simple int len) =>
float av = ta .sma(b.src('hl2'), len)
bar z = bar.new(
b.o ,
ta.highest(len),
ta.lowest (len),
b.c )
float x = ta.linreg((z.c - math.avg(z.src('hl2'), av)) / z.atr() * 100, len,
0)
osc2.new(x, ta.sma(x, sig1))
method dfo(bar b, simple int len) =>
float tr = b .atr ( len)
float up = ta.rma (
math.max (
ta.change(b.h) , 0), len) / (tr)
float dn = ta.rma (
math.max (
ta.change(b.l) * -1, 0), len) / (tr)
float x = ta.rma (
(up - dn) / (up + dn) , len / 2) * 100
osc2.new(
x ,
x > +25 ?
(x - 25) :
x < -25 ?
(x + 25) :
na )
method sqz(bar b, simple int len) =>
array<bool> sqz = array.new<bool>( )
float dev = b.c .stdev (len)
float atr = b .atr (len)
for i = 2 to 4
sqz.unshift(dev < (atr * 0.25 * i))
squeeze.new(sqz.pop(), sqz.pop(), sqz.pop())
method draw(bar b, osc2 o, simple int trs, simple bool s) =>
var divergence d = divergence.new( )
bool u = ta.crossunder (o.o , o.s)
bool l = ta.crossover (o.o , o.s)
float x = o.s
bool p = false
switch
o.o > trs and u and barstate.isconfirmed =>
switch
na(d.p) =>
d := divergence.new(b.h, x, b.i)
p := false
not na(d.p) =>
if b.h > d.p and x < d.s
d := divergence.new( )
p := true
else
d := divergence.new(b.h, x, b.i)
p := false
o.o < -trs and l and barstate.isconfirmed =>
switch
na(d.p) =>
d := divergence.new(b.l, x, b.i)
p := false
not na(d.p) =>
if b.l < d.p and x > d.s
d := divergence.new( )
p := true
else
d := divergence.new(b.l, x, b.i)
p := false
//}
_
='
+-----------------------+
┃ Calc ┃
+-----------------------+
'//{
bar b = bar .new ( )
squeeze s = b .sqz ( len)
osc2 o = b .osc2 (sig1, len)
osc2 v = b.ha(dfh).dfo ( dfl)
bool p = b .draw(o, trs, dbl)
gauge u = gauge .new (
+75 ,
+70 ,
v.o > 0 and o.o > 0 ?
cgp :
v.o > 0 or o.o > 0 ?
color.new(cgp , 40) :
colnt ,
gds == 'Both' or gds == 'Bull' )
gauge d = gauge .new (
-75 ,
-70 ,
v.o < 0 and o.o < 0 ?
cgn :
v.o < 0 or o.o < 0 ?
color.new(cgn , 40) :
colnt ,
gds == 'Both' or gds == 'Bear' )
alerts a = alerts .new (
ta.crossover (o.o, o.s) and o.o < -40 and v.o < 0
,
ta.crossunder(o.o, o.s) and o.o > +40 and v.o > 0
,
ta.crossover (o.o, 0)
,
ta.crossunder(o.o, 0)
,
ta.crossover (v.o, 0)
,
ta.crossunder(v.o, 0)
,
ta.crossunder(o.o, o.s) and smb
,
ta.crossover (o.o, o.s) and smb
,
ta.change (u.c == colnt) and u.c == color.new(cgp,
40),
ta.change (d.c == colnt) and d.c == color.new(cgn,
40),
ta.change (u.c == colnt) and u.c == cgp
,
ta.change (d.c == colnt) and d.c == cng
,
ta.change (s.h ) and s.h
,
ta.change (s.m ) and s.m
,
ta.change (s.l ) and s.l
,
p and o.o > trs
,
p and o.o < -trs
)
//}
_
='
+-----------------------+
┃ Visuals ┃
+-----------------------+
'//{
color colsq = s.h ? colsh : s.m ? colsm : colsl
color colvf = v.o > 0 ? color.new(cps , 70) : color.new(cng , 70)
color colof = v.s > 0 ? color.new(cpo , 70) : color.new(cno , 70)
color colsf = o.o > o.s ? color.new(cpf , 50) : color.new(cdf , 50)
color colzf = o.o > o.s ? cup : cdn
//w = plot (smb ? o.o/2 : na, "Mom" , colzf , 1,
plot.style_line )
//dddd = plot (smb ? o.s/2 : na, "Signal" ,
display = display.none)
//fill(w , dddd , colsf)
plotshape(u.p and a.s ? 65 : na, "Confluence Sell" , shape.triangledown,
location.absolute, colno, size = size.tiny)
plotshape(d.p and a.b ? -65 : na, "Confluence Buy " , shape.triangleup ,
location.absolute, colpo, size = size.tiny)
//plotshape(dbs and a.e ? 70 : na, "Bearish Divergence", shape.labeldown ,
location.absolute, colnt, 0, '𝐃▾', colsm )
//plotshape(dbs and a.f ? -70 : na, "Bullish Divergence", shape.labelup ,
location.absolute, colnt, 0, '𝐃▴', colsm )
q = plot (s.l ? -48 : na, "Squeeze" , colsq , 1,
plot.style_columns, false, -47, display = display.pane)
////////////////
//iPPO inputs
pposrc = input(close, title="PPO Source (default=close)")
shortlength = input(12, title="PPO Short EMA Length (default=12)")
longlength = input(26, title="PPO Long EMA Length (default=26)")
siglength = input(9, title="PPO Signal Line EMA Length (default=9)")
showcand = input(true, title="Show PPO Candles? (may not work with multiple candle-
coloring indicators turned on at the same time. Hide or remove other indicators to
ensure proper functionality.)")
showppo = input(true, title="Show PPO Line?")
showsig = input(true, title="Show PPO Signal Line?")
showhisto = input(true, title="Show PPO Histogram?")
showzero = input(true, title="Show Center Line(0 level)?")
fill1 = input(true, title="Fill PPO & Signal Line Gap?")
fill2 = input(true, title="Fill PPO & 0 Level Gap?")
fill3 = input(true, title="Highlight PPO/Signal Line Crosses?")
fill4 = input(true, title="Bullish/Bearish Background Fill?")
plot1 = input(true, title="Show PPO/0 Level Crossover Plots?")
plot2 = input(true, title="Show PPO/Signal Line Crossover Plots?")
//ppo line calcs
shortL = ta.ema(pposrc, shortlength)
longL = ta.ema(pposrc, longlength)
ppoL = (shortL-longL) / longL * 100
sigL = ta.ema(ppoL, siglength)
longLColor = input.color(color.new(#00ff00, 0), title="", group="+++++++++++++
MACD SETTINGS +++++++++++++")
longLColor1 = input.color(color.new(#008800, 0), title="", group="+++++++++++++
MACD SETTINGS +++++++++++++")
shortLColor = input.color(color.new(#ff0000, 0), title="", group="+++++++++++++
MACD SETTINGS +++++++++++++")
shortLColor1 = input.color(color.new(#ff0000, 50), title="", group="++++++++++++
+ MACD SETTINGS +++++++++++++")
//histogram calcs
histL = ppoL - sigL
plotColor = if histL>0
histL > histL[1] ? longLColor : longLColor1
else
histL < histL[1] ? shortLColor : shortLColor1
plotColor2 = showhisto ==1 ? plotColor : na
//////histogram, ppo, signal and 0 level calcs/plots
//histo plot
plot(-53, title="Histogram", style=plot.style_line, color=plotColor2,linewidth = 2)
//ppo cross over/under 0 level calcs/plots
//ppoX0up = plot1 == 1 ? color(#fcff00) : na
//plot(ta.crossover(ppoL, 0) ? 0 : na, style=plot.style_cross,title="PPO Cross Up 0
Level", color=color(ppoX0up), linewidth=5,offset=0)
//ppoX0down = plot1 == 1 ? color(#ff0000) : na
//plot(ta.crossunder(ppoL, 0) ? 0 : na, style=plot.style_cross,title="PPO Cross
Down 0 Level", color=color(ppoX0down), linewidth=5,offset=0)
//ppo cross over/under signal line calcs/plots
ppoXsigup = plot2 == 1 ? color(#00ff00) : na
plot(ta.crossover(ppoL, sigL) ? 0 : na, style=plot.style_circles,title="PPO Cross
Up Signal Line", color=color(ppoXsigup), linewidth=4,offset=0)
ppoXsigdown = plot2 == 1 ? color(#ff00ff) : na
plot(ta.crossunder(ppoL, sigL) ? 0 : na, style=plot.style_circles,title="PPO Cross
Down Signal Line", color=color(ppoXsigdown), linewidth=4,offset=0)
/////////////////////SCRIPT END//////////////////////////