Hi, I'm looking for help on a script that's able to simply shade the area chosen for IB (I like using the first hour) but there would be an input to choose which range you want to define as your IB.
Once IB closes ( 10:30am ET) in my example, the labels will show " IB high : $ price | IB low: $ price | IB mid : $ price "
if Price is above IB high color dark.green , if below IB low, color pink, if in between IB high and IB low, color white.
This the IB for today with the proper shading im looking for from tradingview
No, it stems from a method some futures traders follow that identifies the Initial balance (9:30-10:30; first hour of trading) which then sets up the rest of the session. There is historical analysis/backtests out there that go into the probability of trades, long/short, if price closes above the "IB" high on x timeframe, and vice versa. There's a ton of info on IB out there that i can link if you're interested.
The indicator really is just a simple one, imo, that "paints" the IB area once it closes with a shaded box and the label then displays the IB high (price), IB mid (halfway point between Hi/lo) price and IB Low (price). The background coloring then just follows the close of each candle to determine the coloring.
No, it stems from a method some futures traders follow that identifies the Initial balance (9:30-10:30; first hour of trading) which then sets up the rest of the session. There is historical analysis/backtests out there that go into the probability of trades, long/short, if price closes above the "IB" high on x timeframe, and vice versa. There's a ton of info on IB out there that i can link if you're interested.
The indicator really is just a simple one, imo, that "paints" the IB area once it closes with a shaded box and the label then displays the IB high (price), IB mid (halfway point between Hi/lo) price and IB Low (price). The background coloring then just follows the close of each candle to determine the coloring.
Sure. The script will allow for an adjustable “initial balance”. For my purposes it would equal the first hour of trading. And the shading would draw a box that covers the high and low achieved during that period. It should also paint a dashed line for the mid (didn’t include this prior). The line doesn’t have to extend past the box.
Hi, I'm looking for help on a script that's able to simply shade the area chosen for IB (I like using the first hour) but there would be an input to choose which range you want to define as your IB.
Once IB closes ( 10:30am ET) in my example, the labels will show " IB high : $ price | IB low: $ price | IB mid : $ price "
if Price is above IB high color dark.green , if below IB low, color pink, if in between IB high and IB low, color white.
This the IB for today with the proper shading im looking for from tradingview
general comment meant to help people compose better requests,
after reading 100s of questions, i have observed, if the word 'simply' is used in a request, almost always there is missing information. reread your post and if you find that word, read it again and elaborate.
when making a request, think about what you want to see and what has to happen.
don't expect others to interpret a picture. your words should describe the situation.
include a link to describe theories.
don't use meaningless terms or abbreviations.
ib or Initial Balance , has no meaning in TOS. you didn't offer any information or link that would describe what it is.
i think you want,
.. define some period, with start and stop times.
.. within this time period, find the highest and lowest prices.
.. calculate the middle price level.
change the color of something, but i'm not sure what.
you mention 3 colors for 3 price situations, but you don't say WHAT you want colored.
----------------------
this finds the highest and lowest , over some period, within a day.
it shades the region
labels show the hi, lo, mid levels
Code:
#period_hilomid_ib
#https://usethinkscript.com/threads/initial-balance-with-labels.21237/
#Initial Balance with Labels
#hboogie 7/7
# shade the area chosen for IB (I like using the first hour)
# but there would be an input to choose which range you want to define as your IB.
# Once IB closes ( 10:30am ET) in my example,
# the labels will show
# IB high : $ price | IB low: $ price | IB mid : $ price
# ??
# dark.green - Price is above IB high color
# pink - price is below IB low
# white - price is in between IB high and IB low
def na = double.nan;
def bn = barnumber();
def n = 500;
def big = 99999;
input start = 0930;
input end = 1030;
def period = if SecondsFromTime(start) >= 0 and SecondsTillTime(end) > 0 then 1 else 0;
def hi;
def lo;
if period and !period[1] then {
hi = fold a = 0 to n
with b
while getvalue(period,-a)
do max(b,getvalue(high,-a));
lo = fold c = 0 to n
with d = big
while getvalue(period,-c)
do min(d,getvalue(low,-c));
} else if period then {
hi = hi[1];
lo = lo[1];
} else {
hi = 0;
lo = 0;
}
def mid = (hi+lo)/2;
def hi2 = if (period and !period[1]) then hi else hi2[1];
def lo2 = if (period and !period[1]) then lo else lo2[1];
def mid2 = if (period and !period[1]) then mid else mid2[1];
addlabel(1," IB high : $ " + hi2, color.yellow);
addlabel(1," IB low: $ " + lo2, color.yellow);
addlabel(1," IB mid : $ " + mid2, color.yellow);
plot z1 = if hi > 0 then hi else na;
z1.SetDefaultColor(Color.gray);
#z1.setlineweight(1);
z1.hidebubble();
plot z2 = if lo > 0 then lo else na;
z2.SetDefaultColor(Color.gray);
#z2.setlineweight(1);
z2.hidebubble();
plot z3 = if lo > 0 then mid else na;
z3.SetStyle(Curve.MEDIUM_DASH);
z3.SetDefaultColor(Color.cyan);
#z3.setlineweight(1);
z3.hidebubble();
addcloud(z1,z2,color.gray);
#
Ok Interesting. I see it as an ORB without the buys and sells and stops - I did add some labels that I would use as current hi lo and mid values - a volume label to signal rising or falling volume and an accumulated average candle close price to see how far off mid I am at the moment... I also extended the lines to close of day (really to mid-night to capture overnight action.)
Just a note
The script calculates the running average of candle closes from 9:30 to 15:59, based on whatever timeframe you're currently viewing (1-min, 5-min, 15-min, etc.). So on a 1-minute chart, it averages 1-minute close values. On a 5-minute chart, it averages the 5-minute candle closes and remember fewer candles = fewer data points = different average result.
Just playing with it - added some areas of interest with labelling and some conditions that identify cycles as dealers will play with liquidity from time to time and added some labelling to identify compression zones to be a tad bit more proactive. https://tos.mx/!1qcxixv4
general comment meant to help people compose better requests,
after reading 100s of questions, i have observed, if the word 'simply' is used in a request, almost always there is missing information. reread your post and if you find that word, read it again and elaborate.
when making a request, think about what you want to see and what has to happen.
don't expect others to interpret a picture. your words should describe the situation.
include a link to describe theories.
don't use meaningless terms or abbreviations.
ib or Initial Balance , has no meaning in TOS. you didn't offer any information or link that would describe what it is.
i think you want,
.. define some period, with start and stop times.
.. within this time period, find the highest and lowest prices.
.. calculate the middle price level.
change the color of something, but i'm not sure what.
you mention 3 colors for 3 price situations, but you don't say WHAT you want colored.
----------------------
this finds the highest and lowest , over some period, within a day.
it shades the region
labels show the hi, lo, mid levels
Code:
#period_hilomid_ib
#https://usethinkscript.com/threads/initial-balance-with-labels.21237/
#Initial Balance with Labels
#hboogie 7/7
# shade the area chosen for IB (I like using the first hour)
# but there would be an input to choose which range you want to define as your IB.
# Once IB closes ( 10:30am ET) in my example,
# the labels will show
# IB high : $ price | IB low: $ price | IB mid : $ price
# ??
# dark.green - Price is above IB high color
# pink - price is below IB low
# white - price is in between IB high and IB low
def na = double.nan;
def bn = barnumber();
def n = 500;
def big = 99999;
input start = 0930;
input end = 1030;
def period = if SecondsFromTime(start) >= 0 and SecondsTillTime(end) > 0 then 1 else 0;
def hi;
def lo;
if period and !period[1] then {
hi = fold a = 0 to n
with b
while getvalue(period,-a)
do max(b,getvalue(high,-a));
lo = fold c = 0 to n
with d = big
while getvalue(period,-c)
do min(d,getvalue(low,-c));
} else if period then {
hi = hi[1];
lo = lo[1];
} else {
hi = 0;
lo = 0;
}
def mid = (hi+lo)/2;
def hi2 = if (period and !period[1]) then hi else hi2[1];
def lo2 = if (period and !period[1]) then lo else lo2[1];
def mid2 = if (period and !period[1]) then mid else mid2[1];
addlabel(1," IB high : $ " + hi2, color.yellow);
addlabel(1," IB low: $ " + lo2, color.yellow);
addlabel(1," IB mid : $ " + mid2, color.yellow);
plot z1 = if hi > 0 then hi else na;
z1.SetDefaultColor(Color.gray);
#z1.setlineweight(1);
z1.hidebubble();
plot z2 = if lo > 0 then lo else na;
z2.SetDefaultColor(Color.gray);
#z2.setlineweight(1);
z2.hidebubble();
plot z3 = if lo > 0 then mid else na;
z3.SetStyle(Curve.MEDIUM_DASH);
z3.SetDefaultColor(Color.cyan);
#z3.setlineweight(1);
z3.hidebubble();
addcloud(z1,z2,color.gray);
#
@halcyonguy Thank you and noted on using the word "simply" going forward. But, regarding this point, I thought the label coloring instructions were obvious with my first quote. What else was missing ? It's the entire label that I originally wanted colored. Having zero coding ability, I , unlike you, don't know the extent of what I could be labeling or coloring....
I tried to create a short thread as opposed to bombarding the thread with links and examples only for it to be confusing. If there are hardcoded criterias you and the admins want on descriptions, inclusive to links, point me to where that's mentioned or perhaps a pinned thread I missed.
Thanks @antwerks for taking it on and making it your own and providing some awesome feedback.
@halcyonguy Thank you and noted on using the word "simply" going forward. But, regarding this point, I thought the label coloring instructions were obvious with my first quote. What else was missing ? It's the entire label that I originally wanted colored. Having zero coding ability, I , unlike you, don't know the extent of what I could be labeling.....
i try to create a short thread as opposed to bombarding the thread with links and examples only for it to be confusing. If there are hardcoded criterias you and the admins want on descriptions, inclusive to links, point me to where that's mentioned or perhaps a pinned thread I missed.
Thanks @antwerks for taking it on and making it your own and providing some awesome feedback.
I hope I am leaning in a positive direction and not confusing the issue - just trying to wrap my head around this IB method/strategy. There are some things in the IB calcs that TOS can not do so work arounds are needed. Still playing with it - will see this morning how it works!!!!
Just playing with it - added some areas of interest with labelling and some conditions that identify cycles as dealers will play with liquidity from time to time and added some labelling to identify compression zones to be a tad bit more proactive. https://tos.mx/!1qcxixv4View attachment 25114
@antwerks -- where can i comment out the vertical sqz lines, if possible ? would be great if that were in the settings, to make it easier for us non-coders.
I hope I am leaning in a positive direction and not confusing the issue - just trying to wrap my head around this IB method/strategy. There are some things in the IB calcs that TOS can not do so work arounds are needed. Still playing with it - will see this morning how it works!!!!
Yes, absolutely. I love the feature in the "no signals" version of being able to look at the IB's from previous sessions. I think if you were to be able combine that feature into the "signals" version with the ability to turn off the sqz lines, I'd love to see that play out in real-time. Awesome work!
Also, here is a link on some stats with regard to IB. There many many studies on it and can link more if anyone is interested.
Yes, absolutely. I love the feature in the "no signals" version of being able to look at the IB's from previous sessions. I think if you were to be able combine that feature into the "signals" version with the ability to turn off the sqz lines, I'd love to see that play out in real-time. Awesome work! View attachment 25118
Also, here is a link on some stats with regard to IB. There many many studies on it and can link more if anyone is interested.
So, in context n = 500 sets an upper limit on how many bars the script will scan backwards to compute the IB High and Low using fold. It doesn’t mean it always uses 500 bars. It only uses as many bars as exist within the 9:30–10:30 period.
For example, on a 5-minute chart, that's 12 bars max, so n = 500 just ensures the fold loop has more than enough range to scan safely.
If you're ever scanning assets with higher prices (e.g., BRK.A), you might want to increase big to 1e6 or even use a custom script to ensure the right values are used automatically.
Purpose of big in the script denotes d = big and initializes the minimum low search with a high starting value (99999). As the fold iterates, it checks Min(d, low), updating d only if a smaller value is found. This ensures that lo ends up being the lowest low during the Initial Balance (IB) period.
So, in context n = 500 sets an upper limit on how many bars the script will scan backwards to compute the IB High and Low using fold. It doesn’t mean it always uses 500 bars. It only uses as many bars as exist within the 9:30–10:30 period.
For example, on a 5-minute chart, that's 12 bars max, so n = 500 just ensures the fold loop has more than enough range to scan safely.
If you're ever scanning assets with higher prices (e.g., BRK.A), you might want to increase big to 1e6 or even use a custom script to ensure the right values are used automatically.
One quick quirk I found, on a 1m chart I'm noticing on those instances that the exact 10:30 candle (1m agg) makes the high (in this example) it doesn't use that candle high. Is there a setting to wait for that candle to close in order to mark that level ? or is this normal because of how TOS does this calculation ?
That's a SPY session from 6/26 at 10:30am (green arrow marker)
Just playing with it - added some areas of interest with labelling and some conditions that identify cycles as dealers will play with liquidity from time to time and added some labelling to identify compression zones to be a tad bit more proactive. https://tos.mx/!1qcxixv4View attachment 25114
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.
How do I get started?
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.
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.