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

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:

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

Hi guys, I am trying to keep track of a couple different strategies of mine as a single P&L line...

For instance let say I have the following portfolio composition:

50% SPY
25% QQQ
25% IWM

How do i represent that as a single line in a TOS chart? Is that even possible?
 
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);
It seems there is a way to adapt this to show only the last entry, yes? For example, I have a stock with multiple entries over multiple days, but I am only interested in the last entry price, not the average of them all (and not including dividends). I am just not easily seeing the way to do this and my testing keeps yeilding avg cost only. Thanks for any help!
 
@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.
 
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.
 
Trying to make a column that plots the difference between my entry price and last price.

Hello! I'm trying to make a simple column that show the amount an instrument has moved from my entry price, so that I don't have to use the PnL to monitor my trades. Any help would be greatly appreciated!

Something like:

plot tradeMov = the difference between entryPrice() and pricetype.LAST()

My thinkscript skills are lacking, sry??? Thanks!
 
Last edited by a moderator:
Trying to make a column that plots the difference between my entry price and last price.

Hello! I'm trying to make a simple column that show the amount an instrument has moved from my entry price, so that I don't have to use the PnL to monitor my trades. Any help would be greatly appreciated!

Something like:

plot tradeMov = the difference between entryPrice() and pricetype.LAST()

My thinkscript skills are lacking, sry??? Thanks!
Moved your post here. You will find 5 pages of scripts that will assist in what you are looking for.
 
Trying to show account profit for the day (the entire account), using the following code. But the screen shot shows a negative profit, even though I made $75 on one trade (i.e., the P/L Day is showing a $75 gain)?
Code:
def PLToday = GetNetLiq() - GetNetLiq()[1];
AddLabel(yes, "T:" + AsDollars(GetNetLiq()) + " Y:" + AsDollars(GetNetLiq()[1]) + " P:" + AsDollars(PLToday), Color.Cyan);
2022-02-11-07-54-00.jpg
 
Trying to show account profit for the day (the entire account), using the following code. But the screen shot shows a negative profit, even though I made $75 on one trade (i.e., the P/L Day is showing a $75 gain)?
Code:
def PLToday = GetNetLiq() - GetNetLiq()[1];
AddLabel(yes, "T:" + AsDollars(GetNetLiq()) + " Y:" + AsDollars(GetNetLiq()[1]) + " P:" + AsDollars(PLToday), Color.Cyan);
2022-02-11-07-54-00.jpg
Needs to be posted on a daily chart.

Keep in mind that it is "NET Liquidity" so it will match your account statement and include things like fees, dividends, etc... as well as gains and losses
 
Hi Everyone,

I'm trying to get my profit and loss to show colors in the text like the LAST price does so I can see quickly if I'm up or down on a position under the Monitor/positions tab.

RED for negative/loss ($)
GREEN for positive/profit $

Does anyone know how to do this?
 
Moved your post here. You will find 5 pages of scripts that will assist in what you are looking for.
Thank you Merry Day but I can't find anywhere in this where it shows how to color code the monitor Positions tab. What is strange is that it does it automatically under the mobile app. Can you show me how to do this or send me the script. I would really appreciate it. I checked your link but it brought me back to this thread.
 
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:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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