Inventory Retracement Bar (IRB) Indicator for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
Claims by Rob Hoffman. Developed and used to win trading competitions around the world, the Hoffman Inventory Retracement Trade is quickly becoming one of the most popular ways to identify where short-term counter trend institutional inventory has subsided and when it’s time to re-enter into a trade’s original trend direction.




thinkScript Code

Code:
# Inventory Retracement Bar
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/VNByUGpE-Rob-Hoffman-s-Inventory-Retracement-Bar-by-UCSgears/

input z = 45;

# Candle Range
def a = absValue(high - low);
# Candle Body
def b = absValue(close - open);
# Percent to Decimal
def c = z / 100;

# Range Verification
def rv = b < c * a;

# Price Level for Retracement
def x = low + (c * a);
def y = high - (c * a);

def sl = rv == 1 and high > y and close<y and open<y;
def ss = rv == 1 and low<x and close> x and open> x;

def li = if sl then y else if ss then x else (x+y)/2;

#assignPriceColor(if sl then color.red else if ss then color.green else color.white);

plot green = if ss then(low - 2 * tickSize()) else Double.NAN;;
green.SetPaintingStrategy(PaintingStrategy.TRIANGLES);

plot red = if sl then(high + 2 * tickSize()) else Double.NAN;
red.SetPaintingStrategy(PaintingStrategy.SQUARES);
red.SetDefaultColor(Color.magenta);

Resources to learn more about the IRB:
 
mc01439

mc01439

Well-known member
2019 Donor
VIP
@Ben Ten - Thanks for posting looking at this tonight - shows potential. I made a few changes and will test over the next few days. If the changes add to the potential for profits will post.
 
BenTen

BenTen

Administrative
Staff
VIP
@mc01439 Happy to hear. Thanks for taking a look at it.
 
P

Playstation

Active member
VIP
what does the triangles and squares mean?
if in an uptrend, and there's a triangle below a DOWN bar, means only a short term countertrend, which will soon return back to it's uptrend?
if in a downtrend, and there's a square on top an UP bar, means only a short term countertrend, which will soon return back to it's downtrend?
 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
@Playstation Magenta Square on top of the candle = bearish candle. CYAN arrow at the bottom of the candle = bullish candle. Without reading too much into the IRB resources, I believe this indicator was designed to help you with entry. Similar to what you just talked about.
 
the_yeti

the_yeti

New member
VIP
If you read the documentation given you'll see that UCGears did not get it quite right, mostly because the body location, size, and direction doesn't matter. Additionally, Rob also uses Inverse IRBs (talked about in other webinars) and explicitly states that up or down bar doesn't matter, but prefers to define it within a trend. I've reconfigured and added a regime filter. I also double checked this against charts he shared in the most recent wealth365 event- it's not perfect, but it never will be due to a variety of reasons, namely how he defines trend. In limited backtesting this plus a simple atr trailing stop or MA stop looks like it gets some nice swings

Code:
# Inventory Retracement Bar and inverse IRB

input z = 45;
input len = 20;

def r = absValue(high - low);
def b = absValue(close - open);
def c = z / 100;

def IRB = min(close,open) > ((r*c) + low);
def revIRB = max(close,open) < high - ((r*c));
def regime = movingaverage(averageType.EXPONENTIAL,close,len);

plot IRBUpTrend = if IRB and close > regime then low - ticksize() * 2 else double.nan;
IRBUpTrend.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
IRBUpTrend.setDefaultColor(color.green);
IRBUpTrend.setLineWeight(3);

plot InvIRBUpTrend = if revIRB and close > regime then low - ticksize() * 2 else double.nan;
InvIRBUpTrend.SetPaintingStrategy(PaintingStrategy.squares);
InvIRBUpTrend.setdefaultColor(color.green);
InvIRBUpTrend.setLineWeight(3);

plot IRBDownTrend = if IRB and close < regime then high + ticksize() * 2 else double.nan;
IRBDownTrend.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
IRBDownTrend.setDefaultColor(color.magenta);
IRBDownTrend.setLineWeight(3);

plot InvIRBDownTrend =if revIRB and close < regime then high + ticksize() * 2 else double.nan;
InvIRBDownTrend.SetPaintingStrategy(PaintingStrategy.squares);
InvIRBDownTrend.setdefaultColor(color.magenta);
InvIRBDownTrend.setLineWeight(3);
 
D

diazlaz

Well-known member
2019 Donor
VIP
@the_yeti this is super helpful thank you for sharing and expanding on the methodology. it's always nice to have another deriviative that can be use as a proxy for trend. welcome to the forum!
 

Similar threads

Top