Entry, Target, Profit Loss (PnL) Watchlists, Labels of Owned Equities In ThinkOrSwim

Hello all,

I noticed some useful features on my Webull app that are missing in Thinkorswim. I have attached an image to check if its possible to add these feature on TOS windows program.

1. I would like to see: Profit/Loss dollar estimate on the chart. This changes dynamically as I move the stop loss or take profit level (OCO order).

yInMhjJ.jpg


2. I also want to see my Point of sale (POS) listed on the chart. Once my order fills, there is no mark on TOS chart to see at what level my stock was purchased at. I have to go to monitor tab or order entry to see my Trade price. I attached an image of how POS appears on Webull.

2j0RzFb.jpg


Thank you
 
Last edited by a moderator:

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

Thanks for the quick reply. I have tried Show trades before but its not accurate. It places a price bubble with arrow pointing to candlestick but its not the actual price level. I have to go back with price level tool to place a line at point of purchase. For example, I bought AAPL at 379.87 but the arrow points no where near 379.87. Also it shows all my previous trades which clutters up the screen if I buy and sell multiple times in a day. I have attached a screenshot of my TOS. It will be nice if it showed only the current POS price level on the chart.

U5Purd1.jpg
 
Last edited by a moderator:
@kalyan Try this code by Mobius -

Code:
# Plotting Average Actual Entry
# Mobius
# 01.01.2018

input HardStop = 3.00;
input Dir = {default long, short};

plot hide = double.nan;
     hide.setDefaultColor(Color.Black);
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 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.Long_Dash);
     Entry_.SetLineWeight(3);
     Entry_.SetDefaultColor(CreateColor(255,215,0));
     Entry_.HideBubble();
     Entry_.HideTitle();
def PL = if Entry > 0 then Entry - c else 0;
AddChartBubble(barNumber() == HighestAll(barNumber()), Entry_, "AVG " +AsDollars(Entry), Entry_.TakeValueColor());
#Alert(c crosses below Entry, "", Alert.Bar, Sound.Chimes);
#Alert(c crosses above Entry, "", Alert.Bar, Sound.Ring);
plot stop;
switch (Dir)
{
case long:
    stop = Entry_ - HardStop;
case short:
    stop = Entry_ + HardStop;
}
#Alert(close crosses stop, "STOP", Alert.Bar, Sound.Bell);
# End Code

Also, try creating a watchlist and select "current account positions". Then, choose your desired columns, such as "Avg Price", "P/L %", "P/L Open", etc.
 
Thank you for the code. It is working great for the POS. I dont see "current account positions" under New watchlist.

Thanks again

iTEBZ6h.jpg
 
Still hunting. For clarity, TOS can show you the price of a purchase and sale in the platform....it has the green arrow up or down for Sale.

I am looking for something similar to when you have an order in place that shows the horizontal line of the trade executed.

Thanks!
 
Last edited by a moderator:
@wcsharron Maybe look at this post, or you could try the modified code below that I have lately been using.
Note: Please ensure that the below study plots correctly before using.

Code:
# 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 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 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.SHORT_DASH);
     Entry_.SetLineWeight(3);
     Entry_.SetDefaultColor(color.BLUE);
     Entry_.HideBubble();
     Entry_.HideTitle();

AddLabel(1, "Qty: " + GetQuantity() +
         "   Avg Cost $" + Entry +
         "   P/L: " + AsDollars(PL),
         if PL == 0 then color.cyan
         else if PL > 0 then color.green
         else color.red);
# end code
 
Last edited:
I also have this problem. It works properly in paper trading, but I only get N/A in real trading. Anyone know why that might be?
 
I had the same problem, getAveragePrice was always "N/A". I contacted support via live chat and they immediately pointed me to the "Advanced Features" setting which needs to be enabled: Ameritrade.com > Client Services > My Profile > General > Advanced Features
It took a few hours to kick in, but now I get the correct values from the Portfolio functions. (y)
 
I had the same problem, getAveragePrice was always "N/A". I contacted support via live chat and they immediately pointed me to the "Advanced Features" setting which needs to be enabled: Ameritrade.com > Client Services > My Profile > General > Advanced Features
It took a few hours to kick in, but now I get the correct values from the Portfolio functions. (y)
Ha! I also figured this out a couple days ago (I think I turned it on the day I posted my reply), but forgot to update this chain. It also fixes "Show Trades" and my mobile alerts. Been a life saver. Google should have this answer more readily!

Thanks!
 
Hi Gang,

This is just what I was looking to add to my charts... Why TOS doesn't have this feature is beyond me....

To take this feature 1-step further, is there any way to add the "P/L Percentage" in parenthesis to the right of the P/L dollar figure? 🤔
 
@evanevans You mentioned creating an P/L cloud in another thread based on the average cost. Here is a snippet for adding a P/L cloud to this code, may want to test it before using. I ran it today in PaperMoney to test the cloud plots.

Code:
input show_cloud = yes;
def up = if PL > 0 then Entry_ else double.nan;
def dn = if PL < 0 then Entry_ else double.nan;
AddCloud(if show_cloud then up else double.nan,hl2,color.green, color.green);
AddCloud(if show_cloud then dn else double.nan,hl2,color.red,color.red);

hLV2kFQ.png
 
I want to display a simple P/L open label on an upper chart and have the following code:

Code:
def PLOpen =  GetOpenPL();

AddLabel (yes, "P/L: " + if ( PLOpen >= 0 ) then PLOpen else PLOpen, if PLOpen > 0 then Color.Black else Color.Red);
# if PL > 0 then CreateColor(0,0,0) else CreateColor(255,0,0);

Instead of displaying "0" if there is no open position, the chart label doesn't show up at all and in its place there is a small error icon (an exclamation point in a circle) on the chart. This is going to be visually distracting to have the label pop in and out of existence based on the existence of a temporarily open position. Is there a simple way to structure an if/then/else or other type of conditional to cause "0" or "No Position" to display when GetOpenPL is returning a null value (ideally, in this case I'd also like the color of the label to be gray instead of red or black - I haven't figured out a way to have three potential label colors either, only two based on if/then/else)?
 
Last edited:
@lmk99 Is this more what you are looking for...??? The label should only display if there is an open trade...

Code:
def PLOpen =  GetOpenPL();

AddLabel (GetQuantity() > 0, "P/L: " + AsText(PLOpen, NumberFormat.DOLLAR), if PLOpen > 0 then Color.GREEN else if PLOpen < 0 then Color.RED else Color.GRAY);
 
Last edited:
@rad14733 The label wasn't displaying before because the 8 minute aggregation period wasn't supported for Portfolio functions. It works on the 5min chart. I want the label to indicate no position instead of disappearing when there's no open position, so it's OK for my purposes that it currently shows "P/L Open: 0" in that case. However I really appreciate your improvement of using "NumberFormat.DOLLAR" - thanks for that, I have made that update to my code!
 
I also use a snippet of code in another script I have on my charts that draws a line at my entry point. I plot it as dots rather than a line. Once I am out of the trade on a specific bar, I can easily tell which bar I exited on. See jpg below and code beneath.

What I was hoping to find was how to change the color of the line based on whether I entered short or long. Anyone have suggestions?

WWhJOnD.jpg


Code:
#Entry Line
declare upper;
def EP = Round(GetAveragePrice(),2);
Plot EntryLine = EP;
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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