Short/Long Entry Line on Chart for ThinkorSwim

rlohmeyer

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

n1t47ps.jpg


Code:
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 Color.green else Color.red);
 

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

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.

olwlipl.jpg


Hope this helps,
Bob
 
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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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