1. Home
  2. Constants
  3. thinkScript PriceType (with Examples)

thinkScript PriceType (with Examples)

In thinkScript, PriceType is a constant that displays selections of price quotations.

Use it with fundamental functions like volume, implied volatility (IV), and open interest.

There are 4 different values that PriceType can retrieve:

  • Bid
  • Ask
  • Last
  • Mark

In this post, we’ll go through each PriceType option and show you how to apply them in your thinkScript code.


The bid defines the highest price someone is willing to pay for the stock.

You can display the bid price of a stock using the following snippet.

plot BidPrice = close(priceType = "BID");


The ask indicates the lowest price an investor is willing to sell their stock for.

You can display the ask price in thinkScript using this snippet.

plot AskPrice = close(priceType = "ASK");


PriceType.LAST is the price of the last trade. It’s the equivalent of the current stock price.

Similar to how thinkScript returns the Bid and Ask price, the same can be used to show the stock’s last price.

plot LastPrice = close(priceType = "LAST");


Think of the Mark price as the estimated fair value based on the bid and ask.

This figure is helpful in futures trading and any other highly volatile market.

plot MarkPrice = close(priceType = "MARK");

PriceType Code Examples in thinkScript

The PriceType constant only work on the intraday timeframe.

Using any of the code below on the Day or Week aggregation period will not return any value.

Bid-Ask Spread

The bid-ask spread is the difference between the bid and ask prices.

declare lower;
plot spread = close(priceType = PriceType.ASK) - close(priceType = PriceType.BID);

Display Bid/Ask Price as Label

You can display the bid and ask on your chart as two separate labels.

def AskPrice = close(priceType = PriceType.ASK);
def BidPrice = close(priceType = PriceType.BID);
AddLabel(yes, "Ask: " + AskPrice);
AddLabel(yes, "Bid: " + BidPrice);

PriceType Switcher

You can add a user input to PriceType.

input priceType = PriceType.ASK;
plot Data = close(priceType = priceType);

This method lets you quickly switch between Bid, Ask, Last, and Mark without editing the source code.

By default, the script plots the Ask price. However, the “price type” can be changed right from the indicator’s settings.

Happy coding!

Unlock the Power of ThinkorSwim

Get the latest news and updates on TD Ameritrade, ThinkorSwim indicators, thinkScript tutorials, and trading strategies delivered straight to your inbox every week.

We don’t spam! Unsubscribe at anytime.

Leave a Reply

Your email address will not be published. Required fields are marked *