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);

bobkhalid

New member
@wcsharron Maybe look at this post, or you could try the modified code below that I have lately been using.
Note: Please ensure that the below study plots correctly before using.

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
Hello- where do you copy this program code?
 

AnakManis

New member
VIP
@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);
Now as an addition, is there a way of adding AddChartBubble to it to be able to see the target percentages? Or is that not doable? Thanks.
 

Pensar

Well-known member
VIP
Now as an addition, is there a way of adding AddChartBubble to it to be able to see the target percentages? Or is that not doable? Thanks.
@AnakManis Its certainly possible. Here is a bubble example for you using the "5% Stop" plot -

Code:
input move_bubble_forward_how_many_bars = 10;
def bm = move_bubble_forward_how_many_bars;

AddChartBubble(!IsNaN(close[bm]) && IsNaN(close[bm-1]),"5% Stop", Round("5% Stop"), "5% Stop".TakeValueColor(), no);

See if you are able to code the remaining bubbles. If not, post the exact code that you are currently using and I will add them for you.
 

PlusEVTrades

New member
Hi, came across this thread looking to plot previous trades. It seems most the codes in the thread plot live trades?

however using the snippet

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

Seems to show "some" of my closed trades but not all. Just curious if anyone knows why and if I can get it to show all trades.
 

Angry_Raven

New member
@BenTen Is something like this possible for TOS? The boxes mark when you entered\exited a position and it tracks how long you were in it. (How many candles you were in it and it shows how many hours). Box is green if it's positive, and red if it's negative.
unknown.png
 

MerryDay

Administrative
Staff member
Staff
VIP
@Angry_Raven All portfolio information resets to isNAN (none) after exiting a trade (except p/l ytd).
Which means we can't analyze our trade history :(

Members have mentioned that they download trades to Excel to do all their post-trade analysis.
 
Last edited:

Yaserhosni2000

New member
Hello, this worked great. Is there a way to make it work for the week and 4 hours intervals?
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);
t
 

Pensar

Well-known member
VIP

Inteezyguy

New member
Good afternoon all,

I was wondering if there is a label on the chart to see when the last time a ticker was traded, possibly even with the P/L of that result of the last time the ticker was traded.

I mainly want a quick reference for the wash sale rule basically.

Thanks for any help!
 

MerryDay

Administrative
Staff member
Staff
VIP
Is there is a label on the chart to see when the last time a ticker was traded, possibly even with the P/L of that result of the last time the ticker was traded.

I mainly want a quick reference for the wash sale rule basically.

Thanks for any help!
I moved your post here as this thread discusses the myriad of ways to display trades on charts.
For a specific answer to your question:
https://usethinkscript.com/threads/show-trades-on-thinkorswim-chart-screen.1857/page-4#post-78210
 
Last edited:

mbarcala

Member
VIP
I would like to know when I place a position if I can have automatically add in my graph a line and a bubble with my entry price. It's this possible to be create in thinkscrip?
 

Jony Giant

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

MerryDay

Administrative
Staff member
Staff
VIP
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.
 

Pensar

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

 
Solution

MerryDay

Administrative
Staff member
Staff
VIP
@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

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

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!
 

Pensar

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

Similar threads

Top