Relative Bar Value Indicator for ThinkorSwim

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

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));
 
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.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
371 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

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?
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.
Back
Top