Page 1 of 1

Calculate Lowest High / Highest Low on 60 min candles of the last X full trade days with Pine Script v5

Posted: Sat Jan 20, 2024 2:44 pm
by williamblake72
I am learning pine script v5 and i am trying to code an indicator which calculates the lowest high and the highest low among 60 min candles of the last X days of trade.
Let's take for instance X=5 (last 5 full trade days) and as assets Crude Oil (having 23 candles in a trade day).

The script should:
- Delimit the time scope of the analysis, e.g. the last 5 days. For instance if today is Friday, the scope is Thu, Wed, Tue, Mon and previous Fri
- Taken into consideration the 60min candles of the days above (they are 23*5 = 115), calculate the lowest high and the highest low among these 115 candles of 60min
- These 2 values are then assigned to today. In other words, the code assign to the day of today 2 numbers which are calculated based on values of the 5 previous full trade days
- Plot in a 60min timeframe the lines which connects the number for all 23 candles of today there is only on highest low and lowest high, so it is a straight line, which will potentially change tomorrow. But all candles of the same day must have the same highest low / lowest high values. The human will interact with this indicator within a 60min timeframe

I am not able to handle the different day vs 60 min timeframe. Can you please help with the core of the code? In order to retrieve the underlying I am using the request.security function.

Thanks