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

@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. 🙏
 

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

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.
 
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.
This should do it:
Ruby:
# Crude Buy Sell Zone indicator by ANTHDKN 06.04.2021
# Free to use to all
# First posted on usethinkscript.com
# Auto entries from positions
input days = 3 ;
def avg = getaveragePrice();
def AreYouIn = if getquantity() != 0 then yes else no;

def Entry = if isNaN(avg) then Entry[1] else avg;
def LastEntryBar = if Entry != Entry[1] then barNumber() else LastEntryBar[1];
def BuyBarsAgo = if barNumber() != LastEntryBar
                 then barNumber() - LastEntryBar
                 else if barNumber() == LastEntryBar
                      then Double.NaN
                 else BuyBarsAgo[1];


AddLabel(AreYouIn,
         "Cost: " +round(avg,2) +
         (if GetOpenPL() > 0
         then " | "+ "P/L: $" + GetOpenPL() +
              " | "+ aspercent(getopenPL() / (avg *  getquantity()))
         else " | "+ "P/L: -$" + GetOpenPL() +
              " | "+ aspercent(getopenPL() / (avg *  getquantity())))
         +    " | "+ " Bought: " +BuyBarsAgo +" days ago"
         +(if BuyBarsAgo >= days then "  SELL" else " "),                
                 if GetOpenPL() > 500
         then Color.cyan
         else    if GetOpenPL() > 0
         then Color.DARK_GREEN
         else Color.DARK_RED);

plot avgprice = if avg != 0  then avg else double.nan;
avgprice.setstyle(curve.SHORT_DASH);
avgprice.setdefaultColor(color.Yellow);
 
Last edited:
What is the script should I type to exclude the stocks that was in my positions (either I sold them or still in my positions) in the last three months (90 days), from the scanner results?

can I use GetQuantity(), for example only show results if the sum of GetQuantity(),GetQuantity([1]),GetQuantity([2])....GetQuantity([30]) is zero
 
Last edited by a moderator:
What is the script should I type to exclude the stocks that was in my positions (either I sold them or still in my positions) in the last three months (90 days), from the scanner results?

can I use GetQuantity(), for example only show results if the sum of GetQuantity(),GetQuantity([1]),GetQuantity([2])....GetQuantity([30]) is zero
With enough scripting knowledge you 'might' be able to write a complex script.

You are facing several uphill issues:
Many members track their trades in spreadsheets. Making it an easy task to import the symbols to include / exclude from their scans.
 
With enough scripting knowledge you 'might' be able to write a complex script.

You are facing several uphill issues:
Many members track their trades in spreadsheets. Making it an easy task to import the symbols to include / exclude from their scans.

in spreadsheets (it is my first time to try it), will the symbols I add in excel be automatically synced with tos, or I should import/export the file manualy everyday? and should both tos and excel file be opened at the same time?
 
in spreadsheets (it is my first time to try it), will the symbols I add in excel be automatically synced with tos, or I should import/export the file manualy everyday? and should both tos and excel file be opened at the same time?
I am not making hundreds of trades a day, so I create my spreadsheet entries manually.
 
@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);


This is incredible. Works perfect for me on longs. Is there a way we can make a duplicate study to show shorts? I tried swapping the adds/subtractions as negatives because I assumed a short has a negative count, but that doesn't seem to work. Any insights?

EDIT: okay seems it does actually work. Not sure why it didn't at first.


Code:
def x = GetQuantity();


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

plot add = x < 0 and x < x[1];
     add.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
     add.setdefaultcolor(color.red);

plot subtract = x < 0 and x > x[1];
     subtract.setpaintingstrategy(paintingstrategy.boolean_arrow_down);
     subtract.setdefaultcolor(color.green);

plot end = x[1] <> 0 and x == 0;
     end.setpaintingstrategy(paintingstrategy.boolean_arrow_down);
     end.setdefaultcolor(color.green);
 
Last edited:
Any way to get P/L on a range chart (i.e., a Renko Chart)? I know that portfolio fuctions such as GetQuantity() don't work on range charts.
 
Any way to get P/L on a range chart (i.e., a Renko Chart)? I know that portfolio fuctions such as GetQuantity() don't work on range charts.
Portfolio functions work on:
1min, 2min, 3min, 4min, 5min, 10min, 15min, 20min, 30min, 1hr, and daily charts only.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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