top of page
Search

Imbalance Gaps indicator on Tradingview


I wrote indicator to use imbalance easier and more effectively.

OVERVIEW

This Imbalance gap indicator can help you when you trade with help of price gaps.

If you don't know exactly what is imbalance and trade strategy pls firstly read this article.

I use this structure often, and I have written an indicator for myself that dynamically shows these fields.

INDICATOR

When there are too many orders for a listed security that can't be fully matched by the opposing order on an exchange, there is an imbalance of orders.

We can talk about two different concepts for Imbalance.

1-The first is to open a position thinking that the price will act to close the Imbalance gaps.

2- The second is that the price starts to move in the opposite direction after filling these gaps.

Of course, there are several concepts, but these two concepts are the most preferred.


IMPLEMENTATION DETAILS

With the help of this indicator, you can easily see the price gaps that are closed and open trades accordingly.

You can also examine the unclosed price gaps on your chart in different colors depending on whether they are bullish or bearish.


SETTINGS

This script allows the user to choose color of open and closed gap colors that will help you to easily determine area of gaps

1. We can specify the maximum number of boxes to be displayed on the chart.

2. We can change the color of the closed price gaps

3. We can determine bullish or bearish price gaps according to your own trading strategy and change their colors.

4. You can change the color of borders that define the price gaps formed.


Notes:

Remember that no method works 100 percent in the market.

Imbalance is a frequently used indicator in price action concepts, and ICT also often pays attention to price gaps.


ALSO

Please do not open trades without properly managing your risk and psychology!!!


If you have any ideas what to add to my work to add more sources or make calculations cooler, suggest in DM.



Pine script Codes:

(Dont forget copy @version=5 code)*



//@version=5
indicator("Imbalance Gaps [ilovealgotrading]", "Imbalance Finder", true, max_lines_count = 500, max_boxes_count = 500)
// www.ilovealgotrading.com
// author = Baby_whale_to_moon


adboxcount = input.int (50, "Maximum Imb Box Displayed", 1, group = "###### Chart Customization ######")
boxcolor_filled = input.color(color.rgb(101, 188, 255, 70), "Filled Box Colour", group = "###### Chart Customization Box ######")
boxcolor_bullish = input.color(color.rgb(0, 230, 119, 50), "Bullish Box Colour", group = "###### Chart Customization Box ######")
boxcolor_bearish = input.color(color.rgb(255, 82, 82, 50), "Bullish Box Colour", group = "###### Chart Customization Box ######")
boxcolor = input.color(color.new(#f3ff4b, 65), "Box Line Colour", group = "###### Chart Customization Box ######")

//boxcolor = input.color(color.new(#f3ff4b, 65), "Box Line Colour", inline = "customcolor", group = "###### Chart Customization Box ######")


var tb = table.new(position.bottom_left, 1, 1, bgcolor = color.new(color.blue, 90))

if barstate.isfirst
    table.cell(tb, 0, 0, 
      'Developed by ilovealgotrading.com'
      ,text_size = size.normal
      ,text_color = color.new(#000000, 20))


var box[] imbboxarray = array.new_box()

topimbalance = low[2] <= open[1] and high[0] >= close[1]
topimbalancesize = low[2] - high[0]
bottomimbalance = high[2] >= open[1] and low[0] <= close[1]
bottomimbalancesize = low[0] - high[2]


if topimbalance and topimbalancesize > 0 or bottomimbalance and bottomimbalancesize > 0
    boxhighzone = topimbalance and topimbalancesize > 0 ? low[2] : low[0]
    boxlowzone = topimbalance and topimbalancesize > 0 ? high[0] : high[2]
    imbbox = box.new(bar_index, boxhighzone, bar_index, boxlowzone, boxcolor, border_style = line.style_dashed, bgcolor = boxcolor)
    if array.size(imbboxarray) > adboxcount
        box.delete(array.shift(imbboxarray))
    array.push(imbboxarray, imbbox)


f_choppedoffimb(imbboxarray) =>
    if array.size(imbboxarray) > 0
        for i = array.size(imbboxarray) - 1 to 0 by 1
            cutbox = array.get(imbboxarray, i)
            boxhighzone = box.get_top(cutbox)
            boxlowzone = box.get_bottom(cutbox)
            boxrightzone = box.get_right(cutbox)
            boxleftzone = box.get_left(cutbox)
            if na or bar_index - 1 == boxrightzone and (high > boxlowzone and high < boxhighzone )
                box.set_bottom(cutbox, high)
                box.set_bgcolor(cutbox, boxcolor_filled)
                box.set_right(cutbox, bar_index)
                BOX1 = box.new(left=boxleftzone, top=high, right=bar_index, bottom=boxlowzone, border_style = line.style_dashed)
                box.set_bgcolor(BOX1, boxcolor_filled )
                box.set_border_color(BOX1, color.rgb(255, 172, 124, 90) )   
            // else if na or bar_index - 1 == boxrightzone and high < boxlowzone 
            //     box.set_right(cutbox, bar_index)
            else if na or bar_index - 1 == boxrightzone and (low > boxlowzone and low < boxhighzone )
                box.set_top(cutbox, low)
                box.set_bgcolor(cutbox, boxcolor_filled)
                box.set_right(cutbox, bar_index)
                BOX2 = box.new(left=boxleftzone, top=low, right=bar_index, bottom=boxhighzone, border_style = line.style_dashed)
                box.set_bgcolor(BOX2, boxcolor_filled)
                box.set_border_color(BOX2, color.rgb(255, 172, 124, 90) )     
            else if na or bar_index - 1 == boxrightzone and not(high > boxlowzone and low < boxlowzone or high > boxhighzone and low < boxhighzone)
                box.set_right(array.get(imbboxarray, i), bar_index)
                if high >  boxhighzone
                    box.set_bgcolor(cutbox, boxcolor_bullish)
                else if low < boxlowzone
                    box.set_bgcolor(cutbox, boxcolor_bearish)
                

f_choppedoffimb(imbboxarray)


If you have any problem send message from Telegram



0 comments
bottom of page