any code workarounds for this?

I am looking to use the getquantity() function to actively show whether I'm in a position or not. My issue is that this function does not work with tick charts. This code below uses entryprice() but it only recognizes if I am in a position after the bar closes, not in real-time.

Would anyone know how to solve this?

Code:
def entry = EntryPrice();

def entryPrice = if !IsNaN(entry)
                 then entry
                 else entryPrice[1];

plot hasEntry = !IsNaN(entry);
hasentry.setpaintingStrategy(paintingStrategy.boolean_ARROW_UP);
 
Solution
I tried doing a workaround with entryprice as well but I haven't been able to figure out a way to get a real-time indicator of whether I am in a position or not - using tick charts.
The ToS documentation states that the portfolio functions work on time frames only. They function on all timeframes hourly and lower and on the daily timeframe.
There is not a way to determine whether you are in a position or not without using the portfolio functions.
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Portfolio
WByOa8y.png
If instead of using the getquantity(), how about using getopenPL()? it will show you your active PL so !isnan(GetOpen()) should tell you if you're in a position or not. I haven't tested this though.

def PLOpen = GetOpenPL();
AddLabel(qty <> 0, "P/L: " + AsDollars(PLOpen),
if PLOpen == 0 then Color.LIGHT_GRAY else if PLOpen > 0 then Color.GREEN else Color.RED);
 

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

If instead of using the getquantity(), how about using getopenPL()? it will show you your active PL so !isnan(GetOpen()) should tell you if you're in a position or not. I haven't tested this though.

def PLOpen = GetOpenPL();
AddLabel(qty <> 0, "P/L: " + AsDollars(PLOpen),
if PLOpen == 0 then Color.LIGHT_GRAY else if PLOpen > 0 then Color.GREEN else Color.RED);

Hi this did not work for me. I think GetOpenPL() is also a portfolio function and will not show up on a tick chart
 
I tried doing a workaround with entryprice as well but I haven't been able to figure out a way to get a real-time indicator of whether I am in a position or not - using tick charts.
 
I tried doing a workaround with entryprice as well but I haven't been able to figure out a way to get a real-time indicator of whether I am in a position or not - using tick charts.
The ToS documentation states that the portfolio functions work on time frames only. They function on all timeframes hourly and lower and on the daily timeframe.
There is not a way to determine whether you are in a position or not without using the portfolio functions.
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Portfolio
WByOa8y.png
 
Solution

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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