• Memorial Day Sale! Claim the biggest discount of the year with $50 off VIP using code MEM50. Sign up here.

Days In Trade Custom Column


New member
Hello, I haven't been able to find a solution so hoping someone could help me out or point me in the right direction.

I have both stocks and options that I monitor and would like a column that shows how many days I have been in that position. Meaning: the column should show 0 if the position was opened today and increment subsequently until closed (when closed it will be removed from my monitor page or watchlist). It can show "-1" or something else to show no position.

Thanks in advance for your help!


Well-known member
@walksonair Unfortunately ThinkScript has no access to your trade data. However there is a workaround.
Here is a real quick way to display the number of trading days you are in a position.
This is done by calculating the number of bar numbers since the inception of your position
Then subtract that from the current bar number and you'll get the number of trading days.
Make sure you run this on a daily chart because you'd want the number of days, otherwise no info is displayed

Here is an example. Assume you purchase AAPL on 20191007. You can change that date in the user interface
Run this study and convince yourself

# Days in Trade
# tomsk
# 11.24.2019

declare hide_on_intraday;

input acquiredDate = 20191007;

def bar = barNumber();
def pos = if getYYYYMMDD() == acquiredDate then bar else Double.NaN;
addlabel(1, "Position Initiated on " + AsPrice(acquiredDate) + "  =  " + (bar - HighestAll(pos) + " Days in Trade"), Color.PINK);
# End Days in Trade
Last edited: