# 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.

VIP

#### 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!

##### 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.

#### Hoang888

##### New member
Everyone, can tell me how to define the highest high, highest low, lowest high, lowest low based on current/previous candle following time frames 15m, 1h, 1d
ex:
def Hs = highest high;
def Hl = highest low;
def Lh = lowest high;
def Ll = lowest low;
but all of them count on the current or previous candle within time frame of 15m, 1h, and 1d that meant it gives me 3 different result

Thank you,