Show trades on ThinkorSwim chart screen?

wcsharron

New member
VIP
Does anyone know how to add a line that shows purchases / Shorts on the screen, similar to how they show on the mobile screen? So it would show a line that extends right at the purchase prices.

Any help is greatly appreciated. By the time i draw a manual line i am sometimes out of the trade.
 
Solution
@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);

Pensar

Well-known member
VIP
@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.
 

Pensar

Well-known member
VIP
@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
 

Kylep19

New member
@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

Well-known member
VIP
@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?
 

Kylep19

New member
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.
 

rlohmeyer

Active member
VIP
@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
 

SAA448

New member
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.
 

marmalade

New member
@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?
I had this issue too, and ended up having to apply for futures trading abilities to get advanced features, and now the script works!
 

Angry_Raven

New member
Can someone please help me make a script that will automatically place a "Price Level" drawing connected to the candle\time when I buy into a position? When I buy into a stock, I like to draw a price line to the candle\exact price so I can visualize how my trades are doing versus looking at the watchlist or other windows.
 

rad14733

Well-known member
VIP
Can someone please help me make a script that will automatically place a "Price Level" drawing connected to the candle\time when I buy into a position? When I buy into a stock, I like to draw a price line to the candle\exact price so I can visualize how my trades are doing versus looking at the watchlist or other windows.
The best you can do is use EntryPrice() similar to the code below... It should also account for multiple purchases...

Ruby:
plot tradePrice = if GetQuantity() > 0  then GetAveragePrice() else Double.NaN;
 

Angry_Raven

New member
The best you can do is use EntryPrice() similar to the code below... It should also account for multiple purchases...

Ruby:
plot tradePrice = if GetQuantity() > 0  then GetAveragePrice() else Double.NaN;
Here's a link to the image of what that code did

Screenshot-2021-01-28-121603.png


I'm looking for something to do this with the "price level"

Screenshot-2021-01-28-121909.png
 

rad14733

Well-known member
VIP
@Angry_Raven Correct... Because of the criteria you need to plot based on your trade, the code can only draw the line based on the duration of your trade... Other than that you would need to draw manually... The code I posted is working as expected... We have to live within the constraints of the TOS platform... Perhaps someone else has time or knows how to assist further... I don't even think the line will remain after the position is closed...
 

Angry_Raven

New member
@Angry_Raven Correct... Because of the criteria you need to plot based on your trade, the code can only draw the line based on the duration of your trade... Other than that you would need to draw manually... The code I posted is working as expected... We have to live within the constraints of the TOS platform... Perhaps someone else has time or knows how to assist further... I don't even think the line will remain after the position is closed...
Either way. I still like what your code does. I'm happy with it for now so thank you a lot!
 

HomerSimpy

New member
I know this is an old thread but just found it.This works great for new trades but doesn't seem to recognize existing trades. the box shows up but it has no relevant content. Is there a waay to force it to find past trades? it worked great in new trades on paper trading.
 

rad14733

Well-known member
VIP
I know this is an old thread but just found it.This works great for new trades but doesn't seem to recognize existing trades. the box shows up but it has no relevant content. Is there a waay to force it to find past trades? it worked great in new trades on paper trading.

You can't display past trades, only active trades using EntryPrice()... Past trades are only viewable on the Monitor tab... Thinkscript cannot access historical trade data...
 

HomerSimpy

New member
@kalyan Try this code by Mobius -

Code:
# Plotting Average Actual Entry
# Mobius
# 01.01.2018

input HardStop = 3.00;
input Dir = {default long, short};

plot hide = double.nan;
     hide.setDefaultColor(Color.Black);
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.Long_Dash);
     Entry_.SetLineWeight(3);
     Entry_.SetDefaultColor(CreateColor(255,215,0));
     Entry_.HideBubble();
     Entry_.HideTitle();
def PL = if Entry > 0 then Entry - c else 0;
AddChartBubble(barNumber() == HighestAll(barNumber()), Entry_, "AVG " +AsDollars(Entry), Entry_.TakeValueColor());
#Alert(c crosses below Entry, "", Alert.Bar, Sound.Chimes);
#Alert(c crosses above Entry, "", Alert.Bar, Sound.Ring);
plot stop;
switch (Dir)
{
case long:
    stop = Entry_ - HardStop;
case short:
    stop = Entry_ + HardStop;
}
#Alert(close crosses stop, "STOP", Alert.Bar, Sound.Bell);
# End Code

Also, try creating a watchlist and select "current account positions". Then, choose your desired columns, such as "Avg Price", "P/L %", "P/L Open", etc.
You can't display past trades, only active trades using EntryPrice()... Past trades are only viewable on the Monitor tab... Thinkscript cannot access historical trade data...
I didn't word it correctly I guess, these are trades I'm currently in but the script only seems to recognize trades I've entered since adding the script, if that makes sense?
 

Hoa

New member
Hi- Below is what I did to display my Trades on TOS chart. I hope this helps.

Check to see if advanced Features are enabled
  1. Log into TD Ameritrade
  2. Select My profile
  3. Under the general tab, make sure "Advanced Features" is set to "Enabled".
Display on Chart
  1. Click on the Gear
  2. General Tab -> Content ->Display -- Make sure "Show Trades" is checked
  3. Click "Setup" typically in the top right
  4. Save workspace as (enter your name)
  5. Close then restart TOS. I right clicked, run as ADMIN. Idk if it matters.
Brownbear311, Would you mind to recheck
"3. Under the general tab, make sure "Advanced Features" is set to "Enabled". I went to TD Ameritrade but didn't see it. I was trying to tick "show trades" in TOS but no luck.
Thank you.
 

Trebor3.3

New member
Hello. I am new on this, by looking on yours post I ended up combining the next script. Some one know if is posible to plto the line from the last bar/candle to the rigth. the main avrerage cost line is fine to keep it at it is. but the others ones Target/Stop loss lines are the one that I would like to keep short on the rigth chart.



# 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

input use_line_limits = yes;#Yes, plots line from/to; No, plot line across entire chart
input linefrom = 100;#Hint linefrom: limits how far line plots in candle area
input lineto = 12;#Hint lineto: limits how far into expansion the line will plot

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," P/L: " + AsDollars(PL) +" ",
if PL == 0 then color.cyan
else if PL > 0 then color.green
else color.red);

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

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

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

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

plot "20% Target" = if Entry_ then Entry_ + .20*Entry else double.nan;
"20% Target".SetDefaultColor(color.red);
# end code
 

Similar threads

Top