Show P&L bubble on current candle In ThinkOrSwim

jetheller

New member
VIP
Here is a quick little study I created to show the current PL for any open positions on the current symbol at the top of the current candle. This is meant for day trading / scalping (may not show on higher time frames).


Ruby:
#Sase
#Add bubble above the the current candle if there is an open position
#If PL is positive then green else yellow

Def PL = GetOpenPL();
AddChartBubble (GetQuantity () != 0 and isnan(close[-1]), high, PL,If PL > 0 Then Color.GREEN Else Color.YELLOW, Yes);
 
Last edited:
Here is a quick little study I created to show the current PL for the current symbol at the top of the current candle.


Ruby:
#Sase
#Add bubble above the the current candle if there is an open position
#If PL is positive then green else yellow

Def PL = GetOpenPL();
AddChartBubble (GetQuantity () != 0 and isnan(close[-1]), high, PL,If PL > 0 Then Color.GREEN Else Color.YELLOW, Yes);
I copied and pasted the above, it does not show the bubble on the last candle. can you advise?

when I remove "GetQuantity () != 0 and" it always shows 0 at the high. when I keep the original code it does not show any bubble on any open position.

I am trading stocks. what is the time frame? is it daily or intraday

I am not sure why it does not work on my open orders for any time frame
I will check further to see why I am not seeing anything on my open orders. I created it as study and I tried various TF.
 
Last edited by a moderator:
It only shows the bubble if there is an open position on the symbol you are looking at; no open position (either long or short) then no bubble. If you want it to always show the bubble then remove "GetQuantity () != 0 and " from the code (that part of the code says when quantity is not equal to 0).

What are you trading? I use this on Stocks and Futures on the Chart in thinkorswim and it works. See image below (/ES chart)

iYbw2A6.jpg



I am on the 5 minute chart. I just checked and it works on 1 hour and smaller but not above. Not sure why, let me see if I can fix that.

Did you create it as a study? I may need more info on your setup, or you can try on a chart that doesn't have any other studies to see if there is a conflict.

This was meant for day trading / scalping so I could quickly see how I was doing and take action or not. I just logged into an account where I have long term positions to see if maybe it only works for intraday positions and that is not the case, then I thought maybe the number is too large and also not the case. See image below, I have this position for a few months, making a good amount and it also shows on the daily chart and all times frames below (for this account it doesn't show on the weekly chart).


P7UaWc5.jpg
 
Last edited by a moderator:
If there is anyone else who has tried this, please let us know if it worked for you or not.
Hi Jet
It only shows the bubble if there is an open position on the symbol you are looking at; no open position (either long or short) then no bubble. If you want it to always show the bubble then remove "GetQuantity () != 0 and " from the code (that part of the code says when quantity is not equal to 0).

What are you trading? I use this on Stocks and Futures on the Chart in thinkorswim and it works. See image below (/ES chart)

iYbw2A6.jpg



I am on the 5 minute chart. I just checked and it works on 1 hour and smaller but not above. Not sure why, let me see if I can fix that.

Did you create it as a study? I may need more info on your setup, or you can try on a chart that doesn't have any other studies to see if there is a conflict.

This was meant for day trading / scalping so I could quickly see how I was doing and take action or not. I just logged into an account where I have long term positions to see if maybe it only works for intraday positions and that is not the case, then I thought maybe the number is too large and also not the case. See image below, I have this position for a few months, making a good amount and it also shows on the daily chart and all times frames below (for this account it doesn't show on the weekly chart).


P7UaWc5.jpg
Thanks jetheller, it started working for me too.
 
Has anyone figured out why this doesn't work on daily charts? I'm using options and the studies I tried may only recognize stocks or futures.

Code:
def LastBar = !isnan(close[0]) and isnan(close[-1]);
#def PL = GetOpenPL();
def PL = GetQuantity() * close;
AddLabel(LastBar, PL, If PL > 0 then Color.GREEN else Color.RED);
 
Last edited:
Could this be amended to show the P&L of being out of the position once the position has been closed. To me, that's an equally challenging and difficult trading decision.
 
Could this be amended to show the P&L of being out of the position once the position has been closed. To me, that's an equally challenging and difficult trading decision.
Could you explain your request with a detailed example, I don't understand the request. There are other tools/places within TOS that shows P&L for closed trades.
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
393 Online
Create Post

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