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

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

I'd like to use the following on a Forex chart (e.g., EUR/USD, or NZD/USD, etc.) But it's not working. Is there another way to get Quantity with Forex symbols?
Code:
def qty = GetQuantity();
AddLabel(yes, "Qty: " + qty, color.CYAN);
The syntax is correct. Without what chart, symbol, time aggregation, etc. It is not possible to determine where you went astray.
Most members who have similar errors are not placing the label on a Daily chart.
 
What I am looking to achieve is to plot a green arrow pointing up on the chart at the price I bought into the trade. No details about the number of shares or time or anything else. Just the arrow up at my entry on the chart, and when I sell I want to plot a red arrow pointing down at the price I sold. Think about it as the TOS price bubble/ pill but without any number of shares or price, just the red or green arrow.

Is this possible to code?
 
Last edited by a moderator:
What I am looking to achieve is to plot a green arrow pointing up on the chart at the price I bought into the trade. No details about the number of shares or time or anything else. Just the arrow up at my entry on the chart, and when I sell I want to plot a red arrow pointing down at the price I sold. Think about it as the TOS price bubble/ pill but without any number of shares or price, just the red or green arrow.

Is this possible to code?
I moved your post to this thread because there are 4 pages describing the various ways to plot THE CURRENT ACTIVE TRADES IN YOUR PORTFOLIO.

Which means your green arrow is doable on those stocks that you hold an open position.

However, there is no way to plot your red arrow. Once you exit a position, all portfolio fields reset to nan (no data).
The only remnant is the ToS built-in trade bubble which we have no access to. So we can't customize it or change its attributes.

Read through this thread for more info on your green arrow.
 
@Jony Giant @MerryDay . . . maybe this? I believe I read once that portfolio functions are limited to one year of data (please don't quote me on that) so not certain how far back in time this code will show. It appears to work for recent trades.

Code:
def x = GetQuantity();

plot start = x[1] == 0 and x <> 0;
     start.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
     start.setdefaultcolor(color.cyan);
    
plot end = x[1] <> 0 and x == 0;
     end.setpaintingstrategy(paintingstrategy.boolean_arrow_down);
     end.setdefaultcolor(color.magenta);

sample-code-plot.png
 
@Jony Giant @MerryDay . . . maybe this? I believe I read once that portfolio functions are limited to one year of data (please don't quote me on that) so not certain how far back in time this code will show. It appears to work for recent trades.
OMGOODNESS!
I was so focused on what was not there, that I never gave thought to the 'was there' and 'now is not there' state having meaning. It is so elegant! It has such potential.

This could be SUCH a game changer in our portfolio analysis capabilities. @Pensar you continually amaze!
Thank you! For sharing!
 
Last edited:
@Jony Giant @MerryDay . . . maybe this? I believe I read once that portfolio functions are limited to one year of data (please don't quote me on that) so not certain how far back in time this code will show. It appears to work for recent trades.

Code:
def x = GetQuantity();

plot start = x[1] == 0 and x <> 0;
     start.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
     start.setdefaultcolor(color.cyan);
   
plot end = x[1] <> 0 and x == 0;
     end.setpaintingstrategy(paintingstrategy.boolean_arrow_down);
     end.setdefaultcolor(color.magenta);

sample-code-plot.png
You absolute LEGEND. This is exactly what I was looking for!! This should definitely be integrated in TOS by default. THANK YOU!
PS: It looks like it plots the arrows when I open the position and when I close it, but it doesn't plot anything if I add more shares after the trade is open. Is still a huge leap though! Thank you!
 
You absolute LEGEND. This is exactly what I was looking for!! This should definitely be integrated in TOS by default. THANK YOU!
PS: It looks like it plots the arrows when I open the position and when I close it, but it doesn't plot anything if I add more shares after the trade is open. Is still a huge leap though! Thank you!
@Jony Giant If you want to show the adds/profit-takings to your position (for long positions only) add this to the code -

Code:
plot add = x > 0 and x > x[1];
     add.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
     add.setdefaultcolor(color.white);

plot subtract = x > 0 and x < x[1];
     subtract.setpaintingstrategy(paintingstrategy.boolean_arrow_down);
     subtract.setdefaultcolor(color.gray);
 
@Jony Giant If you want to show the adds/profit-takings to your position (for long positions only) add this to the code -

Code:
plot add = x > 0 and x > x[1];
     add.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
     add.setdefaultcolor(color.white);

plot subtract = x > 0 and x < x[1];
     subtract.setpaintingstrategy(paintingstrategy.boolean_arrow_down);
     subtract.setdefaultcolor(color.gray);
THANK YOU! You are a LEGEND! exactly what I was looking for. 🙏
 
Maybe I’m clueless but I have pasted numerous posts of the ”average actual entery” in this thread and still can’t get my trade price to display...I just seem to get a blue line that follows the trading price of the the particular ticker...I have bought and sold each time to make sure it had a fresh trade to apply it to. Do I need to do more than simply create a new study and paste the script in and the use it...?🤷🏻‍♂️
 
@Getyourbone I forgot to mention - the blue line you see that is following the price - it comes from the default plot Data = close; segment of code in each new study that is created. Just delete that line of code before pasting in the code you actually want.
 
I tend to do single trades with 100% of my account funds. ToS knows how much money is in my account at any time. I'd like to focus on the price of the equity I'm buying and let the system calculate how many shares I can buy with the money in my account. But I've never heard of a broker doing that for a client. Is it possible somehow? I waste a lot of time pecking at my calculator program to figure out how many shares I can buy as the price is flying around. I'm buying volatile equities where the price ramps up and down a lot.
 
@agatto2 have you enabled "Advanced Features" for your account? Also, if you are trading options, the chart needs to be that of the option ticker and not that of the underlying.
 
I tend to do single trades with 100% of my account funds. ToS knows how much money is in my account at any time. I'd like to focus on the price of the equity I'm buying and let the system calculate how many shares I can buy with the money in my account. But I've never heard of a broker doing that for a client. Is it possible somehow? I waste a lot of time pecking at my calculator program to figure out how many shares I can buy as the price is flying around. I'm buying volatile equities where the price ramps up and down a lot.
Here ya go:
LvRkW0V.png

Ruby:
def SBP = GetTotalCash () ;
AddLabel(yes,
" Total Cash = " + SBP +
"   You can buy:  " + roundDown(SBP/close,0) +" shares", Color.blue);
Note: must be run on a Daily Chart!
 
Last edited:
@Jony Giant If you want to show the adds/profit-takings to your position (for long positions only) add this to the code -

Code:
plot add = x > 0 and x > x[1];
     add.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
     add.setdefaultcolor(color.white);

plot subtract = x > 0 and x < x[1];
     subtract.setpaintingstrategy(paintingstrategy.boolean_arrow_down);
     subtract.setdefaultcolor(color.gray);
Thanks for your code, it helps a lot! Also I'm wondering if there is a way to make the arrow placed right at the price level we traded in and out? Right now they are placed either on the top of the candle or below, hard to tell the accurate price especially on a long candle.
 
Last edited:
Thanks for your code, it helps a lot! Also I'm wondering if there is a way to make the arrow placed right at the price level we traded in and out? Right now they are placed either on the top of the candle or below, hard to tell the accurate price especially on a long candle.
That is not possible. ToS doesn't provide us any portfolio information other than a P/L YTD.

@Pensar came up with this brilliant yet so simple concept. That we can use the fact that ToS does not keep any portfolio information to our favor.

What this script does, it is looks for when you were in a trade and the moment that ToS drops all that information. This script defines the "state" of your trade. In or Out. This is so cool!
 
Just wanting to share #TodayTrades watchlist/chart label. This is number of trades, can be used as liquidity indicator together with volume.
Have to check the box "including extended trading hours" in script editor.

Code:
def Trades = Fundamental(FundamentalType.TICK_COUNT);
def newDay1 = GetDay() <> GetDay()[1];
rec todaystrades = if newDay1 then trades else todaystrades[1] + trades;
AddLabel(yes,(todaystrades), (if todaystrades > 100 then Color.whITE else Color.BLACK));
plot data=todaystrades;

If someone find some mistakes please let it know.
 
This is probably a very simple feat, but I'm trying to set a reminder to myself to sell a % (roughly 25-33%) of my position after 3-5 days of purchasing it. I want to automate my strategy in the sense that having something on the screen that says "Sell" will hopefully keep my emotion out of it.

Can anyone make a label that says "Sell" after three days of making a position in an equity, and maybe having the option of changing from three days to even five days?

Thank you.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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