Portfolio Functions Not Working

EddieM

New member
Plus
I have this working in paper money it shows me the PL live as I am trading. Shows my money up or down in green or red and my buy in amount I am at. Th gray area title on the end.
But now I moved to live trading and it is not working? Even the time in is not working but it all still works in paper trading.

How can I get it working in live trading?

It is this part that is not working it seems - it just stays gray no matter what with no numbers showing and the time in is not changing to the current buy in time as it dose in paper money working right.
_______________
AddLabel(1, "Qty: " + GetQuantity() +
" Avg $" + Entry +
" P/L: " + AsDollars(PL) + " Max L: " + AsDollars(Entry * GetQuantity()),
if PL == 0 then Color.GRAY
else if PL > 0 then Color.GREEN
else Color.RED);

addlabel(1,
" In: " + ( barssince * chartmin) + " minutes",
if GetOpenPL() > 0 then Color.yellow else Color.yellow);
__________________________

Screenshot 2024-11-14 at 10.27.31 AM.png


Here is the share link
https://tos.mx/!IhORQ6dE

--------------------
#PL_label_days2

#https://usethinkscript.com/threads/changes-days-to-minutes-in-p-l-label.19791/#post-146834
# Average Actual Entry
# Mobius
# 01.01.2018

# Removed portions of Mobius' code, added quantity and replaced Mobius' P/L
# calculation with GetOpenPL().
# Color-coded label, edited study look/colors for personal preference

def na = double.nan;
def bn = barnumber();

# get chart agg time
def chartagg = GetAggregationPeriod();
def chartmin = chartagg / (1000 * 60);

input use_line_limits = yes;#Yes, plots line from/to; No, plot line across entire chart
input linefrom = 100;#Hint linefrom: limits how far line plots in candle area
input lineto = 12;#Hint lineto: limits how far into expansion the line will plot

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 LastEntryBar = if Entry != Entry[1] then bn else LastEntryBar[1];

def barssince = bn - lastentrybar;

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

plot "1% Stop" = if Entry_ then Entry_ - .01 * Entry else Double.NaN;
"1% Stop".SetDefaultColor(Color.RED);

plot "1% Target" = if Entry_ then Entry_ + .01 * Entry else Double.NaN;
"1% Target".SetDefaultColor(Color.GREEN);

plot "10% Target" = if Entry_ then Entry_ + .10 * Entry else Double.NaN;
"10% Target".SetDefaultColor(Color.YELLOW);

plot "15% Target" = if Entry_ then Entry_ + .15 * Entry else Double.NaN;
"15% Target".SetDefaultColor(Color.MAGENTA);

plot "20% Target" = if Entry_ then Entry_ + .20 * Entry else Double.NaN;
"20% Target".SetDefaultColor(Color.RED);

input balance = 1000;
def current_price = close;
def limit = balance / current_price;

AddLabel(yes, Concat("Money = ", RoundDown(balance)), Color.MAGENTA);
AddLabel(yes, Concat("Can buy: " , RoundDown(limit)) + " Shares", Color.WHITE);

AddLabel(1, "Qty: " + GetQuantity() +
" Avg $" + Entry +
" P/L: " + AsDollars(PL) + " Max L: " + AsDollars(Entry * GetQuantity()),
if PL == 0 then Color.GRAY
else if PL > 0 then Color.GREEN
else Color.RED);

addlabel(1,
" In: " + ( barssince * chartmin) + " minutes",
if GetOpenPL() > 0 then Color.yellow else Color.yellow);

I know a trade needs to be going. This works in paper trading but not in the live trading.

Still not working here is a screen shot of the active trade and then the item not working. On the same timeline as in paper trading that it works in - its the same chart setup.

Also the timeframe link provided in the reply post is not working to see anything.

Page not found​


Screenshot 2024-11-20 at 9.31.20 AM.png


Screenshot 2024-11-20 at 9.31.57 AM.png

Chart link
https://tos.mx/!gV7TvkxM
 

Attachments

  • Screenshot 2024-11-14 at 10.10.56 AM.png
    Screenshot 2024-11-14 at 10.10.56 AM.png
    94.6 KB · Views: 35
Last edited:
Solution
The BID ASK SPREAD and Diff label is not part of the script that you provided.
So those fields do not appear, because they are not in the script.

The rest of your script does work for VALID TRADES THAT ARE CURRENTLY OPEN!
For example, here is my monitor tab. It shows an open trade for AAPL
mo52ot0.png


Here is the AAPL chart with your script working correctly:
tMZvTtu.png


You did not provide an image of your monitor tab indicating that your trade is currently open.
Portfolio labels only work when there is an open trade.

Here is the link to everything you want to know about portfolio functions.
https://usethinkscript.com/threads/portfolio-functions-in-thinkorswim.11485/
Yes...
The BID ASK SPREAD and Diff label is not part of the script that you provided.
So those fields do not appear, because they are not in the script.

The rest of your script does work for VALID TRADES THAT ARE CURRENTLY OPEN!
For example, here is my monitor tab. It shows an open trade for AAPL
mo52ot0.png


Here is the AAPL chart with your script working correctly:
tMZvTtu.png


You did not provide an image of your monitor tab indicating that your trade is currently open.
Portfolio labels only work when there is an open trade.

Here is the link to everything you want to know about portfolio functions.
https://usethinkscript.com/threads/portfolio-functions-in-thinkorswim.11485/
Yes, it is a working link.
 
Solution
I did provide the screen shot here is another of the monitor tab with open order
Screenshot 2024-11-20 at 10.26.51 AM.png


Here it is in paper trading it works but will not work on my live chart..
Screenshot 2024-11-20 at 10.34.39 AM.png


It also in paper trading shows the white line to the right at the buy in point as seen here.
Screenshot 2024-11-20 at 10.37.35 AM.png
 

Attachments

  • Screenshot 2024-11-20 at 10.33.48 AM.png
    Screenshot 2024-11-20 at 10.33.48 AM.png
    98.6 KB · Views: 5
As stated, the script works as required.
No, you never provided your activities and position image showing that the trade still has a p/l open amount.
You only provided images that an order was placed at some point.
But you never provide an image of the current status of the trade.
The assumption is that you do not have a current open trade therefore the portfolio functions cannot provide any data.


Bottom line as @MerryDay indicated above. There is no coding or syntax issue.
The code does work. And yes, it provides the requisite labels and lines.
Therefore, the forum cannot provide any further assistance.

The forum is not affiliated with Schwab.
You need assistance from Schwab to determine if you have open trades and then why they are not displayed on your charts.
 
As stated, the script works as required.
No, you never provided your activities and position image showing that the trade still has a p/l open amount.
You only provided images that an order was placed at some point.
But you never provide an image of the current status of the trade.
The assumption is that you do not have a current open trade therefore the portfolio functions cannot provide any data.


Bottom line as @MerryDay indicated above. There is no coding or syntax issue.
The code does work. And yes, it provides the requisite labels and lines.
Therefore, the forum cannot provide any further assistance.

The forum is not affiliated with Schwab.
You need assistance from Schwab to determine if you have open trades and then why they are not displayed on your charts.
The screen shots I provided are how mine shows up on Mac in both paper trading and live trading to show a open order.
I have no view that looks like the one that was posted by MerrryDay that I can find anyplace in my monitor area to show?
 
At this point, given that, the script does work; and you are still having issues.
You will have to contact Customer Support.

Suggestion: As Customer Support does not provide support for custom scripts.
You should ask why the ToS function quantity() is not displaying in a label.

When you have a simple quantity displaying; your custom scripts should also work.
 

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