Relative Bar Value Indicator for ThinkorSwim

a3ctrader

New member
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));
 

nduckste

New member
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
 

a3ctrader

New member
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

Top