Bid Ask Labels For ThinkOrSwim

raj2ras

New member
I am new to thinkScript. Is it possible to get the bid ask spread as a label on a daily chart?

Thank you in advance
 
@raj2ras The following is a snippet of code from one of my regularly used Studies, edited to your request...

Ruby:
def bid = close(priceType = PriceType.BID);
def ask = close(priceType = PriceType.ASK);

AddLabel(yes, "Bid: " + Round(bid, 2), Color.GRAY);
AddLabel(yes, "Ask: " + Round(ask, 2), Color.GRAY);
AddLabel(yes, "BA/2: " + Round((bid + ask) / 2, 2), Color.GRAY);
 
#Bid, Ask, Spreads Label
input limit = 0.09;
def priceB = close(priceType = PriceType.BID);
def priceA = close(priceType = PriceType.ASK);
AddLabel(yes, Concat("Bid: ", priceB), Color.WHITE);
AddLabel(yes, Concat("Ask: ", priceA), Color.WHITE);
AddLabel(yes, Concat("Spread: ", priceA - priceB), if priceA - priceB > limit then Color.RED else Color.WHITE);
 
Last edited by a moderator:
My label boxes on the chart do not show the actual bid and ask prices for lower time frames less than 4 Hours.
What could be the reason for this?
Thanks.

Update:
my message was incorrect. It should have read:
My label boxes on the chart do not show the actual bid and ask prices for time frames of 4 hours or greater than 4 Hours. Time frames below 4 hours are OK.
What could be the reason for this?
I am not paper trading.
Thanks. I very much appreciate your help and your contributions to the site.
 
Last edited by a moderator:
Haven't had any reported issues with the code. Are you maybe paper trading? Have you tried reinstalling making sure to copy entire code?
#Bid, Ask, Spreads Label
input limit = 0.09;
def priceB = close(priceType = PriceType.BID);
def priceA = close(priceType = PriceType.ASK);
AddLabel(yes, Concat("Bid: ", priceB), Color.WHITE);
AddLabel(yes, Concat("Ask: ", priceA), Color.WHITE);
AddLabel(yes, Concat("Spread: ", priceA - priceB), if priceA - priceB > limit then Color.RED else Color.WHITE);

Are you able to use this in a scanner? Would like to thin the heard if possible?
 
My label boxes on the chart do not show the actual bid and ask prices for time frames of 4 hours or greater than 4 Hours.
@UpTwoBucks

You didn't provide enough information to say where you went astray.
If I was to hazard a wild guess. I would say that your chart time interval is too high.

Bid and Ask price types are only supported on intraday charts with time interval not greater than 15 days.
https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/PriceType/PriceType-ASK
 

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
416 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