Close Price of Specific Ticker


New member
Hi all,

I'm trying to write ThinkScript code for a %B indicator that is based on the close of the VIX. The indicator is fairly similar to the BollingerPercentB indicator given by ToS, but I wanted to make some modifications.

Firstly, I wanted the indicator to only take into account VIX. That is, regardless of which chart I am on/ showing, the study is only calculating from/for the VIX. Here's the code I have thus far:
declare lower;

input averageType = AverageType.SIMPLE;
input openPrice = open;
input displace = 0;
input length = 20;
input Num_Dev_Dn = -1.5;
input Num_Dev_up = 1.5;
input market = {default "VIX"}; 

### Error Here
input closePrice = close(market); #Error Here
### Error Here

def upperBand = BollingerBands(closePrice, displace, length, Num_Dev_Dn, Num_Dev_up, averageType).UpperBand;
def lowerBand = BollingerBands(closePrice, displace, length, Num_Dev_Dn, Num_Dev_up, averageType).LowerBand;

plot PercentB = (closePrice - lowerBand) / (upperBand - lowerBand) * 100;
plot ZeroLine = 0;
plot HalfLine = 50;
plot UnitLine = 100;

PercentB.DefineColor("None", Color.GRAY);
PercentB.DefineColor("0.1 Bound", Color.ORANGE);
PercentB.DefineColor("0.05 Bound", Color.DARK_GREEN);
PercentB.DefineColor("0 Bound", Color.GREEN);

PercentB.AssignValueColor(if PercentB > 10 then PercentB.Color("None")
else if PercentB <= 10 and PercentB > 5 then PercentB.Color("0.1 Bound")
else if PercentB <= 5 and PercentB > 0 then PercentB.Color("0.05 Bound")
else PercentB.Color("0 Bound"));


and obviously there is an error when I try to set the closePrice to be for VIX only. I've checked out the thinkscript learning center but haven't been able to get much from it. Any suggestions on how this is possible?

Similar threads