Get the Highest high or Lowest low from the time I enter a trade?

Frank123

New member
I’m having trouble trying to mark a trade entry (within a code) so I can track the highest or lowest the price has gone since my trade entry.
Highest(high,[x]) or Lowest(low,[x])
Basically I either need x=1 today, then x=2 tomorrow, x=3, etc. somehow, however I run into a “only constants expected” error trying to place a variable in where [x] (the expected constant) goes.
Or if it’s possible to maybe plot a vertical line on my trade date then track the highest(high, (from vertical line)).. I think I’m at a dead end and could use some help.
Also I have a (countTradingDays) issue that arose from this issue but will post that in another question to keep this question relevant to Highest, and Lowest incase others run into this same issue.

The type of trading I do primarily is swing and long term .

My logic adjust my exit criteria based on the unrealized profit since I entered the trade.

So as an example if i enter a trade today with minimal unrealized gains over the first few days I may employ a standard trailing or volatility type stop .

However if the trade becomes highly profitable I could change my exit criteria or strategy based on my unrealized profits. As an example if I have a gain of 30% I might tighten my stop parameters or if a volatility stop change my parameters .

To do that I need to understand the highest high since I entered the trade.

Hopefully this helps and thank you all in advance for any suggestions or information you might provide.

Thanks in advance for any help in this issue.
 
Last edited by a moderator:
@Frank123 Believe it or not that logic does make sense... However, successfully coding that logic into Thinkscript could prove problematic... It almost borders on fuzzy logic, something Thinkscript isn't designed for... The only way to code it would be to break it down into its rawest pieces-parts, parse for each piece of logic, and then further parse those results... Rinse and repeat until you get the answer you are looking for... Factoring in the time spans may or may not be the most complicated part... I can't take the time to map it out but I think you should draw up a logic diagram before coding to reduce the amount of logic re-writes... I haven't refined counter and date-related coding but if you get your logic diagram planned out perhaps @XeoNoX could fill in those blanks... Granted, it may sound simple when your eyes and brain are processing it but turning all of that into Thinkscript might be a bit more daunting...
 
Last edited:
Well thank you for reviewing it, and replying so quickly. From what I’ve found, I was worried it could be an issue. Well, and after reading through dozens of questions and answers throughout this forum, I thought for sure if it could be done that someone here could at least steer me in the right direction.
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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