Close Price of Specific Ticker

rjacobse7

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:
Code:
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"));

PercentB.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
PercentB.SetLineWeight(1);

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?
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
430 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