Your post above did not make any specific requests. If you have code, or an indicator somewhere else you've seen, please provide code and or links -- preferably both. I don't have the first clue how the indicator you took a screen shot of was created, or even which platform the screen grab is from. Your admonition that it is simply closing prices without wicks doesn't make a great deal of sense when trying to convert the idea to code.Thanks. I looked at this but this is completely different. it's not your typical indicator but rather a heatmap of volume and is not part of a chart.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Vulnerable_human_x
//@version=5
indicator("ICT - GAPS, BPR, Volume & Price Imbalance", shorttitle = "ICT - Imbalances", overlay=true)
//Volume Imbalance
showbullvi = input.bool(true, "Show Bullish Volume Imbalance", group="Volume Imbalance")
showbearvi = input.bool(true, "Show Bearish Volume Imbalance", group="Volume Imbalance")
bullimbalance = input.color(color.new(#00e640,10), "Bullish VI Color", group="Volume Imbalance", inline="1")
bearimbalance = input.color(color.new(#e30000,10), "Bearish VI Color", group="Volume Imbalance", inline="1")
viMaxBoxSet = input.int(defval=15, title='Maximum Box Displayed', minval=1, maxval=100, group="Volume Imbalance", tooltip='Minimum = 1, Maximum = 100')
extendvibox = input.bool(false, title="Extend Unmitigated VI Boxes", group="Volume Imbalance")
//Gaps
showgaps = input.bool(true, "Show Gaps in Price", group="GAP")
gapcolor = input.color(color.new(#fff176, 85), "GAP Color", group="GAP")
gapsMaxBoxSet = input.int(defval=15, title='Maximum Box Displayed', minval=1, maxval=100, group="GAP", tooltip='Minimum = 1, Maximum = 100')
extendgapbox = input.bool(true, title="Extend Unmitigated GAP Boxes", group="GAP")
//FVG and BPR
plotFVG = input.bool(true, "FVG BOX", inline="18", group="FVG/BPR")
plotBPR = input.bool(true, "BPR BOX", inline="18", group="FVG/BPR")
fvgBullColor = input.color(defval=color.new(color.green, 85), title='Bullish FVG',inline="1", group="FVG/BPR")
fvgBearColor = input.color(defval=color.new(color.red, 85), title='Bearish FVG',inline="1", group="FVG/BPR")
bprBullColor = input.color(defval=color.new(#41ed47, 70), title='Bullish BPR',inline="2", group="FVG/BPR")
bprBearColor = input.color(defval=color.new(#d83d3d, 70), title='Bearish BPR',inline="2", group="FVG/BPR")
var float bprprecision = input.float(0.00005,"BPR Precision",step=0.00001, group="FVG/BPR")
fvgMaxBoxSet = input.int(defval=10, title='Maximum Box Displayed', minval=1, maxval=100, group="FVG/BPR", tooltip='Minimum = 1, Maximum = 100')
extendfvgbox = input.bool(true, title="Extend Unmitigated FVG/BPR Boxes", group="FVG/BPR")
//Box Styling
BoxBorder = input.string(defval=line.style_solid, title='Box Border Style', options=[line.style_dashed, line.style_dotted, line.style_solid], group="Box Style", tooltip='To disable border, set Border Width below to 0')
BorderTransparency = input.int(defval=60, title='Border Box Transparency', minval=0, maxval=100, group="Box Style")
filterMitBOX = input.bool(defval=false, title='Mitigated Box Color', group="Box Style")
mitBOXColor = input.color(defval=color.new(color.gray, 80), title='Mitigated Box Color', group="Box Style", tooltip='Set Transparency to 0 to make mitigated Boxes disappear')
plotBoxLabel = input.bool(defval=true, title='Plot Label', group="Box Style")
BoxLabelColor = input.color(defval=color.rgb(161, 163, 171), title='Label Color', group="Box Style")
BoxLabelSize = input.string(defval=size.tiny, title="Label Size", options=[size.huge, size.large, size.small, size.tiny, size.auto, size.normal], group="Box Style")
var int _fvg = 2
//Box Labels
var string _fvgLabel = "FVG"
var string _plus = "+"
var string _minus = "-"
var string _empty = ""
var string _bprLabel = "BPR"
var box[] _bearBoxesFVG = array.new_box()
var box[] _bullBoxesFVG = array.new_box()
var box[] _gapsboxes = array.new_box()
var box[] _bullishvi = array.new_box()
var box[] _bearishvi = array.new_box()
_controlBox(_boxes, _high, _low, _type) =>
if array.size(_boxes) > 0
for i = array.size(_boxes) - 1 to 0 by 1
_box = array.get(_boxes, i)
_boxLow = box.get_bottom(_box)
_boxHigh = box.get_top(_box)
_boxRight = box.get_right(_box)
if (filterMitBOX and _type == _fvg)
if na or (bar_index == _boxRight and not((_high > _boxLow and _low < _boxLow) or (_high > _boxHigh and _low < _boxHigh)))
box.set_right(_box, bar_index + 1)
else
if _type == _fvg
box.set_bgcolor(_box, mitBOXColor)
box.set_border_color(_box, mitBOXColor)
else
if na or (bar_index == _boxRight and not((_high > _boxLow and _low < _boxLow) or (_high > _boxHigh and _low < _boxHigh)))
box.set_right(_box, bar_index + 1)
//Volume Imbalance
//Bullish Volume Imbalance
if showbullvi and open > close[1] and low <= high[1] and close > close[1] and open > open[1]
box _bullboxVI = na
_bullboxVI := box.new(left=bar_index-1, top=math.min(open,close), right=bar_index+1, bottom=math.max(close[1],open[1]), bgcolor=bullimbalance,border_style=BoxBorder, border_color=color.new(bullimbalance,BorderTransparency), text=plotBoxLabel?"VI+":na, text_halign=text.align_right, text_valign=text.align_bottom, text_size=BoxLabelSize, text_color=BoxLabelColor)
if array.size(_bullishvi) > viMaxBoxSet
box.delete(array.shift(_bullishvi))
array.push(_bullishvi, _bullboxVI)
//Bearish Volume Imbalance
if showbearvi and open < close[1] and open < open[1] and high >= low[1] and close < close[1] and close < open[1]
box _bearboxVI = na
_bearboxVI := box.new(left=bar_index-1, top=math.min(close[1],open[1]), right=bar_index+1, bottom=math.max(open,close), bgcolor=bearimbalance,border_style=BoxBorder, border_color=color.new(bearimbalance,BorderTransparency),text=plotBoxLabel?"VI-":na, text_halign=text.align_right, text_valign=text.align_bottom, text_size=BoxLabelSize, text_color=BoxLabelColor)
if array.size(_bearishvi) > viMaxBoxSet
box.delete(array.shift(_bearishvi))
array.push(_bearishvi, _bearboxVI)
//Gap
if (showgaps and high[1] < low) or (showgaps and low[1] > high)
box _gaps = na
if high[1] < low
_gaps := box.new(left=bar_index-1, top=low, right=bar_index, bottom=high[1], bgcolor=gapcolor, border_color=color.new(gapcolor,BorderTransparency), text=plotBoxLabel?"GAP+":na,border_style=BoxBorder, text_halign=text.align_right, text_valign=text.align_bottom, text_size=BoxLabelSize, text_color=BoxLabelColor)
else if low[1] > high
_gaps := box.new(left=bar_index-1, top=low[1], right=bar_index, bottom=high, bgcolor=gapcolor, border_color=color.new(gapcolor,BorderTransparency), text=plotBoxLabel?"GAP-":na,border_style=BoxBorder, text_halign=text.align_right, text_valign=text.align_bottom, text_size=BoxLabelSize, text_color=BoxLabelColor)
if array.size(_gapsboxes) > gapsMaxBoxSet
box.delete(array.shift(_gapsboxes))
array.push(_gapsboxes, _gaps)
//fvg
isFvgUp(index) =>
(low[index] > high[index + 2] and low[index + 1] <= high[index + 2] and high[index + 1] >= low[index])
isFvgDown(index) =>
(high[index] < low[index + 2] and high[index] >= low[index + 1] and high[index +1] >= low[index +2])
//Balanced Price Range
isbprdown (index) =>
low [index + 3] > high[index] and low[index + 3] < low[index + 2] and low[index + 3] < close[index + 3] and high[index + 2] >= close[index + 2] and high[index + 1] <= ((open [index + 1]) + (open[index + 1] * bprprecision)) and (low[index + 2] >= ((open[index + 2]) - (open[index + 2] * bprprecision)) or (low[index + 2] >= ((close[index + 2]) - (close[index + 2] * bprprecision))))
isbprup (index) =>
high [index + 3] < low[index] and high[index + 3] > high[index + 2] and high[index + 3] > close[index + 3] and low[index + 2] <= close[index + 2] and low[index + 1] >= ((open [index + 1]) - (open[index + 1] * bprprecision)) and (high[index + 2] <= ((open[index + 2]) + (open[index + 2] * bprprecision)) or (high[index + 2] <= ((close[index + 2]) + (close[index + 2] * bprprecision))))
//Bullish FVG Box Plotting
if isbprup(0) and isFvgUp(0)
box _bullboxFVG = na
if plotBPR
_bullboxFVG := box.new(left=bar_index-3, top=low[0], right=bar_index, bottom=high[3], bgcolor=bprBullColor, border_color=color.new(bprBullColor,BorderTransparency), border_style=BoxBorder, border_width=1,
text=plotBoxLabel ? _bprLabel + _plus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=BoxLabelSize, text_color=BoxLabelColor)
else if plotFVG
_bullboxFVG := box.new(left=bar_index-2, top=low[0], right=bar_index, bottom=high[2], bgcolor=fvgBullColor, border_color=color.new(fvgBullColor,BorderTransparency), border_style=BoxBorder, border_width=1,
text=plotBoxLabel ? _fvgLabel + _plus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=BoxLabelSize, text_color=BoxLabelColor)
if array.size(_bullBoxesFVG) > fvgMaxBoxSet
box.delete(array.shift(_bullBoxesFVG))
array.push(_bullBoxesFVG, _bullboxFVG)
else if isFvgUp(0)
box _bullboxFVG = na
if plotFVG
_bullboxFVG := box.new(left=bar_index-2, top=low[0], right=bar_index, bottom=high[2], bgcolor=fvgBullColor, border_color=color.new(fvgBullColor,BorderTransparency), border_style=BoxBorder, border_width=1,
text=plotBoxLabel ? _fvgLabel + _plus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=BoxLabelSize, text_color=BoxLabelColor)
if array.size(_bullBoxesFVG) > fvgMaxBoxSet
box.delete(array.shift(_bullBoxesFVG))
array.push(_bullBoxesFVG, _bullboxFVG)
//Bearish FVG Box Plotting
if isbprdown(0) and isFvgDown(0)
box _bearboxFVG = na
if plotBPR
_bearboxFVG := box.new(left=bar_index-3, top=low[3], right=bar_index, bottom=high[0], bgcolor=bprBearColor, border_color=color.new(bprBearColor,BorderTransparency), border_style=BoxBorder, border_width=1,
text=plotBoxLabel ? _bprLabel + _minus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=BoxLabelSize, text_color=BoxLabelColor)
else if plotFVG
_bearboxFVG := box.new(left=bar_index-2, top=low[2], right=bar_index, bottom=high[0], bgcolor=fvgBearColor, border_color=color.new(fvgBearColor,BorderTransparency), border_style=BoxBorder, border_width=1,
text=plotBoxLabel ? _fvgLabel + _minus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=BoxLabelSize, text_color=BoxLabelColor)
if array.size(_bearBoxesFVG) > fvgMaxBoxSet
box.delete(array.shift(_bearBoxesFVG))
array.push(_bearBoxesFVG, _bearboxFVG)
else if isFvgDown(0)
box _bearboxFVG = na
if plotFVG
_bearboxFVG := box.new(left=bar_index-2, top=low[2], right=bar_index, bottom=high[0], bgcolor=fvgBearColor, border_color=color.new(fvgBearColor,BorderTransparency), border_style=BoxBorder, border_width=1,
text=plotBoxLabel ? _fvgLabel + _minus : _empty, text_halign=text.align_right, text_valign=text.align_bottom, text_size=BoxLabelSize, text_color=BoxLabelColor)
if array.size(_bearBoxesFVG) > fvgMaxBoxSet
box.delete(array.shift(_bearBoxesFVG))
array.push(_bearBoxesFVG, _bearboxFVG)
if extendfvgbox
_controlBox(_bearBoxesFVG, high, low, _fvg)
_controlBox(_bullBoxesFVG, high, low, _fvg)
if extendgapbox
_controlBox(_gapsboxes, high, low, _fvg)
if extendvibox
_controlBox(_bullishvi, high, low, _fvg)
_controlBox(_bearishvi, high, low, _fvg)
//end of script
//Volume Imbalance
//Bullish Volume Imbalance
if showbullvi and open > close[1] and low <= high[1] and close > close[1] and open > open[1]
box _bullboxVI = na
_bullboxVI := box.new(left=bar_index-1, top=math.min(open,close), right=bar_index+1, bottom=math.max(close[1],open[1]), bgcolor=bullimbalance,border_style=BoxBorder, border_color=color.new(bullimbalance,BorderTransparency), text=plotBoxLabel?"VI+":na, text_halign=text.align_right, text_valign=text.align_bottom, text_size=BoxLabelSize, text_color=BoxLabelColor)
if array.size(_bullishvi) > viMaxBoxSet
box.delete(array.shift(_bullishvi))
array.push(_bullishvi, _bullboxVI)
//Bearish Volume Imbalance
if showbearvi and open < close[1] and open < open[1] and high >= low[1] and close < close[1] and close < open[1]
box _bearboxVI = na
_bearboxVI := box.new(left=bar_index-1, top=math.min(close[1],open[1]), right=bar_index+1, bottom=math.max(open,close), bgcolor=bearimbalance,border_style=BoxBorder, border_color=color.new(bearimbalance,BorderTransparency),text=plotBoxLabel?"VI-":na, text_halign=text.align_right, text_valign=text.align_bottom, text_size=BoxLabelSize, text_color=BoxLabelColor)
if array.size(_bearishvi) > viMaxBoxSet
box.delete(array.shift(_bearishvi))
array.push(_bearishvi, _bearboxVI)
anyone has a script for "Volume Imbalance"? this seems to be an easy one to write? just closing prices w/o wick but what do I know about writing.
This seems to be a really powerful toll
code...
I also would really like someone to make this script for TOS. EXTREMELY powerful trading concept for sure.can someone make this script for TOS based on the example above of Volume Imbalance alone? Thank you!
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
S | Volume Imbalance MTF | Questions | 0 | |
W | Need to calculate total volume since X time | Questions | 1 | |
J | Anchored Volume Profile with buyers and sellers like tradestation | Questions | 2 | |
H | TopSurge volume surge indicator ? | Questions | 1 | |
Calculate Avg of Volume Bars | Questions | 6 |
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.