Days In Trade Custom Column

walksonair

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!
 
At this time, I don’t think there is a way to incorporate current opening positions into a watchlist column.
 

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

@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

Code:
# 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:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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