Luxalgo Oscillator Matrix
Luxalgo Oscillator Matrix
upperColor = color.new(#787B86, 0)
lowerColor = color.new(#787B86, 0)
showMeUp = false
mfiColor = #828282
if (mfi > 70)
mfiColor := color.rgb(0, 148, 76)
if (mfi < 30)
mfiColor := color.rgb(147, 0, 0)
// Divergence
lookbackRight = 5
lookbackLeft = 5
rangeUpper = 60
rangeLower = 5
bearColor = colorMildRed
bullColor = colorMildGreen
textColor = color.white
noneColor = color.new(color.white, 100)
// 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")
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]
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)
pos := false
neg := false
// 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
// IMPULSE MACD
calc_smma(src, len) =>
smma = 0.0
smma := na(smma[1]) ? ta.sma(src, len) : (smma[1] * (len - 1) + src) / len
smma
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]
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")
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 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
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)
v5 = volume
vola =
v_calc == 'None' or na(volume) ? 1 :
v_calc == 'Relative' ? ta.stoch(v5, v5, v5, vlookbk) / 100 :
v5
c_up5 = color.new(#11ff20, 0)
c_dn5 = color.new(#ff1111, 0)
c_grow_above = #1b5e2080
c_grow_below = #dc4c4a80
c_fall_above = #66bb6a80
c_fall_below = #ef8e9880
bo = fixnan(asp)
bc = fixnan(adp)
bh = math.max(bo, bc)
bl = math.min(bo, bc)
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
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)
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")
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
if not bApply25and75
bBelow25 := true
bAbove75 := true
b_color = (rsiM > upperWT and bAbove75) ? c_regular_red : (rsiM < lowerWT and
bBelow25) ? c_regular_green : na
colorGreen = colorMildGreen
colorRed = colorMildRed
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))
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)
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)
///////////////////////////////////////////////////////////////////////////////////
/////////////
// 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)
// 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)
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
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
// 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"
rfTL = "More factor will return in less signals but in a stronger way, less factor
will return more signal with less strength"
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
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
)
method st(simple string src, float osc1, simple int len) =>
float o = switch src
"SMA" => ta.sma(osc1, len)
"EMA" => ta.ema(osc1, len)
rv() =>
vMA = ta.sma(volume, 7)
rsi = ta.rsi(vMA, 7) - 50
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
mfi() =>
mf.mfi := ta.sma(ta.mfi(hl2, mfL) - 50, mfS)
bL = mf.mfi - 10
bR = mf.mfi + 10
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])
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
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")
// 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)
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)
//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 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
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)
xROC = ta.roc(close, 1)
//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(waeColor1)
//////////////////////////////////////////////////////////////////////////////////
_
='
+-----------------------+
┃ Constants ┃
+-----------------------+
'//{
//}
_
='
+-----------------------+
┃ Inputs ┃
+-----------------------+
+-----------------------+'//{
//}
_
='
+-----------------------+
┃ 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 ┃
+-----------------------+
'//{
p ? x : b
for k = 0 to len - 1
val = nz(src[k])
psq := sq
sq += (val - sq) / (1 + k )
sum += (val - sq) * (val - psq)
osc2.new(
x ,
x > +25 ?
(x - 25) :
x < -25 ?
(x + 25) :
na )
for i = 2 to 4
sqz.unshift(dev < (atr * 0.25 * i))
switch
o.o > trs and u and barstate.isconfirmed =>
switch
na(d.p) =>
d := divergence.new(b.h, x, b.i)
p := false
//}
_
='
+-----------------------+
┃ Calc ┃
+-----------------------+
'//{
//}
_
='
+-----------------------+
┃ Visuals ┃
+-----------------------+
'//{
////////////////
//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?")
//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
/////////////////////SCRIPT END//////////////////////////