Short/Long Entry Line on Chart for ThinkorSwim


I have had an issue with the fact that it is not easy to track your trades real time on your charts, know when they ended, and whether they were winner/loser. I coded a simple script to give this ability which I use within a more complex script to determine my risk and convert it to shares.

Below is an image of the entry lines on my chart. The color is dynamically determined based on whether trade is long or short, but I plotted it as dots so that I can easily see how many bars the trade lasted and which bar was the exit.


declare upper;
def EP = Round(GetAveragePrice(), 2);
plot Enter = EP;
def shrs = GetQuantity();
def long = shrs > 0;
def short = shrs < 0;
Enter.AssignValueColor(if long then else;


hi, your code does not seem to be working. I added it as a study but nothing populates.
Hi Rosalyn,
I have the code running on my charts. 1 question and one issue:

1. I assume you have set it up on a chart that you have had live trades on? If not, nothing will show of course. It only plots when there have been live trades.
2. Secondly, if you got in and got out on the same bar, the code will show the entry on that bar, but disappear from the bar when you close the trade. So if your trade lasted 4 bars, you will see the entry on 3 of those bars and once you exit your trade on the 4th bar, the entry plot will disappear from that bar.

Also, setup the plot in your settings as a dot and chose size 3.

Here is a jpg to illustrate. On this chart I have the exact same code running. The trade that I show as an example is from much earlier today, and it is still showing.


Hope this helps,


One other issue. Do not plot this with too many days on the chart, especially with bars of 5 minutes or less. In calculating entry, if there are plots below or above the chart y axis, it will not plot peoperly, I have found.

Similar threads