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

Total dollar(Exposure amount) and P&L on Top of the chart
Is there any way we can show the below 2 real-time criteria on top of the chart?

1. If I buy 100 stocks worth $10 each then it should say -
Exposure - $1000
2. It should calculate live P&L% if stock is $11 now then -
P&L% - 10%


Thank you,
Rik
 
Last edited by a moderator:
@rikinroy
v7hrRj1.png

Code:
AddLabel(yes,"Exposure: "+GetQuantity()*GetAveragePrice()+" | P&L% "+Round((((close*GetQuantity())-(GetQuantity()*GetAveragePrice()))/(GetQuantity()*GetAveragePrice()))*100,2)+"%",color.white);
 
@rikinroy
v7hrRj1.png

Code:
AddLabel(yes,"Exposure: "+GetQuantity()*GetAveragePrice()+" | P&L% "+Round((((close*GetQuantity())-(GetQuantity()*GetAveragePrice()))/(GetQuantity()*GetAveragePrice()))*100,2)+"%",color.white);
Thank you so much. I will test it tomorrow in real time.

Appreciate it.
 
I went through all 5 pages of this thread but all of these are for charts and are not for watchlist columns or the positions tab. All I want to do is show profit each position from entry into the trade. I trade mostly options. It would be red for negative, green for positive. It does this on the mobile app. Someone's gotta have this somewhere. I even contacted TD ameritrade and they didn't have it.
 
Last edited by a moderator:
Ditto....is there an answer to this question on how to create custom columns from Portfolio Functions, ie GetNetLiq(). I want to calculate the 'position weight %' of each of my portfolio positions but there is no way to use these functions in Watchlists. Is there another way?
 
Ditto....is there an answer to this question on how to create custom columns from Portfolio Functions, ie GetNetLiq(). I want to calculate the 'position weight %' of each of my portfolio positions but there is no way to use these functions in Watchlists. Is there another way?
I've been digging around everywhere for the same and haven't found it.

Odd that these functions aren't enabled for watchlists. Simple red/green indicators for open positions are something I'm sure many would like to have.
 
I went through all 5 pages of this thread but all of these are for charts and are not for watchlist columns or the positions tab. All I want to do is show profit each position from entry into the trade. I trade mostly options. It would be red for negative, green for positive. It does this on the mobile app. Someone's gotta have this somewhere. I even contacted TD ameritrade and they didn't have it.
Ditto....is there an answer to this question on how to create custom columns from Portfolio Functions, ie GetNetLiq(). I want to calculate the 'position weight %' of each of my portfolio positions but there is no way to use these functions in Watchlists. Is there another way?
I've been digging around everywhere for the same and haven't found it.

Odd that these functions aren't enabled for watchlists. Simple red/green indicators for open positions are something I'm sure many would like to have.
The ToS platform does not make the portfolio functions available for watchlists
 
Last edited:
Average trade price on the chart
would someone please code a script to show the average trade price on the chart as a line? thinkorswim app for iphone and ipad they can show where your position is but on the desktop it doesnt show. sounds very simple but i can't code and have no idea how to make this. thanks!

This tread does not solve the problem and the ask is different.
 
Last edited by a moderator:
Average trade price on the chart
would someone please code a script to show the average trade price on the chart as a line? thinkorswim app for iphone and ipad they can show where your position is but on the desktop it doesnt show. sounds very simple but i can't code and have no idea how to make this. thanks!

This tread does not solve the problem and the ask is different.
What is the definition of Average trade price? There are scripts in this thread for Average Entry Price.
ToS platform has no data field for average sold price.
 
I know how to enter "one triggers sequence" orders. How can I get the value of a purchase made today in order to use it as part of a sell script?

For example, the sell script might be like this (if I can get code for the PurchasePrice)
# intention is to sell for 1% gain
def PurchasePrice = x;
def Sell = if close > 1.01 * PurchasePrice then 1 else 0;
 
The portfolio functions can be found here. They're very limited and basic, and there is already sample code for each posted in the manual.
 
Here's a link to the image of what that code did

Screenshot-2021-01-28-121603.png


I'm looking for something to do this with the "price level"

Screenshot-2021-01-28-121909.png
Add this to the indicator to get the price as a chart bubble.

def avgprice =(if isNaN(TRADEPRICE[-1]) then TRADEPRICE else Double.NaN);
addchartBubble(TRADEPRICE, avgprice,"Avg=$" + GetAveragePrice,color.CYAN);
 
Hi all,

First, thanks to everybody who generously shares their knowledge in this forum! This is an amazing place for traders.

I have a very simple question and I haven't been able to find an answer to it. I'm looking for a Net of Fees P/L badge for actual trades (not strategy) on the current chart. Futures comms fees are quite high on ToS especially for Micros so for small accounts Gross P/L and Net P/L may differ a lot. If it can also give stats on the trades, say winning trades, Net P/L per trade it would be great. If somebody could share any insight, they would be very much welcome!

I can enter the fees per contract manually. I get charged the same amount for every Micro i think. Something along the lines of per instrument NetDayPL=DayPnl - nr_of_trades*fees_per_trade. If there are already thinscripts that do that + other daily trading stats it would be awesome, just surprised I haven't found anything like that.

Thank you,

AB

Hi,

I was wondering if anybody could give at least a pointer at where to look for the number of trades done in a day period in Thinkscript?
P&L Labels For Charts
This script provides the P/L For Accumulated Trades
The Net PnL uses a cost adjusted basis: ProfitLossMode.COST_BASIS

These labels include
  • the total Quantity bought,
  • Average Purchase Price per share and total,
  • the Adjusted Average Sales Price per share and total
  • and the net Gain/Loss
You can edit out the fields that you don't want.
6ewhwpz.png

Ruby:
# Profit & Loss Label (on a cost adjusted basis)
# @merryday 2/2023

input PLMode = ProfitLossMode.COST_BASIS;
def PL = GetOpenPL(profitLossMode = PLMode) ;

def Entry = if GetAveragePrice() != 0 then GetAveragePrice() else Entry[1];
def GainLoss = if PL != 0 then PL else GainLoss[1];
def Qty =  if GetQuantity() != 0 then GetQuantity() else Qty[1];

DefineGlobalColor("Gain",  CreateColor(0, 165, 0)) ;
DefineGlobalColor("Loss",  CreateColor(225, 0, 0)) ;

AddLabel(GainLoss,
"Qty: " + Qty + "  Entry/shr $" + Entry + "   Exit/shr  $" + (Entry+GainLoss)
+ "  | Total Purchase: " +Qty*Entry  + "   Total Sale: " +Qty*(Entry+GainLoss)
+" | P/L: " + AsDollars(GainLoss*Qty),
      if GainLoss > 0 then GlobalColor("Gain") else GlobalColor("Loss"));
 
Goal: the Entry & P/L labels showed up as chart bubbles on the right hand side of the chart.
  • Entry bubble. both bubbles fixed 4 bars to the right of the current candle. So as the candles keep coming, there will always be at least 4 bars of separation.
  • I want the entry bubble to be fixed (naturally),
  • but the P/L bubble to be synced with the current price and move up and down accordingly.
  • The color of the bubble would change to green if profitable and red if not.

Any chance this has already been created?🤞🤞😁 I have seen a few other platforms with this feature, I'd love to have one also.
 
Last edited by a moderator:
Hello,
I am trying to create a label that will display my position and the cost basis. Unable to get the cost basis using the following:

def qty =GetQuantity();
def myCost = ProfitLossMode.COST_BASIS();
AddLabel(yes, qty + " @ " + myCost, color.WHITE);

Thanks
TK
 
I've been trying to write a script for a custom column that will provide a liquidating P/L based off the bid for long positions and ask for short positions instead of the mark price. I seem to hit a wall because the getQuantity function doesn't work for custom columns. i haven't been able to find any kind of workaround. Any help is much appreciated!!
 
I've been trying to write a script for a custom column that will provide a liquidating P/L based off the bid for long positions and ask for short positions instead of the mark price. I seem to hit a wall because the getQuantity function doesn't work for custom columns. i haven't been able to find any kind of workaround. Any help is much appreciated!!
The ToS platform does not make the portfolio functions available for watchlists
 

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