ARBR and CR Indicators (Emotion and Willingness Indexes) for ThinkorSwim

mashume

Expert
VIP
All,

Something new to play with. Here are the ARBR and CR indicators for ThinkOrSwim. They have not been extensively backtested or even tested at all. Just something I found while poking around in some other software and thought "hey, what's that?" So I wrote them up for ToS.

There is a little bit on the internet about how to use these indicators of you search for it. A lot of it seems to be badly translated to English and I haven't taken the time to rewrite the instructions for use.

Any thoughts?

Eye Candy:

-mashume

ArBr Indicator:

Code:
``````############################################
#
#              ArBr Indicator
#  Emotion Index and Willingness Indicator
#
#     released under GPL 3 as applicable
#              January 2021
#                  V1.0
#                @mashume
#
############################################

declare lower;

input n = 26;

# AR=SUM(HIGH-OPEN,N)/SUM(OPEN-LOW,N)*100
# The sum of the difference between the highest price and the opening price in the last N days is divided by the sum of the difference between the opening price and the lowest price, and the ratio is multiplied by 100.

plot AR = (sum( high - open , n) / sum( open - low , n )) * 100;
AR.SetDefaultColor(Color.RED);

plot AR_Top = 120;
AR_Top.SetStyle(Curve.SHORT_DASH);
AR_TOP.SetDefaultColor(Color.Red);
AR.SetLineWeight(2);

plot AR_Low = 80;
AR_Low.SetStyle(Curve.SHORT_DASH);
AR_Low.SetDefaultColor(Color.Red);

# BR=SUM(MAX(0,HIGH-REF(CLOSE,1)),N)/SUM(MAX(0,REF(CLOSE,1)-LOW),N)*100

# In the last N days, if the highest price of a certain day is higher than the closing price of the previous day, the difference between the highest price of the day and the previous closing will be added to the strong days sum. If the lowest price of a certain day is lower than the previous closing, the previous closing will be combined with the difference in the lowest price of the day is added to the weak days sum. Finally, divide the strong sum by the weakdayssum, and the resulting ratio is enlarged by 100. Where N=26

plot BR = (sum(max(0, high - close[1]), n) / sum(max(0, close[1] - low), n)) * 100;
BR.SetDefaultColor(color.blue);
BR.SetLineWeight(2);

plot Center = 100;
Center.SetDefaultColor(Color.White);
Center.SetStyle(CURVE.LoNG_DASH);

plot br_top = 150;
br_top.setDefaultColor(color.blue);
br_top.SetStyle(CURve.SHORT_DASH);

plot br_low = 70;
br_low.setDefaultColor(color.blue);
br_low.SetStyle(CURve.SHORT_DASH);

AddLabel(AR Crosses Below BR and AR < 100, "Buy on Dip", color.Dark_Green);
AddLabel(BR > 300, "Br Warning", Color.RED);
AddLabel(AR > 150, "Ar Warning", Color.RED);
AddLabel(BR < 50, "Br Entry Watch", Color.Dark_Green);
AddLabel(AR < 70, "Ar Entry Watch", Color.Dark_Green);
addLabel(AR > 80 and AR < 120, "Ar Neutral", color.Gray);
addLabel(BR > 70 and BR < 150, "Br Neutral", color.Gray);``````

CR Indicator:

Code:
``````############################################
#
#              Cr Indicator
#  Emotion Index and Willingness Indicator
#
#     released under GPL 3 as applicable
#              January 2021
#                  V1.0
#                @mashume
#
############################################

declare lower;

input n = 30;
input YM = HL2;
input a_len = 10;
input B_len = 20;
input C_len = 40;
input D_len = 60;

plot CR = (sum(max(0, high - YM[1]), n) / sum(max(0, YM[1] - low), n)) * 100;
CR.SetDefaultColor(color.PLUM);
CR.SetLineWeight(2);

plot a = SimpleMovingAvg(CR, a_len);
plot B = SimpleMovingAvg(CR, b_len);
plot C = SimpleMovingAvg(CR, c_len);
plot D = SimpleMovingAvg(CR, d_len);

a.setDefaultColor(Color.Dark_Gray);
b.setDefaultColor(Color.Dark_Gray);
b.setStyle(Curve.MEDIUM_DASH);
c.setDefaultColor(Color.Gray);
d.setDefaultColor(Color.Gray);
d.SetStyle(Curve.MEDIUM_DASH);

AddLabel(CR > 150, "CR Warning", Color.RED);

AddLabel(CR < 70, "CR Entry Watch", Color.Dark_Green);

plot Center = 100;
Center.SetDefaultColor(Color.White);
Center.SetStyle(Curve.LONG_DASH);``````

P.S. I have started looking at scans based on these, but they're not quite ready for prime time (not that these are necessarily either)

Last edited by a moderator:
Hello, anyone has the above 2 Indicators to share for TOS I couldn't locate them in TOS studies. Thanks

I manage to get the VR Script from Trading View and hope someone kind enough to help to convert into TOS.

Code:
``````//@version=3
// Copyright (c) 2018-present, Alex Orekhov (everget)
study("Volatility Ratio", shorttitle="VR")

length = input(title="Length", type=integer, minval=1, defval=14)
breakoutLevel = input(title="Breakout Level", type=float, minval=0, step=0.1, defval=0.5)

_highest(length, start) =>
out = nz(high[start])
for i = start + 1 to length - 1
prev = nz(high[I])
out := out < prev ? prev : out
out

_lowest(length, start) =>
out = nz(low[start])
for i = start + 1 to length - 1
prev = nz(low[I])
out := out > prev ? prev : out
out

max = max(_highest(length, 1), close[length + 1])
min = min(_lowest(length, 1), close[length + 1])

vr = tr(true) / (max - min)

vrColor = vr >= breakoutLevel ? #ff9800 : #3c78d8

plot(vr, title="VR", color=vrColor, transp=0)

hline(breakoutLevel, title="Breakout Level", linestyle=dotted)

breakoutFillColor = vr >= breakoutLevel ? #ff9800 : color(white, 100)
bgcolor(breakoutFillColor, transp=90)``````

Last edited:

In general, AR can be used alone, BR and AR need to be used in conjunction to be effective, therefore, in the calculation of AR, BR, AR and BR curves should be drawn in the same map, AR and BR merger, The rules are as follows:

1, AR and BR at the same time rapid rise, which means the stock price peak near the time of holding should pay attention to profit-taking.

2, BR lower than the AR, and the index is below 100 to the next, you can consider bargain hunting.

3, BR from the peak back down, down to 1.2, if the AR no warning signal appears to be bargain hunters.

4, BR rapid rise, AR consolidation small back, should rallies to sell, timely end

I haven't tested these filters so don't know the veracity of the information.

@MerryDay I built a bunch of AddLabel features into the indicators that mirror the consensus of uses for these that I found online (I read about 6 pages on the indicators as I was building them).

@hoojsn Check indicator above.

@mashume Thank you very much for the New Year 2021 present. I really appreciate that you have put so much effort into it. By the way, do you happen to have "VR" Volatility Ratio" for TOS and share it? VR Indicator will combo well with ARBR and CR.

I know this is probably known, but just in case, to find more information on how this indicator works you can search BRAR indicator.

@hoojsn Hack Job, but here's VR:

http://tos.mx/hoxu0XS

5 methods, since I couldn't decide which one was better. 1 and 2 seem to produce nearly identical results.
Method 3 produces a similar graph, but with VERY small values.
Method 4 seems to be an inverse of methods 1 and 2 (swapped around the 0 line).
Method 5 is an attempt to reproduce the Trading View version from the provided code.

If anyone can shed light on which method is preferred, or if I coded something up horribly incorrectly, do point it out in the comments.

I have no idea how to use this for anything, but the math is fun enough for me. Perhaps you can explain how you pair it up with the ARBR indicators?

-mashume

Code:
``````########################################
#
#       Volatility Ratio Indicator
#          (collected methods)
#
#           January 2021 V1
#              GNU GPL 3
#      @mashume for UseThinkScript
#
#      uncomment the method you
#             want to use
#
########################################

declare lower;

input n = 14;

# METHOD 1
def TTR = max(HIGH, CLOSE[1]) - min(LOW, CLOSE[1]);
plot VR = TTR / ATR(n);

# METHOD 2
def TTR_2 = max(max(HIGH - LOW, HIGH - CLOSE[1]), CLOSE[1] - LOW);
def VR_2 = AbsValue(TTR_2) / ATR(n);

# METHOD 3
def VR_3 = TTR / MovAvgExponential(CLOSE, n);

# METHOD 4
def _MAX = HIGH - CLOSE[1];
def _MIN = LOW - CLOSE[1];
def TTR_4 = _MIN - _MAX;
def VR_4 = TTR_4 / ATR(n);

# METHOD 5 -- Trading View ?
def _max_ = max(highest(CLOSE[1], n), close[n + 1]);
def _min_ = min(lowest(LOW[1], n), close[n + 1]);
def tr = TrueRange(high = HIGH, close = CLOSE, low = LOW);
plot VR_5 = tr / (_max_ - _min_);``````

Last edited:
Thanks again for your great effort. However, the VR seems quite different from my current software for stock analysis purpose. Mine came in % form. When n cross 60%, it a buy point until reached the oversold region of 300% when things get ugly and need to take profit. Really thanks for your effort.

Maybe something like this, done with method 1, but you can sub in whichever method you're interested in using. Looking at this on a daily chart makes more sense to me than an intraday. What timeframes do you usually look at this on?

Code:
``````declare lower;

input n = 14;
input oversold = 300;
input overbought = 50;

# METHOD 1
def TTR = max(HIGH, CLOSE[1]) - min(LOW, CLOSE[1]);
plot VR = (TTR / ATR(n)) * 100;
VR.SetDefaultColor(COLOR.PLUM);
VR.SETLIneWeight(2);

plot Center = 100;
Center.SetDefaultColor(Color.BLACK);
Center.SetStyle(CUrve.MEDIUM_DASH);
plot OB = overbought;
OB.SetDefaultColor(Color.Dark_Gray);
OB.SetStyle(Curve.SHORT_DASH);
plot OS = overSold;
OS.SetDefaultColor(Color.Dark_Gray);
OS.SetStyle(Curve.SHORT_DASH);

plot buyPoint = if VR < overbought then VR else double.nan;

My background is light-themed, so you may have to play with the colors if you use a dark background.

-mashume

@mashume Thanks, I will play around with it. Normally I will use with day chart.

Hope I am not asking too much. The Indicator you Script for ARBR, CR & Lastest Revision VR is really great. Is it possible you can convert into Trading View Script. I am using it to trade Market like HK. Thanks.

@mashume Hope I am not asking too much. The Indicator you Script for ARBR, CR & Lastest Revision VR is really great. Is it possible you can convert into Trading View Script. I am using it to trade Market like HK. Thanks.
Might seem like a silly question but why not ask someone over on Trading View to do that conversion...??? Or learn to code it yourself... Seems kinda ballsy to expect members here to code for other platforms upon request... Think about it...!!!

Eh, I had coded up the ARBR before I saw the request on here anyway.

;-)

mashume

Might seem like a silly question but why not ask someone over on Trading View to do that conversion...??? Or learn to code it yourself... Seems kinda ballsy to expect members here to code for other platforms upon request... Think about it...!!!
Hey you are being rude here and should be ban from this forum I am asking politely for Sir Mahume for help. If you could extend your input fine or else just throw your frustration somewhere when you lost in your Trading.

@mashume Thanks for your precious time and I know it a heck of a Job. Hopefully I can find in other place for this useful Indicator for Trading View. As my skill set is in Trading not a Script Writer. Cheers.

here is a version where I added Deviation Bands, Arrows and Colored in Clouds
Code:
``````############################################
#
#              Cr Indicator
#  Emotion Index and Willingness Indicator
#
#     released under GPL 3 as applicable
#              January 2021
#                  V1.0
#                @mashume
#01102021 H Kaczmarczyk added Deviation Bands ,Arrows ,Clouds
############################################

declare lower;

input n = 30;
input YM = HL2;
input a_len = 10;
input B_len = 20;
input C_len = 40;
input D_len = 60;
input showArrows = yes;
plot CR = (Sum(Max(0, high - YM[1]), n) / Sum(Max(0, YM[1] - low), n)) * 100;
CR.SetDefaultColor(Color.PLUM);
CR.SetLineWeight(2);

plot a = SimpleMovingAvg(CR, a_len);
plot B = SimpleMovingAvg(CR, B_len);
plot C = SimpleMovingAvg(CR, C_len);
plot D = SimpleMovingAvg(CR, D_len);

a.SetDefaultColor(Color.DARK_GRAY);
B.SetDefaultColor(Color.DARK_GRAY);
B.SetStyle(Curve.MEDIUM_DASH);
C.SetDefaultColor(Color.GRAY);
D.SetDefaultColor(Color.GRAY);
D.SetStyle(Curve.MEDIUM_DASH);

plot UZone = SimpleMovingAvg(CR, 34) + (1.3185 * StDev(CR, 34));
plot LZone = SimpleMovingAvg(CR, 34) - (1.3185 * StDev(CR, 34));
UZone.SetStyle(Curve.SHORT_DASH);
UZone.SetDefaultColor(Color.CYAN);
LZone.SetStyle(Curve.SHORT_DASH);
LZone.SetDefaultColor(Color.CYAN);
plot UZoneArrowdown = if showArrows == yes and CR crosses below UZone then UZone else Double.NaN;
UZoneArrowdown.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
UZoneArrowdown.SetDefaultColor(Color.CYAN);
UZoneArrowdown.setLineweight(3);
plot UZoneArrowUp = if showArrows == yes and CR crosses Above UZone then UZone else Double.NaN;
UZoneArrowUp.SetPaintingStrategy(PaintingStrategy.ARROW_Up);
UZoneArrowUp.SetDefaultColor(Color.CYAN);
UZoneArrowUp.setLineweight(3);
plot LZoneArrowUp = if showArrows == yes and CR crosses Above LZone then LZone else Double.NaN;
LZoneArrowUp.SetPaintingStrategy(PaintingStrategy.ARROW_Up);
LZoneArrowUp.SetDefaultColor(Color.CYAN);
LZoneArrowUp.setLineweight(3);
plot LZoneArrowdown = if showArrows == yes and CR crosses Below LZone then LZone else Double.NaN;
LZoneArrowdown.SetPaintingStrategy(PaintingStrategy.ARROW_Down);
LZoneArrowdown.SetDefaultColor(Color.CYAN);
LZoneArrowdown.setLineweight(3);

plot CRArrowUp1 = if showArrows == yes and CR crosses Above Max(a,B) then Max(a,B) else Double.NaN;
CRArrowUp1.SetPaintingStrategy(PaintingStrategy.ARROW_Up);
CRArrowUp1.SetDefaultColor(Color.Magenta);
CRArrowUp1.setLineweight(3);
plot CRArrowdown1 = if showArrows == yes and CR crosses Below Max(a,B) then Max(a,B) else Double.NaN;
CRArrowdown1.SetPaintingStrategy(PaintingStrategy.ARROW_Down);
CRArrowdown1.SetDefaultColor(Color.Magenta);
CRArrowdown1.setLineweight(3);

plot CRArrowUp2 = if showArrows == yes and CR crosses Above Min(a,B) then Min(a,B) else Double.NaN;
CRArrowUp2.SetPaintingStrategy(PaintingStrategy.ARROW_Up);
CRArrowUp2.SetDefaultColor(Color.Magenta);
CRArrowUp2.setLineweight(3);
plot CRArrowdown2 = if showArrows == yes and CR crosses Below Min(a,B) then Min(a,B) else Double.NaN;
CRArrowdown2.SetPaintingStrategy(PaintingStrategy.ARROW_Down);
CRArrowdown2.SetDefaultColor(Color.Magenta);
CRArrowdown2.setLineweight(3);

AddLabel(CR > 150, "CR Warning", Color.RED);

AddLabel(CR < 70, "CR Entry Watch", Color.DARK_GREEN);

plot Center = 100;
Center.SetDefaultColor(Color.WHITE);
Center.SetStyle(Curve.LONG_DASH);``````

Last edited:

Not the exact question you're looking for?

87k+ Posts
338 Online

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

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.

What are the benefits of VIP Membership?