# Relative Bar Value Indicator for ThinkorSwim

##### New member
Relative Bar Value

Last edited:
What does the red and black bar signify?

What does the red and black bar signify?

The color of each relative bar is based on its close vs open and if it's below, within, or above the normal range. See code below.

Code:
``````RelativeBarValue.AssignValueColor(
if close > open and RelativeBarValue <   NormalRangeLow  then CreateColor(102, 102, 255)
else if close > open and RelativeBarValue <=  NormalRangeHigh then CreateColor(0,   0,   255)
else if close > open                                          then CreateColor(0,   0,   153)
else if close < open and RelativeBarValue <   NormalRangeLow  then CreateColor(255, 102, 102)
else if close < open and RelativeBarValue <=  NormalRangeHigh then CreateColor(255, 0,   0)
else if close < open                                          then CreateColor(153, 0,   0)
else if                  RelativeBarValue <   NormalRangeLow  then CreateColor(128, 128, 128)
else if                  RelativeBarValue <=  NormalRangeHigh then CreateColor(64,  64,  64)
else                                                               CreateColor(0,   0,   0));``````

@a3ctrader nice one, how to make this as scan?

I'm new to ThinkScript. What defines "normal range" in your indicator?

To be transparent, I'm looking for a script that plots the average volume for the current time bar based on the average for that same time bar over the last x days. So if the current bar is 09:30, I want to plot the average for the 09:30 bar over the last x days. Is that what this is doing?

I've done this in NinjaScript simply by looping through the last x days for a particular bar, summing those values, and then dividing by x days. That is very procedural (NinjaScript is C# based) but I'm guessing there is a more elegant way in ThinkScript.

Thanks,

Nick

I'm new to ThinkScript. What defines "normal range" in your indicator?

To be transparent, I'm looking for a script that plots the average volume for the current time bar based on the average for that same time bar over the last x days. So if the current bar is 09:30, I want to plot the average for the 09:30 bar over the last x days. Is that what this is doing?

I've done this in NinjaScript simply by looping through the last x days for a particular bar, summing those values, and then dividing by x days. That is very procedural (NinjaScript is C# based) but I'm guessing there is a more elegant way in ThinkScript.

Thanks,

Nick
Nick,

This indicator uses DataProfile to automatically set the upper and lower "normal range" at one standard deviation or 68%. The chart lookback period will determine the amount of data that's used in the calculation. I use this indicator for overnight index futures with 20 minutes being the lowest timeframe. A lower timeframe can be used on day only session futures/stocks. The relative bar value is (Value / AvgValue) * 100.

87k+ Posts
371 Online

## The Market Trading Game Changer

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?