GetQuantity stuck

zgdesign

New member
Hello,
I'm hoping someone can help with an issue I'm having.
I have a simple study that shows a label on the chart with the quantity of shares I have, either long or short.
Randomly it just gets stuck, and I'm not sure if it's on the Ameritrade side or the TOS side.
For example, a couple of months ago I exited a short position on NIO, but the quantity still shows -3. I've tried everything but it won't reset.
However if I have active trader open, I see that the position is flat.
If I make another trade, let's say 50 shares long, I will see 47 on the chart, because it's subtracting the -3 shares that are stuck in the system.
Does anyone know how to reset the GetQuantity() total?
Thanks

There's really not much to the study, here it is below:


def PL = GetOpenPL();
def c = if IsNaN(close[-1]) then close else c[1];
def Entry = if IsNaN(GetAveragePrice()) then Entry[1] else GetAveragePrice();
def openCost = GetQuantity() * GetAveragePrice();
def PercentPL = GetOpenPL() / AbsValue(openCost) * 100;
def LastEntryBar = if Entry != Entry[1] then BarNumber() else LastEntryBar[1];

plot Entry_ = if BarNumber() >= HighestAll(LastEntryBar) and Entry > 0
then HighestAll(if IsNaN(close[-1]) then Entry else Double.NaN) else Double.NaN;
Entry_.SetStyle(Curve.FIRM);
Entry_.SetLineWeight(1);
Entry_.SetDefaultColor(Color.WHITE);
Entry_.HideBubble();
Entry_.HideTitle();

AddLabel(1, "Q" + GetQuantity() +
" A$" + Entry +
" A%" + PercentPL + "%" +
" T$" + openCost +
" P " + AsDollars(PL),
if PL == 0 then Color.CYAN
else if PL > 0 then Color.GREEN
else Color.RED);

# end code
 
I'm having the same problem. getquantity() is hozed. Looks like a bug in tos.

In my case, it keeps returning -100 as though I'm short 100 shares when in reality I'm flat. Apparently, at some point after a buy order, getquantity() returned 100 shares less than my actual buy size. The closing sell order quantity was registered accurately leaving a net -100 short position per getquantity(). Further, getaverageprice() also returns a non zero value even though there isn't an open position.

Did you connect with tos on this?

Anybody else here having similar issues with getquantity() and getaverageprice()?


Hello,
I'm hoping someone can help with an issue I'm having.
 
Last edited:
Likely they have 2 different systems that track positions. One is accurate which feeds into the "activity and positions" tab in tos and the other a buggy one which feeds into thinkscript funcs. At the least, I had expected the buggy one to get reset overnight to reflect the positions per the accurate records one, but no such thing.

I haven't gotten a chance to contact AMTD regarding the issue, but the quantities are still stuck and I haven't found a fix.
 
The glitch disappeared over the w/e, perhaps those 2 accurate/inaccurate systems got synced up.

I've had this issue in the past and it had disappeared the next day. I had not noticed what day it was then since it was the first instance of observing the glitch.

This past time it showed up on a thur and was still present on friday. So its possible that perhaps the syncing does not happen everyday, but does happen over the w/e.

Likely they have 2 different systems that track positions. One is accurate which feeds into the "activity and positions" tab in tos and the other a buggy one which feeds into thinkscript funcs. At the least, I had expected the buggy one to get reset overnight to reflect the positions per the accurate records one, but no such thing.
 
This glitch reappeared this wk as well. This time for 18 shares long when I'm flat. Incidentally, one of the partial fills on the sell order was for 18 shares. It showed up on tue and hung around for couple of days and had disappeared on fri am. So it gets wiped out whenever (not necessarily over the weekend, but not every night either).

The glitch disappeared over the w/e, perhaps those 2 accurate/inaccurate systems got synced up.

I've had this issue in the past and it had disappeared the next day. I had not noticed what day it was then since it was the first instance of observing the glitch.

This past time it showed up on a thur and was still present on friday. So its possible that perhaps the syncing does not happen everyday, but does happen over the w/e.
 
Last edited:

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