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. Thanks in advance for any help in this issue.
 

rad14733

Well-known member
VIP
@Frank123 I think it would help if you were to explain your logic in needing to plot the highest and lowest prices since your trade was entered... And I'm assuming that this is a live trade rather than backtesting... Knowing your logic might help members come up with a broader solution than you have thought of to date... Essentially, it sounds like you want to know the trading range since entry but, again, I'm not sure why... Are you long term trading, swing trading, day trading, scalping...??? What are your take profit exit and stop loss limits in relation to your entry...??? At this point you've left us with more questions than answers...
 

Frank123

New member
Thank you for responding, I appreciate any assistance you can provide.

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.

Thank you!
 

rad14733

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

Frank123

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

Similar threads

Top