本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("Volume Suite", shorttitle="V Suite", overlay=false, dynamic_requests=true,
max_lines_count=500, max_labels_count=500, max_boxes_count=500, max_bars_back=5000)
V_BASE = 340.0
A_BASE = 240.0
B_BASE = 140.0
C_BASE = 40.0
D_BASE = 0.0
D_HGT = 40.0
gProf = "0 Trader profile"
profile = input.string("Day Trader", "Profile", options=["Scalper", "Day Trader", "Swing", "Investor", "Custom"], group=gProf, tooltip="Presets overwrite every per-indicator length. Choose Custom to use the manual inputs.", display=display.none)
pMFI = profile == "Scalper" ? 10 : profile == "Day Trader" ? 14 : profile == "Swing" ? 14 : 21
pVZO = profile == "Scalper" ? 8 : profile == "Day Trader" ? 14 : profile == "Swing" ? 14 : 28
pCMF = profile == "Scalper" ? 10 : profile == "Day Trader" ? 20 : profile == "Swing" ? 20 : 50
pOBV = profile == "Scalper" ? 50 : profile == "Day Trader" ? 100 : profile == "Swing" ? 200 : 300
pKFa = profile == "Scalper" ? 20 : profile == "Day Trader" ? 34 : profile == "Swing" ? 34 : 55
pKSl = profile == "Scalper" ? 34 : profile == "Day Trader" ? 55 : profile == "Swing" ? 55 : 89
pKSg = profile == "Scalper" ? 9 : profile == "Day Trader" ? 13 : profile == "Swing" ? 13 : 13
pEOm = profile == "Scalper" ? 9 : profile == "Day Trader" ? 14 : profile == "Swing" ? 14 : 20
pEOz = profile == "Scalper" ? 50 : profile == "Day Trader" ? 50 : profile == "Swing" ? 100 : 200
pRVO = profile == "Scalper" ? 14 : profile == "Day Trader" ? 20 : profile == "Swing" ? 50 : 100
gLay = "1 Layout"
layout = input.string("All-in-one (volume + 4 bands)", "Layout", options=["All-in-one (volume + 4 bands)", "Volume band only", "Oscillator bands only"], group=gLay, tooltip="One script can only live in one pane. 'Volume band only' lets you run the same script a second time in its own pane.", display=display.none)
gStyle = "1a Style preset"
layPre = input.string("Custom (individual styles)", "All bands layout", options=["Custom (individual styles)", "Area + Line", "Line + Line", "Area + Columns", "Columns + Columns"], group=gStyle, tooltip="Restyles all six oscillators at once. Custom leaves every band on its own style input below.", display=display.none)
colT = input.int(55, "Overlap transparency (columns layouts)", minval=0, maxval=95, group=gStyle, tooltip="Fades the first oscillator of each pair when both are columns, so the overlapping bars stay readable.", display=display.none)
e1(string own) => layPre == "Custom (individual styles)" ? own : layPre == "Area + Line" ? "Area" : layPre == "Line + Line" ? "Line" : layPre == "Area + Columns" ? "Area" : "Columns"
e2(string own) => layPre == "Custom (individual styles)" ? own : layPre == "Area + Line" ? "Line" : layPre == "Line + Line" ? "Line" : "Columns"
gAx = "1b Fake axis"
showAxis = input.bool(false, "Show fake per-band axis labels (30 / 50 / 70)", group=gAx, display=display.none, tooltip="Prints a small set of reference numbers next to each oscillator band so you can judge where a value sits without reading the price scale. Off by default because the traffic light gauge already shows the live numbers.")
axisPin = input.string("Glued to the right edge", "Axis position", options=["Glued to the right edge", "Fixed bar offset"], group=gAx, display=display.none, tooltip="Where the reference numbers sit. Glued to the right edge keeps them next to the price scale and steady when you zoom. Fixed bar offset places them a set number of candles past the last one.")
axisOff = input.int(10, "Label offset to the right (bars)", minval=0, maxval=200, group=gAx, tooltip="Pushes the fake axis away from the last candle so it does not sit on top of the oscillator.", display=display.none)
axNumCol = input.color(#ffffff, "Axis numbers colour (30 / 50 / 70)", group=gAx, display=display.none, tooltip="Colour of the reference numbers themselves.")
gGauge = "1i Gauge (traffic light)"
showGauge = input.bool(true, "Show the gauge", group=gGauge, display=display.none, tooltip="The traffic light panel. One block per band, coloured by the live state of that band, so the whole pane can be read at a glance. Turn it off if you prefer the raw plots only.")
gPct = input.float(6.0, "Gauge width (% of the pane)", minval=1.0, maxval=100.0, step=0.5, group=gGauge, tooltip="Width as a share of the visible pane, so the gauge keeps its size when you zoom.", display=display.none)
gMinWb = input.float(1.5, "Gauge minimum width (bars)", minval=0.1, maxval=20.0, step=0.1, group=gGauge, tooltip="Hard floor. Raise it if the gauge becomes a sliver when you zoom right in.", display=display.none)
gForce = input.bool(true, "Keep the gauge width even if space is tight", group=gGauge, tooltip="ON: the gauge keeps its width and may run past the pane edge. OFF: it shrinks to fit the space left of the price scale.", display=display.none)
gOff = input.float(3.0, "Traffic light offset (bars)", minval=-10.0, maxval=30.0, step=0.5, group=gGauge, tooltip="Slides ONLY the traffic light to the right or left. The values stay exactly where they are, so this sets the gap between them.", display=display.none)
gBord = input.color(#000000, "Cell border colour", group=gGauge, display=display.none, tooltip="Colour of the thin outline around each gauge cell.")
gBw = input.int(0, "Cell border width", minval=0, maxval=3, group=gGauge, display=display.none, tooltip="Thickness of the outline around each gauge cell. Zero removes the outlines and leaves plain colour blocks.")
gTxt = input.string("Small", "Gauge text size", options=["Tiny", "Small", "Normal"], group=gGauge, display=display.none, tooltip="Text size used inside the gauge.")
gSwap = input.bool(false, "Swap the order inside each pair", group=gGauge, display=display.none, tooltip="Flips the vertical order of the two oscillators inside each band of the gauge. The first oscillator of a pair becomes second and the other way round. Volume and relative volume do not move.")
gSep = "1c Band separators"
showSep = input.bool(false, "Show band separators", group=gSep, display=display.none, tooltip="Draws thin horizontal lines between the bands. Off by default because the bands already separate themselves.")
sepStyle = input.string("Solid", "Separator style", options=["Solid", "Dashed", "Dotted", "None"], group=gSep, display=display.none, tooltip="Line style for the band separators.")
sepCol = input.color(color.new(#000000, 75), "Separator colour", group=gSep, display=display.none, tooltip="Colour of the band separators. The default is almost transparent black so the separators read as a faint seam rather than a hard rule.")
sepW = input.int(1, "Separator width", minval=1, group=gSep, display=display.none, tooltip="Thickness of the band separators.")
gMid = "1d Reference lines (50 and 1.0x)"
showMid = input.bool(true, "Show the 50 / 1.0x reference lines", group=gMid, display=display.none, tooltip="Master switch for the reference lines. Each band also has its own switch, so this only has to be used to silence all of them at once.")
gNR = "1e Non-repainting"
waitClose = input.bool(true, "Wait for candle close confirmation", group=gNR, tooltip="ON (default): while the current candle is still forming, every value is blank. " + "The numbers appear only once the candle closes, and then they can never change.\n" + "This is what makes the indicator non-repainting. Turn it OFF only if you want to watch " + "a value move intrabar - which by definition repaints.", display=display.none)
gVal = "1g Oscillator values"
showVals = input.bool(false, "Show oscillator value", group=gVal, tooltip="A number next to each oscillator, sitting between the last candle and the fake scale. " + "This replaces the dashboard.", display=display.none)
valSize = input.string("Small", "Value text size", options=["Tiny", "Small", "Normal", "Large"], group=gVal, tooltip="Same default size as the band names (MOMENTUM / FLOW / IMPULSE).", display=display.none)
valOff = input.int(4, "Value offset from right edge (bars)", minval=0, maxval=200, group=gVal, tooltip="Keep this SMALLER than the fake-axis offset so the values land between the candles and the scale.", display=display.none)
valColMode = input.string("Same as plot", "Value colour", options=["Same as plot", "Custom"], group=gVal, display=display.none, tooltip="Whether the printed value takes the colour of its plot or a single colour you choose.")
valColUser = input.color(#ffffff, "Custom value colour", group=gVal, display=display.none, tooltip="The colour used for every printed value when the value colour mode is set to custom.")
showVol = layout != "Oscillator bands only"
showOsc = layout != "Volume band only"
gR = "2 Zone RSI"
rsiLen = input.int(14, "RSI length", minval=2, group=gR, display=display.none, tooltip="Lookback for the zone RSI. Shorter reacts faster and produces more zone changes, longer is steadier.")
rsiSrc = input.source(close, "RSI source", group=gR, display=display.none, tooltip="Price series the zone RSI reads. Close is the standard choice.")
rsiVW = input.bool(false, "Volume-weighted RSI", group=gR, display=display.none, tooltip="Weights each move by volume, so a move made on heavy volume counts more than the same move on light volume. Useful on instruments with real traded volume, less useful on tick volume.")
rsiHTF = input.bool(false, "Use higher timeframe RSI (last closed bar)", group=gR, display=display.none, tooltip="Reads the zone RSI from a higher timeframe and uses only its last closed bar, so the higher timeframe reading can never change mid candle.")
rsiTF = input.timeframe("D", "RSI timeframe", group=gR, display=display.none, tooltip="The higher timeframe used when the higher timeframe option is on. It must be higher than your chart timeframe.")
obLvl = input.int(70, "Overbought level (green)", group=gR, display=display.none, tooltip="The upper threshold of the colour model. Values above it are treated as the strongest zone.")
osLvl = input.int(30, "Oversold level (red)", group=gR, display=display.none, tooltip="The lower threshold of the colour model. Values below it are treated as the weakest zone.")
gCol = "2b Zone colours"
cZOB = input.color(#1fff00, "RSI > 70", group=gCol, display=display.none, tooltip="Colour used for the strong zone. It drives the volume columns, the split segments, the dominance markers and the gauge row.")
cZUp = input.color(#ffffff, "RSI 50 - 70", group=gCol, display=display.none, tooltip="Colour used for the upper middle zone.")
cZDn = input.color(#000000, "RSI 30 - 50", group=gCol, display=display.none, tooltip="Colour used for the lower middle zone.")
cZOS = input.color(#cb0000, "RSI < 30", group=gCol, display=display.none, tooltip="Colour used for the weak zone.")
calcZone(source, len, useVol) =>
hi = ta.highest(source, len)
lo = ta.lowest(source, len)
rng = hi - lo
d = source - source[1]
diff = hi > hi[1] ? rng : lo < lo[1] ? -rng : d
vm = useVol ? volume : 1.0
num = ta.rma(diff * vm, len)
den = ta.rma(math.abs(diff) * vm, len)
den == 0.0 ? 50.0 : num / den * 50.0 + 50.0
zoneRsiBase = calcZone(rsiSrc, rsiLen, rsiVW)
zoneRsiHtf = request.security(syminfo.tickerid, rsiTF, calcZone(rsiSrc, rsiLen, rsiVW)[1], lookahead=barmerge.lookahead_off)
zoneRsi = rsiHTF ? zoneRsiHtf : zoneRsiBase
zoneCol = zoneRsi > obLvl ? cZOB : zoneRsi > 50 ? cZUp : zoneRsi > osLvl ? cZDn : cZOS
gV = "3 Split volume"
volMode = input.string("Split (bought / sold)", "Volume mode", options=["Split (bought / sold)", "Plain (total only)"], group=gV, display=display.none, tooltip="Total draws one column per candle. Split draws two stacked segments inside each candle so you can see how much of the volume was bought and how much was sold.")
splitM = input.string("Range proxy", "Split estimation", options=["Range proxy", "Intrabar (LTF)", "Fixed 50 / 50"], group=gV, tooltip="TradingView has no true bid/ask volume. Every split is an ESTIMATE. " + "Range proxy = (close - low) / (high - low). Intrabar sums closed lower-timeframe bars.", display=display.none)
ltfMode = input.string("Auto", "Intrabar timeframe", options=["Auto", "Manual"], group=gV, tooltip="Auto resolves a lower timeframe from your chart timeframe, so the script works on any chart interval. Manual lets you force one, but it must be lower than the chart timeframe.", display=display.none)
ltfTF = input.timeframe("5", "Manual intrabar timeframe", group=gV, display=display.none, tooltip="Only used when the intrabar timeframe is set to Manual. Must be lower than the chart timeframe or TradingView will reject it.")
volNormL = input.int(50, "Volume normalisation lookback", minval=5, group=gV, display=display.none, tooltip="How many candles are used to find the tallest column so every column can be scaled to the band height. A shorter window makes the columns adapt faster.")
sellTrans = input.int(55, "Seller segment transparency", minval=0, maxval=90, group=gV, display=display.none, tooltip="How faded the seller segment is compared with the buyer segment. Faded means sold, solid means bought.")
showDiv = input.bool(false, "Divider line at the buy/sell boundary", group=gV, display=display.none, tooltip="Draws a line along the boundary between the bought and sold segments. Off by default.")
divCol = input.color(#000000, "Divider colour", group=gV, display=display.none, tooltip="Colour of the divider line.")
divW = input.int(1, "Divider width", minval=1, maxval=4, group=gV, display=display.none, tooltip="Thickness of the divider line.")
showBul = input.bool(false, "Dominance square", group=gV, display=display.none, tooltip="Marks candles where one side clearly dominated the other. Off by default. The marker sits above the column so it never covers it.")
bulThr = input.float(15.0, "Dominance threshold %", minval=0, maxval=50, step=1, group=gV, display=display.none, tooltip="How far from an even split one side must be before a marker appears. Fifteen percent means buyers or sellers must hold at least sixty five percent of the candle.")
bulGap = input.float(8.0, "Dominance square gap above the bar", minval=0, maxval=40, step=1, group=gV, display=display.none, tooltip="How far above the volume column the marker floats, so it reads as a mark placed above the bar rather than sitting on it.")
bulShape = input.string("Square", "Dominance square shape", options=["Circle", "Square", "Triangle up"], group=gV, display=display.none, tooltip="Shape of the dominance marker. Circle, square or triangle. Each shape is a separate drawing object, so the list is deliberately short.")
tfS = timeframe.in_seconds()
ltfAuto = tfS <= 60 ? "" : tfS <= 300 ? "1" : tfS <= 900 ? "5" : tfS <= 3600 ? "15" : tfS <= 86400 ? "60" : "240"
ltfUse = ltfMode == "Auto" ? ltfAuto : ltfTF
hasLtf = ltfUse != "" and (ltfMode == "Manual" or tfS > 60)
float iBuy = 0.0
float iTot = 0.0
if hasLtf
ltfC = request.security_lower_tf(syminfo.tickerid, ltfUse, close)
ltfO = request.security_lower_tf(syminfo.tickerid, ltfUse, open)
ltfV = request.security_lower_tf(syminfo.tickerid, ltfUse, volume)
if not na(ltfV) and array.size(ltfV) > 0
for i = 0 to array.size(ltfV) - 1
vv = array.get(ltfV, i)
cc = array.get(ltfC, i)
oo = array.get(ltfO, i)
iTot += vv
iBuy += (cc > oo ? vv : cc < oo ? 0.0 : vv * 0.5)
splitME = hasLtf ? splitM : "Range proxy"
rangePct = high == low ? 0.5 : (close - low) / (high - low)
float buyPct = 0.5
if splitME == "Range proxy"
buyPct := rangePct
else if splitME == "Intrabar (LTF)"
buyPct := iTot > 0 ? math.max(0.0, math.min(1.0, iBuy / iTot)) : rangePct
else
buyPct := 0.5
totVol = splitME == "Intrabar (LTF)" and iTot > 0 ? iTot : volume
buyVol = totVol * buyPct
volMax = ta.highest(totVol, volNormL)
volNorm = volMax > 0 ? math.min(100.0, totVol / volMax * 100.0) : 0.0
buyNorm = volMax > 0 ? math.min(100.0, buyVol / volMax * 100.0) : 0.0
volTotY = V_BASE + volNorm
volBuyY = V_BASE + buyNorm
domBuy = (buyPct - 0.5) * 100.0 >= bulThr
domSell = (0.5 - buyPct) * 100.0 >= bulThr
bulY = volTotY + bulGap
isSplit = volMode == "Split (bought / sold)"
liveOff = waitClose and not barstate.isconfirmed
f1(float v) => str.tostring(v, "#.0")
f2(float v) => str.tostring(v, "#.00")
fs1(float v) => str.tostring(v, "+#.0;-#.0")
fs2(float v) => str.tostring(v, "+#.00;-#.00")
gc(float v) => math.abs(v) >= 1000 ? str.tostring(v, "#") : math.abs(v) >= 10 ? str.tostring(v, "#.#") : str.tostring(v, "#.##")
gcs(float v) => math.abs(v) >= 1000 ? str.tostring(v, "+#;-#") : math.abs(v) >= 10 ? str.tostring(v, "+#.#;-#.#") : str.tostring(v, "+#.##;-#.##")
vCol(color plotCol) => valColMode == "Custom" ? valColUser : plotCol
gA = "4 Momentum (MFI, VZO)"
shA = input.bool(true, "Show band", group=gA, display=display.none, tooltip="Shows or hides the whole momentum band without losing any of its settings.")
showMFI = input.bool(true, "Show MFI", group=gA, display=display.none, tooltip="Shows the money flow reading inside the momentum band.")
showVZO = input.bool(true, "Show VZO", group=gA, display=display.none, tooltip="Shows the volume zone oscillator inside the momentum band.")
lenMFIin = input.int(14, "MFI length (Custom only)", minval=2, group=gA, display=display.none, tooltip="Lookback for the money flow reading. Only used when the profile is set to custom.")
lenVZOin = input.int(14, "VZO length (Custom only)", minval=2, group=gA, display=display.none, tooltip="Lookback for the volume zone oscillator. Only used when the profile is set to custom.")
stAMFI = input.string("Area", "MFI style", options=["Line", "Area", "Columns"], group=gA, display=display.none, tooltip="How the money flow reading is drawn. Area fills the space between the value and the band midline, line draws only the trace, columns draw vertical bars from the midline.")
stAVZO = input.string("Line", "VZO style", options=["Line", "Area", "Columns"], group=gA, display=display.none, tooltip="How the volume zone oscillator is drawn.")
eAMFI = e1(stAMFI)
eAVZO = e2(stAVZO)
cAMFIu = input.color(#268c17, "MFI above 50 colour", group=gA, display=display.none, tooltip="Colour of the money flow reading when it is above the band midline.")
cAMFId = input.color(#9d0a0a, "MFI below 50 colour", group=gA, display=display.none, tooltip="Colour of the money flow reading when it is below the band midline.")
cAFill = input.int(0, "MFI fill transparency", minval=0, maxval=95, group=gA, display=display.none, tooltip="Transparency of the money flow fill. Zero is fully solid, higher numbers let the chart show through.")
cAVZOu = input.color(#1fff00, "VZO above 50 colour", group=gA, display=display.none, tooltip="Colour of the volume zone oscillator when it is above the band midline.")
cAVZOd = input.color(#ff0000, "VZO below 50 colour", group=gA, display=display.none, tooltip="Colour of the volume zone oscillator when it is below the band midline.")
lwA = input.int(1, "Line width (MFI / VZO)", minval=1, group=gA, display=display.none, tooltip="Line thickness for both oscillators in the momentum band.")
mfiOut = input.bool(false, "MFI outline line (Area style)", group=gA, display=display.none, tooltip="Adds a visible outline to the money flow fill. Off by default so the area reads as a clean shape.")
rsiBandA = input.bool(false, "Colour band by RSI zone", group=gA, display=display.none, tooltip="Replaces the two oscillator colours with the live zone colour, so the whole band changes colour together with the zone reading.")
refOnA = input.bool(false, "Show the Momentum 50 line", group=gA, display=display.none, tooltip="Draws the midline of the momentum band. Off by default, because each band is already read against its own midpoint.")
refColA = input.color(#ffffff, "Momentum 50 line colour", group=gA, display=display.none, tooltip="Colour of the momentum midline.")
refStyA = input.string("Dotted", "Momentum 50 line style", options=["Solid", "Dashed", "Dotted", "None"], group=gA, display=display.none, tooltip="Line style of the momentum midline. Solid, dashed, dotted or none.")
refWidA = input.int(1, "Momentum 50 line width", minval=1, maxval=4, group=gA, display=display.none, tooltip="Thickness of the momentum midline.")
lenMFI = profile == "Custom" ? lenMFIin : pMFI
lenVZO = profile == "Custom" ? lenVZOin : pVZO
mfiCalc(len) =>
tp = hl2
mf = tp * volume
pos = tp > tp[1] ? mf : 0.0
neg = tp < tp[1] ? mf : 0.0
sp = math.sum(pos, len)
sn = math.sum(neg, len)
sn == 0.0 ? 100.0 : sp == 0.0 ? 0.0 : 100.0 - 100.0 / (1.0 + sp / sn)
vzoCalc(len) =>
vp = volume * math.sign(close - close[1])
ev = ta.ema(vp, len)
ea = ta.ema(volume, len)
ea == 0.0 ? 0.0 : 100.0 * ev / ea
mfiV = mfiCalc(lenMFI)
vzoV = vzoCalc(lenVZO)
mfiY = A_BASE + math.max(0.0, math.min(100.0, mfiV))
vzoY = A_BASE + 50.0 + math.max(-100.0, math.min(100.0, vzoV)) / 2.0
mfiUp = mfiV >= 50.0
vzoUp = vzoV >= 0.0
colAMFI = rsiBandA ? zoneCol : mfiUp ? cAMFIu : cAMFId
colAMFIo = mfiOut or eAMFI == "Line" ? colAMFI : color.new(colAMFI, 100)
colAMFIc = eAMFI == "Columns" and eAVZO == "Columns" ? color.new(colAMFI, colT) : colAMFI
colAVZO = rsiBandA ? zoneCol : vzoUp ? cAVZOu : cAVZOd
gAon = showOsc and shA
pMidA = plot( liveOff ? na : (gAon ? A_BASE + 50.0 : na), "Momentum 50 anchor", color=color.new(refColA, 100), style=plot.style_line, linewidth=1, editable=false, display=display.pane)
pMfiL = plot( liveOff ? na : (gAon and showMFI and eAMFI != "Columns" ? mfiY : na), "MFI line", color=colAMFIo, style=plot.style_line, linewidth=lwA, editable=false, display=display.pane)
pMfiC = plot( liveOff ? na : (gAon and showMFI and eAMFI == "Columns" ? mfiY : na), "MFI columns", color=colAMFIc, style=plot.style_columns, histbase=A_BASE + 50.0, editable=false, display=display.pane)
fill(pMfiL, pMidA, color = gAon and showMFI and eAMFI == "Area" and mfiUp ? color.new(cAMFIu, cAFill) : na, title="MFI fill above")
fill(pMfiL, pMidA, color = gAon and showMFI and eAMFI == "Area" and not mfiUp ? color.new(cAMFId, cAFill) : na, title="MFI fill below")
pVzoL = plot( liveOff ? na : (gAon and showVZO and eAVZO != "Columns" ? vzoY : na), "VZO line", color=colAVZO, style=plot.style_line, linewidth=lwA, editable=false, display=display.pane)
pVzoC = plot( liveOff ? na : (gAon and showVZO and eAVZO == "Columns" ? vzoY : na), "VZO columns", color=colAVZO, style=plot.style_columns, histbase=A_BASE + 50.0, editable=false, display=display.pane)
fill(pVzoL, pMidA, color = gAon and showVZO and eAVZO == "Area" ? color.new(colAVZO, cAFill) : na, title="VZO fill")
gB = "5 Flow (CMF, OBV)"
shB = input.bool(true, "Show band", group=gB, display=display.none, tooltip="Shows or hides the whole flow band without losing any of its settings.")
showCMF = input.bool(true, "Show CMF", group=gB, display=display.none, tooltip="Shows the money flow pressure reading inside the flow band.")
showOBV = input.bool(true, "Show OBV", group=gB, display=display.none, tooltip="Shows the on balance volume reading inside the flow band.")
lenCMFin = input.int(20, "CMF length (Custom only)", minval=2, group=gB, display=display.none, tooltip="Lookback for the money flow pressure reading. Only used when the profile is set to custom.")
lenOBVin = input.int(100, "OBV normalisation window (Custom only)", minval=5, group=gB, display=display.none, tooltip="How many candles are used to scale on balance volume into the band. Only used when the profile is set to custom.")
stBCMF = input.string("Area", "CMF style", options=["Line", "Area", "Columns"], group=gB, display=display.none, tooltip="How the money flow pressure reading is drawn.")
stBOBV = input.string("Line", "OBV style", options=["Line", "Area", "Columns"], group=gB, display=display.none, tooltip="How the on balance volume reading is drawn.")
eBCMF = e1(stBCMF)
eBOBV = e2(stBOBV)
cBCMFu = input.color(#268c17, "CMF above 50 colour", group=gB, display=display.none, tooltip="Colour of the money flow pressure reading when it is above the band midline.")
cBCMFd = input.color(#9d0a0a, "CMF below 50 colour", group=gB, display=display.none, tooltip="Colour of the money flow pressure reading when it is below the band midline.")
cBOBVu = input.color(#1fff00, "OBV above 50 colour", group=gB, display=display.none, tooltip="Colour of the on balance volume reading when it is above the band midline.")
cBOBVd = input.color(#ff0000, "OBV below 50 colour", group=gB, display=display.none, tooltip="Colour of the on balance volume reading when it is below the band midline.")
cBFill = input.int(0, "CMF / OBV fill transparency", minval=0, maxval=95, group=gB, display=display.none, tooltip="Transparency of the flow band fills. Zero is fully solid.")
cmfOut = input.bool(false, "CMF outline line (Area style)", group=gB, display=display.none, tooltip="Adds a visible outline to the money flow pressure fill. Off by default.")
lwB = input.int(1, "Line width (CMF / OBV)", minval=1, group=gB, display=display.none, tooltip="Line thickness for both oscillators in the flow band.")
rsiBandB = input.bool(false, "Colour band by RSI zone", group=gB, display=display.none, tooltip="Replaces the two oscillator colours with the live zone colour.")
refOnB = input.bool(false, "Show the Flow 50 line", group=gB, display=display.none, tooltip="Draws the midline of the flow band. Off by default.")
refColB = input.color(#ffffff, "Flow 50 line colour", group=gB, display=display.none, tooltip="Colour of the flow midline.")
refStyB = input.string("Dotted", "Flow 50 line style", options=["Solid", "Dashed", "Dotted", "None"], group=gB, display=display.none, tooltip="Line style of the flow midline.")
refWidB = input.int(1, "Flow 50 line width", minval=1, maxval=4, group=gB, display=display.none, tooltip="Thickness of the flow midline.")
lenCMF = profile == "Custom" ? lenCMFin : pCMF
lenOBV = profile == "Custom" ? lenOBVin : pOBV
cmfCalc(len) =>
rng = high - low
mfv = rng == 0.0 ? 0.0 : ((close - low) - (high - close)) / rng * volume
vs = math.sum(volume, len)
vs == 0.0 ? 0.0 : 100.0 * math.sum(mfv, len) / vs
obvCalc(w) =>
o = ta.cum(math.sign(close - close[1]) * volume)
lo = ta.lowest(o, w)
hi = ta.highest(o, w)
hi - lo == 0.0 ? 50.0 : (o - lo) / (hi - lo) * 100.0
cmfV = cmfCalc(lenCMF)
obvV = obvCalc(lenOBV)
cmfY = B_BASE + 50.0 + math.max(-100.0, math.min(100.0, cmfV)) / 2.0
obvY = B_BASE + math.max(0.0, math.min(100.0, obvV))
cmfUp = cmfV >= 0.0
obvUp = obvV >= 50.0
colBCMF = rsiBandB ? zoneCol : cmfUp ? cBCMFu : cBCMFd
colBOBV = rsiBandB ? zoneCol : obvUp ? cBOBVu : cBOBVd
colBCMFo = cmfOut or eBCMF == "Line" ? colBCMF : color.new(colBCMF, 100)
colBCMFc = eBCMF == "Columns" and eBOBV == "Columns" ? color.new(colBCMF, colT) : colBCMF
gBon = showOsc and shB
pMidB = plot( liveOff ? na : (gBon ? B_BASE + 50.0 : na), "Flow 50 anchor", color=color.new(refColB, 100), style=plot.style_line, linewidth=1, editable=false, display=display.pane)
pCmfL = plot( liveOff ? na : (gBon and showCMF and eBCMF != "Columns" ? cmfY : na), "CMF line", color=colBCMFo, style=plot.style_line, linewidth=lwB, editable=false, display=display.pane)
pCmfC = plot( liveOff ? na : (gBon and showCMF and eBCMF == "Columns" ? cmfY : na), "CMF columns", color=colBCMFc, style=plot.style_columns, histbase=B_BASE + 50.0, editable=false, display=display.pane)
fill(pCmfL, pMidB, color = gBon and showCMF and eBCMF == "Area" ? color.new(colBCMF, cBFill) : na, title="CMF fill")
pObvL = plot( liveOff ? na : (gBon and showOBV and eBOBV != "Columns" ? obvY : na), "OBV line", color=colBOBV, style=plot.style_line, linewidth=lwB, editable=false, display=display.pane)
pObvC = plot( liveOff ? na : (gBon and showOBV and eBOBV == "Columns" ? obvY : na), "OBV columns", color=colBOBV, style=plot.style_columns, histbase=B_BASE + 50.0, editable=false, display=display.pane)
fill(pObvL, pMidB, color = gBon and showOBV and eBOBV == "Area" ? color.new(colBOBV, cBFill) : na, title="OBV fill")
gC = "6 Impulse (KVO, EOM)"
shC = input.bool(true, "Show band", group=gC, display=display.none, tooltip="Shows or hides the whole impulse band without losing any of its settings.")
showKVO = input.bool(true, "Show KVO", group=gC, display=display.none, tooltip="Shows the volume based impulse reading inside the impulse band.")
showEOM = input.bool(true, "Show EOM", group=gC, display=display.none, tooltip="Shows the ease of movement reading inside the impulse band.")
kFastIn = input.int(34, "KVO fast (Custom only)", minval=2, group=gC, display=display.none, tooltip="Fast average for the impulse reading. Only used when the profile is set to custom.")
kSlowIn = input.int(55, "KVO slow (Custom only)", minval=2, group=gC, display=display.none, tooltip="Slow average for the impulse reading. Only used when the profile is set to custom.")
kSigIn = input.int(13, "KVO signal (Custom only)", minval=2, group=gC, display=display.none, tooltip="Signal average for the impulse reading. Only used when the profile is set to custom.")
eomLenIn = input.int(14, "EOM length (Custom only)", minval=2, group=gC, display=display.none, tooltip="Lookback for the ease of movement reading. Only used when the profile is set to custom.")
eomZIn = input.int(50, "EOM z-score lookback (Custom only)", minval=5, group=gC, display=display.none, tooltip="Lookback used to standardise the ease of movement reading so it can share the band. Only used when the profile is set to custom.")
stCKVO = input.string("Line", "KVO style", options=["Line", "Area", "Columns"], group=gC, display=display.none, tooltip="How the impulse reading is drawn.")
stCEOM = input.string("Area", "EOM style", options=["Line", "Area", "Columns"], group=gC, display=display.none, tooltip="How the ease of movement reading is drawn.")
eCEOM = e1(stCEOM)
eCKVO = e2(stCKVO)
cCKVOu = input.color(#1fff00, "KVO above 50 colour", group=gC, display=display.none, tooltip="Colour of the impulse reading when it is above the band midline.")
cCKVOd = input.color(#ff0000, "KVO below 50 colour", group=gC, display=display.none, tooltip="Colour of the impulse reading when it is below the band midline.")
cCKVO2 = input.color(#800101, "KVO signal colour", group=gC, display=display.none, tooltip="Colour of the optional signal line that trails the impulse reading.")
cCEOMu = input.color(#268c17, "EOM above 50 colour", group=gC, display=display.none, tooltip="Colour of the ease of movement reading when it is above the band midline.")
cCEOMd = input.color(#9d0a0a, "EOM below 50 colour", group=gC, display=display.none, tooltip="Colour of the ease of movement reading when it is below the band midline.")
cCFill = input.int(0, "KVO / EOM fill transparency", minval=0, maxval=95, group=gC, display=display.none, tooltip="Transparency of the impulse band fills. Zero is fully solid.")
kvoOut = input.bool(false, "KVO outline line (Area style)", group=gC, display=display.none, tooltip="Adds a visible outline to the impulse reading fill. Off by default.")
eomOut = input.bool(false, "EOM outline line (Area style)", group=gC, display=display.none, tooltip="Adds a visible outline to the ease of movement fill. Off by default.")
showKSignal = input.bool(false, "Show KVO signal line", group=gC, display=display.none, tooltip="Draws the signal line that trails the impulse reading. Off by default because the reading alone is cleaner.")
lwC = input.int(1, "Line width (KVO / EOM)", minval=1, group=gC, display=display.none, tooltip="Line thickness for both oscillators in the impulse band.")
rsiBandC = input.bool(false, "Colour band by RSI zone", group=gC, display=display.none, tooltip="Replaces the two oscillator colours with the live zone colour.")
refOnC = input.bool(false, "Show the Impulse 50 line", group=gC, display=display.none, tooltip="Draws the midline of the impulse band. Off by default.")
refColC = input.color(#ffffff, "Impulse 50 line colour", group=gC, display=display.none, tooltip="Colour of the impulse midline.")
refStyC = input.string("Dotted", "Impulse 50 line style", options=["Solid", "Dashed", "Dotted", "None"], group=gC, display=display.none, tooltip="Line style of the impulse midline.")
refWidC = input.int(1, "Impulse 50 line width", minval=1, maxval=4, group=gC, display=display.none, tooltip="Thickness of the impulse midline.")
kFast = profile == "Custom" ? kFastIn : pKFa
kSlow = profile == "Custom" ? kSlowIn : pKSl
kSig = profile == "Custom" ? kSigIn : pKSg
eomLen = profile == "Custom" ? eomLenIn : pEOm
eomZ = profile == "Custom" ? eomZIn : pEOz
kDm = high - low
kTrend = hl2 > hl2[1] ? 1.0 : -1.0
var float kCm = 0.0
kCm := kTrend == kTrend[1] ? kCm + kDm : nz(kDm[1]) + kDm
kCms = kCm == 0.0 ? 1.0 : kCm
kVf = volume * math.abs(2.0 * (kDm / kCms - 1.0)) * kTrend * 100.0
kvoV = ta.ema(kVf, kFast) - ta.ema(kVf, kSlow)
kvoSig = ta.ema(kvoV, kSig)
eDm = hl2 - hl2[1]
eBox = high - low
eBr = eBox == 0.0 ? 1.0 : (volume / 1000000.0) / eBox
eRaw = eBr == 0.0 ? 0.0 : eDm / eBr
eSm = ta.sma(eRaw, eomLen)
eMu = ta.sma(eSm, eomZ)
eSd = ta.stdev(eSm, eomZ)
eomV = eSd == 0.0 ? 0.0 : (eSm - eMu) / eSd
kAbs = ta.highest(math.abs(kvoV), 100)
kAbsS = kAbs == 0.0 ? 1.0 : kAbs
kvoY = C_BASE + 50.0 + math.max(-1.0, math.min(1.0, kvoV / kAbsS)) * 45.0
kSigY = C_BASE + 50.0 + math.max(-1.0, math.min(1.0, kvoSig / kAbsS)) * 45.0
eomY = C_BASE + 50.0 + math.max(-3.0, math.min(3.0, eomV)) / 3.0 * 45.0
kvoUp = kvoV >= 0.0
eomUp = eomV >= 0.0
colCKVO = rsiBandC ? zoneCol : kvoUp ? cCKVOu : cCKVOd
colCEOM = rsiBandC ? zoneCol : eomUp ? cCEOMu : cCEOMd
colCKVOo = kvoOut or eCKVO == "Line" ? colCKVO : color.new(colCKVO, 100)
colCEOMo = eomOut or eCEOM == "Line" ? colCEOM : color.new(colCEOM, 100)
colCEOMc = eCEOM == "Columns" and eCKVO == "Columns" ? color.new(colCEOM, colT) : colCEOM
gCon = showOsc and shC
pMidC = plot( liveOff ? na : (gCon ? C_BASE + 50.0 : na), "Impulse 50 anchor", color=color.new(refColC, 100), style=plot.style_line, linewidth=1, editable=false, display=display.pane)
pKvoL = plot( liveOff ? na : (gCon and showKVO and eCKVO != "Columns" ? kvoY : na), "KVO line", color=colCKVOo, style=plot.style_line, linewidth=lwC, editable=false, display=display.pane)
pKvoC = plot( liveOff ? na : (gCon and showKVO and eCKVO == "Columns" ? kvoY : na), "KVO columns", color=colCKVO, style=plot.style_columns, histbase=C_BASE + 50.0, editable=false, display=display.pane)
fill(pKvoL, pMidC, color = gCon and showKVO and eCKVO == "Area" ? color.new(colCKVO, cCFill) : na, title="KVO fill")
plot( liveOff ? na : (gCon and showKVO and showKSignal ? kSigY : na), "KVO signal", color=cCKVO2, style=plot.style_line, linewidth=1, editable=false, display=display.pane)
pEomL = plot( liveOff ? na : (gCon and showEOM and eCEOM != "Columns" ? eomY : na), "EOM line", color=colCEOMo, style=plot.style_line, linewidth=lwC, editable=false, display=display.pane)
pEomC = plot( liveOff ? na : (gCon and showEOM and eCEOM == "Columns" ? eomY : na), "EOM columns", color=colCEOMc, style=plot.style_columns, histbase=C_BASE + 50.0, editable=false, display=display.pane)
fill(pEomL, pMidC, color = gCon and showEOM and eCEOM == "Area" ? color.new(colCEOM, cCFill) : na, title="EOM fill")
gD = "7 Context (RVOL)"
showRVOL = input.bool(true, "Show RVOL", group=gD, display=display.none, tooltip="Shows relative volume in the context band.")
rvolIn = input.int(20, "RVOL length (Custom only)", minval=2, group=gD, display=display.none, tooltip="Lookback used as the average volume baseline. Only used when the profile is set to custom.")
stDRV = input.string("Columns", "RVOL style", options=["Line", "Area", "Columns"], group=gD, display=display.none, tooltip="How relative volume is drawn.")
cDRV = input.color(#b8b8b8, "RVOL colour", group=gD, display=display.none, tooltip="Colour of relative volume in normal conditions. Light grey so that coloured spikes stand out clearly against it.")
rvolHi = input.float(2.0, "High-relative-volume threshold", minval=0.5, step=0.1, group=gD, display=display.none, tooltip="How many times the average volume counts as a spike. Two means twice the average.")
rvZone = input.bool(true, "Colour spikes by RSI zone", group=gD, display=display.none, tooltip="Takes the spike colour from the zone reading at the moment of the spike, so the colour tells you which zone the spike happened in. Turn this off to use one fixed spike colour instead.")
cDHi = input.color(#cb0000, "RVOL spike colour (zone colour off)", group=gD, display=display.none, tooltip="Fixed colour used for spikes when the zone colouring is switched off.")
refOnD = input.bool(true, "Show the RVOL 1.0x line", group=gD, display=display.none, tooltip="Draws the average volume level inside the context band, so a column can be judged against it directly. On by default.")
refColD = input.color(#000000, "RVOL 1.0x line colour", group=gD, display=display.none, tooltip="Colour of the average volume line.")
refStyD = input.string("Dotted", "RVOL 1.0x line style", options=["Solid", "Dashed", "Dotted", "None"], group=gD, display=display.none, tooltip="Line style of the average volume line.")
refWidD = input.int(1, "RVOL 1.0x line width", minval=1, maxval=4, group=gD, display=display.none, tooltip="Thickness of the average volume line.")
lenRV = profile == "Custom" ? rvolIn : pRVO
rvolCalc(len) =>
av = ta.sma(volume, len)
av == 0.0 ? 0.0 : volume / av
rvolV = rvolCalc(lenRV)
rvolY = D_BASE + math.min(1.0, rvolV / 3.0) * D_HGT
colRV = rvolV >= rvolHi ? (rvZone ? zoneCol : cDHi) : cDRV
gDon = showOsc and showRVOL
pMidD = plot( liveOff ? na : (gDon ? D_BASE + D_HGT / 3.0 : na), "RVOL 1.0x anchor", color=color.new(refColD, 100), style=plot.style_line, linewidth=1, editable=false, display=display.pane)
pRvolL = plot( liveOff ? na : (gDon and showRVOL and stDRV != "Columns" ? rvolY : na), "RVOL line", color=colRV, style=plot.style_line, linewidth=2, editable=false, display=display.pane)
pRvolC = plot( liveOff ? na : (gDon and showRVOL and stDRV == "Columns" ? rvolY : na), "RVOL columns", color=colRV, style=plot.style_columns, histbase=D_BASE, editable=false, display=display.pane)
fill(pRvolL, pMidD, color = gDon and showRVOL and stDRV == "Area" ? color.new(colRV, 72) : na, title="RVOL fill")
plot( liveOff ? na : (showVol ? volTotY : na), "Volume total (sellers)",
color=color.new(zoneCol, isSplit ? sellTrans : 0),
style=plot.style_columns, histbase=V_BASE, linewidth=2, editable=false, display=display.pane)
plot( liveOff ? na : (showVol and isSplit ? volBuyY : na), "Volume bought",
color=zoneCol, style=plot.style_columns, histbase=V_BASE, linewidth=2, editable=false, display=display.pane)
plot( liveOff or not showVol or not isSplit or not showDiv ? na : volBuyY, "Buy / sell boundary",
color=divCol, style=plot.style_line, linewidth=divW, editable=false, display=display.pane)
plotshape( liveOff or not showVol or not showBul or bulShape != "Circle" or not domBuy ? na : bulY,
"CircleBuy", style=shape.circle, location=location.absolute, color=zoneCol, size=size.tiny, editable=false, display=display.pane)
plotshape( liveOff or not showVol or not showBul or bulShape != "Circle" or not domSell ? na : bulY,
"CircleSell", style=shape.circle, location=location.absolute, color=color.new(zoneCol, sellTrans), size=size.tiny, editable=false, display=display.pane)
plotshape( liveOff or not showVol or not showBul or bulShape != "Square" or not domBuy ? na : bulY,
"SquareBuy", style=shape.square, location=location.absolute, color=zoneCol, size=size.tiny, editable=false, display=display.pane)
plotshape( liveOff or not showVol or not showBul or bulShape != "Square" or not domSell ? na : bulY,
"SquareSell", style=shape.square, location=location.absolute, color=color.new(zoneCol, sellTrans), size=size.tiny, editable=false, display=display.pane)
plotshape( liveOff or not showVol or not showBul or bulShape != "Triangle up" or not domBuy ? na : bulY,
"TriangleupBuy", style=shape.triangleup, location=location.absolute, color=zoneCol, size=size.tiny, editable=false, display=display.pane)
plotshape( liveOff or not showVol or not showBul or bulShape != "Triangle up" or not domSell ? na : bulY,
"TriangleupSell", style=shape.triangleup, location=location.absolute, color=color.new(zoneCol, sellTrans), size=size.tiny, editable=false, display=display.pane)
valMFI = liveOff ? nz(mfiV[1], mfiV) : mfiV
valVZO = liveOff ? nz(vzoV[1], vzoV) : vzoV
valCMF = liveOff ? nz(cmfV[1], cmfV) : cmfV
valOBV = liveOff ? nz(obvV[1], obvV) : obvV
valKVO = liveOff ? nz(kvoV[1], kvoV) : kvoV
valEOM = liveOff ? nz(eomV[1], eomV) : eomV
valRVO = liveOff ? nz(rvolV[1], rvolV) : rvolV
valRSI = liveOff ? nz(zoneRsi[1], zoneRsi) : zoneRsi
sepOn = showSep and sepStyle != "None"
sepLs = sepStyle == "Dashed" ? line.style_dashed : sepStyle == "Dotted" ? line.style_dotted : line.style_solid
var line rfA = na
var line rfB = na
var line rfC = na
var line rfD = na
rfLs(string t) => t == "Dashed" ? line.style_dashed : t == "Dotted" ? line.style_dotted : line.style_solid
if barstate.islast
line.delete(rfA)
line.delete(rfB)
line.delete(rfC)
line.delete(rfD)
rx1 = chart.left_visible_bar_time
rx2 = time
if showMid and refOnA and refStyA != "None"
rfA := line.new(rx1, A_BASE + 50.0, rx2, A_BASE + 50.0, xloc=xloc.bar_time, extend=extend.none, color=refColA, style=rfLs(refStyA), width=refWidA)
if showMid and refOnB and refStyB != "None"
rfB := line.new(rx1, B_BASE + 50.0, rx2, B_BASE + 50.0, xloc=xloc.bar_time, extend=extend.none, color=refColB, style=rfLs(refStyB), width=refWidB)
if showMid and refOnC and refStyC != "None"
rfC := line.new(rx1, C_BASE + 50.0, rx2, C_BASE + 50.0, xloc=xloc.bar_time, extend=extend.none, color=refColC, style=rfLs(refStyC), width=refWidC)
if showMid and refOnD and refStyD != "None"
rfD := line.new(rx1, D_BASE + D_HGT / 3.0, rx2, D_BASE + D_HGT / 3.0, xloc=xloc.bar_time, extend=extend.none, color=refColD, style=rfLs(refStyD), width=refWidD)
var line sp1 = na
var line sp2 = na
var line sp3 = na
var line sp4 = na
var line sp5 = na
if barstate.islast
line.delete(sp1)
line.delete(sp2)
line.delete(sp3)
line.delete(sp4)
line.delete(sp5)
if sepOn
sx1 = chart.left_visible_bar_time
sx2 = time
sp1 := line.new(sx1, 40.0, sx2, 40.0, xloc=xloc.bar_time, extend=extend.none, color=sepCol, style=sepLs, width=sepW)
sp2 := line.new(sx1, 140.0, sx2, 140.0, xloc=xloc.bar_time, extend=extend.none, color=sepCol, style=sepLs, width=sepW)
sp3 := line.new(sx1, 240.0, sx2, 240.0, xloc=xloc.bar_time, extend=extend.none, color=sepCol, style=sepLs, width=sepW)
sp4 := line.new(sx1, 340.0, sx2, 340.0, xloc=xloc.bar_time, extend=extend.none, color=sepCol, style=sepLs, width=sepW)
sp5 := line.new(sx1, 440.0, sx2, 440.0, xloc=xloc.bar_time, extend=extend.none, color=sepCol, style=sepLs, width=sepW)
var array<label> ax = array.new<label>()
var array<box> bx = array.new<box>()
gRowH = (V_BASE + 100.0 - D_BASE) / 8.0
gTop(int i) => V_BASE + 100.0 - (i - 1) * gRowH
gBot(int i) => V_BASE + 100.0 - i * gRowH
if barstate.islast
if array.size(ax) > 0
for i = 0 to array.size(ax) - 1
label.delete(array.get(ax, i))
array.clear(ax)
if array.size(bx) > 0
for i = 0 to array.size(bx) - 1
box.delete(array.get(bx, i))
array.clear(bx)
tfMs = timeframe.in_seconds() * 1000
vX = time + tfMs * valOff
visBars = math.max(1.0, (chart.right_visible_bar_time - chart.left_visible_bar_time) / tfMs)
gWf = math.max(0.25, visBars * gPct / 100.0)
gSlots = 1.0
gWf := math.max(gWf, gMinWb)
availB = math.max(0.1, (chart.right_visible_bar_time - vX) / tfMs - 0.5 - math.max(0.0, gOff))
gWf := gForce ? gWf : math.min(gWf, availB)
gxR = int(vX + tfMs * (gWf + math.max(0.0, gOff)))
axX = axisPin == "Glued to the right edge" ? math.max(chart.right_visible_bar_time, gxR + tfMs * 2) : time + tfMs * (valOff + axisOff)
if showGauge
gSz = gTxt == "Tiny" ? size.tiny : gTxt == "Normal" ? size.normal : size.small
wM = tfMs * gWf
cL0 = int(vX)
cL = int(cL0 + tfMs * gOff)
cR = int(cL + wM)
giRSI = 1
giM = gSwap ? 3 : 2
giV = gSwap ? 2 : 3
giC = gSwap ? 5 : 4
giO = gSwap ? 4 : 5
giK = gSwap ? 6 : 7
giE = gSwap ? 7 : 6
giR = 8
if showVol
array.push(bx, box.new(cL, gTop(giRSI), cR, gBot(giRSI), xloc=xloc.bar_time, border_color=gBord, border_width=gBw, bgcolor=zoneCol))
if showOsc and shA and showMFI
array.push(bx, box.new(cL, gTop(giM), cR, gBot(giM), xloc=xloc.bar_time, border_color=gBord, border_width=gBw, bgcolor=colAMFI))
if showOsc and shA and showVZO
array.push(bx, box.new(cL, gTop(giV), cR, gBot(giV), xloc=xloc.bar_time, border_color=gBord, border_width=gBw, bgcolor=colAVZO))
if showOsc and shB and showCMF
array.push(bx, box.new(cL, gTop(giC), cR, gBot(giC), xloc=xloc.bar_time, border_color=gBord, border_width=gBw, bgcolor=colBCMF))
if showOsc and shB and showOBV
array.push(bx, box.new(cL, gTop(giO), cR, gBot(giO), xloc=xloc.bar_time, border_color=gBord, border_width=gBw, bgcolor=colBOBV))
if showOsc and shC and showKVO
array.push(bx, box.new(cL, gTop(giK), cR, gBot(giK), xloc=xloc.bar_time, border_color=gBord, border_width=gBw, bgcolor=colCKVO))
if showOsc and shC and showEOM
array.push(bx, box.new(cL, gTop(giE), cR, gBot(giE), xloc=xloc.bar_time, border_color=gBord, border_width=gBw, bgcolor=colCEOM))
if showOsc and showRVOL
array.push(bx, box.new(cL, gTop(giR), cR, gBot(giR), xloc=xloc.bar_time, border_color=gBord, border_width=gBw, bgcolor=colRV))
if showAxis
if showOsc and shA
array.push(ax, label.new(axX, A_BASE + obLvl, str.tostring(obLvl), xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=axNumCol, size=size.tiny))
array.push(ax, label.new(axX, A_BASE + 50.0, "50", xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=axNumCol, size=size.tiny))
array.push(ax, label.new(axX, A_BASE + osLvl, str.tostring(osLvl), xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=axNumCol, size=size.tiny))
if showOsc and shB
array.push(ax, label.new(axX, B_BASE + 70.0, "70", xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=axNumCol, size=size.tiny))
array.push(ax, label.new(axX, B_BASE + 50.0, "50", xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=axNumCol, size=size.tiny))
array.push(ax, label.new(axX, B_BASE + 30.0, "30", xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=axNumCol, size=size.tiny))
if showOsc and shC
array.push(ax, label.new(axX, C_BASE + 70.0, "70", xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=axNumCol, size=size.tiny))
array.push(ax, label.new(axX, C_BASE + 50.0, "50", xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=axNumCol, size=size.tiny))
array.push(ax, label.new(axX, C_BASE + 30.0, "30", xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=axNumCol, size=size.tiny))
if showOsc and showRVOL
array.push(ax, label.new(axX, D_BASE + D_HGT, "3x", xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=axNumCol, size=size.tiny))
if showVals
vsz = valSize == "Tiny" ? size.tiny : valSize == "Small" ? size.small : valSize == "Normal" ? size.normal : size.large
if showOsc and shA and showMFI
array.push(ax, label.new(vX, A_BASE + 92.0, "MFI " + f1(valMFI), xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=vCol(colAMFI), size=vsz))
if showOsc and shA and showVZO
array.push(ax, label.new(vX, A_BASE + 82.0, "VZO " + fs1(valVZO), xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=vCol(colAVZO), size=vsz))
if showOsc and shB and showCMF
array.push(ax, label.new(vX, B_BASE + 92.0, "CMF " + fs1(valCMF), xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=vCol(colBCMF), size=vsz))
if showOsc and shB and showOBV
array.push(ax, label.new(vX, B_BASE + 82.0, "OBV " + f1(valOBV) + "n", xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=vCol(colBOBV), size=vsz))
if showOsc and shC and showKVO
array.push(ax, label.new(vX, C_BASE + 92.0, "KVO " + f1(valKVO), xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=vCol(colCKVO), size=vsz))
if showOsc and shC and showEOM
array.push(ax, label.new(vX, C_BASE + 82.0, "EOM " + fs2(valEOM), xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=vCol(colCEOM), size=vsz))
if showOsc and showRVOL
array.push(ax, label.new(vX, D_BASE + D_HGT * 0.75, "RVOL " + f2(valRVO) + "x", xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=vCol(colRV), size=vsz))
array.push(ax, label.new(vX, V_BASE + 92.0, "RSI " + f1(valRSI), xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none, textcolor=vCol(zoneCol), size=vsz))
fire = not liveOff
zBull = zoneRsi > obLvl
zBear = zoneRsi < osLvl
zMid = zoneRsi > 50.0
momUp = mfiV > 50.0
flowUp = cmfV > 0.0
impUp = kvoV > 0.0
alignBull = momUp and flowUp and impUp
alignBear = not momUp and not flowUp and not impUp
if fire
if showVol and domBuy
alert("Buy dominance on " + syminfo.ticker + " " + timeframe.period, alert.freq_once_per_bar_close)
if showVol and domSell
alert("Sell dominance on " + syminfo.ticker + " " + timeframe.period, alert.freq_once_per_bar_close)
if zBull and not zBull[1]
alert("Zone entered the strong zone on " + syminfo.ticker + " " + timeframe.period, alert.freq_once_per_bar_close)
if zBear and not zBear[1]
alert("Zone entered the weak zone on " + syminfo.ticker + " " + timeframe.period, alert.freq_once_per_bar_close)
if zMid and not zMid[1]
alert("Zone crossed above the middle on " + syminfo.ticker + " " + timeframe.period, alert.freq_once_per_bar_close)
if not zMid and zMid[1]
alert("Zone crossed below the middle on " + syminfo.ticker + " " + timeframe.period, alert.freq_once_per_bar_close)
if momUp and not momUp[1]
alert("Momentum band turned positive on " + syminfo.ticker + " " + timeframe.period, alert.freq_once_per_bar_close)
if not momUp and momUp[1]
alert("Momentum band turned negative on " + syminfo.ticker + " " + timeframe.period, alert.freq_once_per_bar_close)
if flowUp and not flowUp[1]
alert("Flow band turned positive on " + syminfo.ticker + " " + timeframe.period, alert.freq_once_per_bar_close)
if not flowUp and flowUp[1]
alert("Flow band turned negative on " + syminfo.ticker + " " + timeframe.period, alert.freq_once_per_bar_close)
if impUp and not impUp[1]
alert("Impulse band turned positive on " + syminfo.ticker + " " + timeframe.period, alert.freq_once_per_bar_close)
if not impUp and impUp[1]
alert("Impulse band turned negative on " + syminfo.ticker + " " + timeframe.period, alert.freq_once_per_bar_close)
if showOsc and showRVOL and rvolV > rvolHi and rvolV[1] <= rvolHi
alert("Volume spike on " + syminfo.ticker + " " + timeframe.period, alert.freq_once_per_bar_close)
if alignBull and not alignBull[1]
alert("All bands aligned bullish on " + syminfo.ticker + " " + timeframe.period, alert.freq_once_per_bar_close)
if alignBear and not alignBear[1]
alert("All bands aligned bearish on " + syminfo.ticker + " " + timeframe.period, alert.freq_once_per_bar_close)