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

I could really use that feature, could you advise on how to enter the code? I use a mac so would I just open a monitor and cut ans paste the code?
Thanks for the help

I am curious what I am doing wrong, I go to setup - application settings - my profile, but there are no "advanced features" to enable or disable?
 
Last edited by a moderator:

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

@desertskies

The code below will place a label on your chart with your entry point plus gives you a label for your pesent Profit or Loss on the trade. You would simply paste this code into a new indicator and you are set to go.
I have found this to be the easiest/most relaibel way to track the entry.

On a chart you would click the Studies icon at the top of the chart, then "edit sudies", then "create".....give your new study a name you will remember, and paste the code below into it. Add it to you chart and you should be good to go.

Code:
def EP = Round(GetAveragePrice(), 2);
def PrLs = GetOpenPL();
def UPDN = EP + GetOpenPL();
AddLabel (yes, "Entry: " + EP, Color.CYAN);
AddLabel (if UPDN <> EP then yes else no, "PrLs: $" + PrLs , if UPDN > EP then Color.GREEN else Color.RED);
 
@Pensar I'm wondering if there's a way to plot lines indicator to let you get out at 5% Stop loss and/or at 10% gain. Idk if @BenTen knows the code to add that? Unless there's already a post on here that I missed.
 
I'm wondering if there's a way to plot lines indicator to let you get out at 5% Stop loss and/or at 10% gain. Idk if @BenTen knows the code to add that? Unless there's already a post on here that I missed.
@AnakManis Try adding this code snippet to the code you quoted above. It will only display when you are in a trade.

Code:
plot "5% Stop" = if Entry_ then Entry_ - .05*Entry else double.nan;
     "5% Stop".SetDefaultColor(color.red);

plot "10% Target" = if Entry_ then Entry_ + .10*Entry else double.nan;
     "10% Target".SetDefaultColor(color.green);
 
@wcsharron Glad you liked it! No payment needed, but if you want, you could pick up a VIP membership here at usethinkscript. :)
@Pensar, I must be the one unlucky soul who is having trouble with this. It does nit show up on my charts.
Are there any requirements, like restarting TOS, or having the study applied at the tune of the trade?
 
@Kylep19 - The lines will only show on the chart when you enter a trade, but there should be a cyan colored label showing in the upper left corner of your chart.
 
Yes, I have tried on charts with positions held. If it helps to indicate something, the cyan label on my chart is black. I can barely read the font in the negative space.
 
@Kylep19 If you are testing it in PaperMoney, it may have problems showing. Someone else I know of had that problem, but after a while the indicator worked again. I have no idea why, maybe the portfolio functions used are not supported in PaperMoney, but I'm just guessing here.
 
@Kylep19 Maybe try this code, although I think it's the same as in post #19. I'm running it now, and its working fine -

Code:
# Average Actual Entry
# Mobius
# 01.01.2018

# Pensar @ usethinkscript.com
# Removed portions of Mobius' code, added quantity and replaced Mobius' P/L
# calcuation with GetOpenPL() to show P/L more accurately.
# Color-coded label, edited study look/colors for personal preference

def PL = GetOpenPL();
def c = if isNaN(close[-1]) then close else c[1];
def Entry = if isNaN(GetAveragePrice()) then Entry[1] else GetAveragePrice();
def LastEntryBar = if Entry != Entry[1] then barNumber() else LastEntryBar[1];

plot Entry_ = if barNumber() >= HighestAll(LastEntryBar) and Entry > 0
              then highestAll(if isNaN(close[-1]) then Entry else double.nan) else double.nan;
     Entry_.SetStyle(Curve.FIRM);
     Entry_.SetLineWeight(1);
     Entry_.SetDefaultColor(color.BLUE);
     Entry_.HideBubble();
     Entry_.HideTitle();

plot "5% Stop" = if Entry_ then Entry_ - .05*Entry else double.nan;
     "5% Stop".SetDefaultColor(color.red);

plot "10% Target" = if Entry_ then Entry_ + .10*Entry else double.nan;
     "10% Target".SetDefaultColor(color.green);

AddLabel(1, "Qty: " + GetQuantity() +
         "   Avg $" + Entry +
         "   P/L: " + AsDollars(PL) + "   Max L: " + AsDollars(Entry*GetQuantity()),
         if PL == 0 then color.gray
         else if PL > 0 then color.green
         else color.red);

# end code
 
@Pensar, thanks for the info. It is still acting the same, and no paper account usage here. The odd thing is the cyan box you mentioned being blacked out on my screen, yet still there. Oh, and I tried the most recent script, same thing.
odd.
Here is a what the indicator tile looks like. Note, all the NaN values. This is on a live account chart I have been holding a position in since Yesterday.
https://www.screencast.com/t/DAFf4GQlwdk
 
Last edited:
@Pensar, thanks for the info. It is still acting the same, and no paper account usage here. The odd thing is the cyan box you mentioned being blacked out on my screen, yet still there. Oh, and I tried the most recent script, same thing.
odd.
Sounds like it could possibly be a platform problem . . . did you try contacting TOS support?
 
Sounds like it could possibly be a platform problem . . . did you try contacting TOS support?
I did not, yet. Figured they would shy away from 3rd party script issues. I have been searching my parameters for something I may have changed myself, but no luck so far.
When I go to Chart Settings>General>Show Trades, my entries don't show up in the native format either. This would normally indicate something I've changed in my custom chart settings but searching online, this native entry indicator has been having issues as well.
I am actually very surprised this isn't just a part of TOS out of the box, as it seems many folks are.
 
I am a new member and my first to share. I wrote two simple labels that would show on top of the chart as a label. I trade Equities.

Code:
#Code 1
# Portfolio Functions Label to display in the chart

def GetAveragePrice = GetAveragePrice();
def GetQuantity = GetQuantity();
def TargetPrice = Round((GetAveragePrice * .10) + GetAveragePrice); # Change Percent you wish as target price.
def pgain = if GetAveragePrice != 0 then close - GetAveragePrice else 0;

AddLabel(yes, " Pos: " + GetQuantity
       + " | Avg Price: $" + Round(GetAveragePrice)
        + " | Exit (10%) Price: $ " + TargetPrice
         + " | Price Gain: $ " + Round(pgain) + " "
            , if pgain > close then Color.green else Color.light_green);

#end of Code 1

#Code 2
# Profiting or Losing on Chart
# if Profiting background label to Green with $ amount
# if Losing background label to Light_Red with $ amount

def GetOpenPL = GetOpenPL();

AddLabel(yes, " P/L: $ " + Round(GetOpenPL) + " "
            , if GetOpenPL > 0 then Color.green else Color.light_red);

#end of Code 2

I hope that helps. Please let me know how if it works for you.

cabe1332
 
Last edited:
Thanks cabe1332 for the formula for "P/L:" That seems to get me the profit from Opening the position. Do you have a calculation to get the "P/L Day:"?
 
@epete I really did not need P/L Day since I really don't average into a position. When I enter I just let it ride. What I did though is add a percent to the P/L label. I feel that is more lucrative for me to take profits at a certain price range. Sorry about that.

Code:
# code
# Label if Profiting or Losing

def GetOpenPL = GetOpenPL();
def GetAveragePrice = GetAveragePrice();
def AvgPrice = if GetAveragePrice != 0 then close - GetAveragePrice else 0;

AddLabel(yes, " P/L: $ " + Round(GetOpenPL) + " | "  
        + (round((AvgPrice/GetAveragePrice)*100,2) + " %")
        , if GetOpenPL >= 0 then Color.green else Color.light_red);

# end code

Good luck!

cabe1332
 
@rlohmeyer TY for the great study..I use it everyday!! Is it possible to make for a watchlist...just so I don't have to cycle through trades all the time...Thank you again for this!!
 
@kmg526 There are Portfolio Watchlist functions that can be added to track Open P/L, Days P/L for each position, and others. Click settings to add a column and look under Portfolio. Here is a screen shot of the list. I am using the code previously shared on this discussion to show entry lines on your chart listed in post 19 by @wcsharron . I've posted it again below the screen shot. It was done by Mobius originally, a wizard coder.

oA70LkT.jpg


Code:
# Average Actual Entry
# Mobius
# 01.01.2018

# Removed portions of Mobius' code, added quantity and replaced Mobius' P/L
# calculation with GetOpenPL().
# Color-coded label, edited study look/colors for personal preference

def PL = GetOpenPL();
def c = if isNaN(close[-1]) then close else c[1];
def Entry = if isNaN(GetAveragePrice()) then Entry[1] else GetAveragePrice();
def LastEntryBar = if Entry != Entry[1] then barNumber() else LastEntryBar[1];

plot Entry_ = if barNumber() >= HighestAll(LastEntryBar) and Entry > 0
              then highestAll(if isNaN(close[-1]) then Entry else double.nan) else double.nan;
     Entry_.SetStyle(Curve.SHORT_DASH);
     Entry_.SetLineWeight(3);
     Entry_.SetDefaultColor(color.BLUE);
     Entry_.HideBubble();
     Entry_.HideTitle();

AddLabel(1, "Qty: " + GetQuantity() + 
         "   Avg Cost $" + Entry +
         "   P/L: " + AsDollars(PL),
         if PL == 0 then color.cyan
         else if PL > 0 then color.green 
         else color.red);
# end code
 
Hi all, this is my finding when I tried to enable 'Show trade" on Thinkorswim".
I could not get the trades shown although I have the "show trade" checked on chart setting.
Solution used to be to go to TD Ameritrade site and enable "Advanced Features", now this option is not available and you won't be able to find "Advanced Features" on the website, so you need to request through Thinkorswim representative and it needs to go through an overnight update. The only down side is that your transaction history in ThinkorSwim will be wiped, however it's still available on the TD Ameritrade website(tdameritrade.com). My account > history & statements > transcations.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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