Hi folks,
I wonder if anyone can help. Ive been banging my head against my desk for hours trying to figure this one out…
Instead of identifying the highest high or lowest low over a lookback period of given number of bars – e.g.
HIGHEST[10](High)
I would like to quantify the highest high and lowest low after a defined time. For example, I’d like to quantify the highest high after 14:00 and before 19:00
This quantity should continually update during this period but not reference price prior to 14:00. This is where the HIGHEST[10](High) is problematic because at 14:00 it is looking 10 bars back before the time reference point.
Thanks in advance for any help
Try this (not tested):
IF OpenTime = 140000 Then
MyHighest = high
Endif
If OpenTime > 140000 and OpenTime <= 160000 Then
MyHighest = max(MyHighest,high)
Endif
You can replace OpenTime with Time if you prefer the time when a candle closes rather than when it opens.
Moreover, it will not work as expected if you use a TF that does not open/close a candle at that time (such as a 4-hour or 7-minute TF).
Many thanks Roberto. Thats spot on!
Sorry for not adding LOWEST.
I read your example and didn’t pay attention to your title:
IF OpenTime = 140000 Then
MyHighest = high
MyLowest = low
Endif
If OpenTime > 140000 and OpenTime <= 160000 Then
MyHighest = max(MyHighest,high)
MyLowest = min(MyLowest,low)
Endif