Hello, I am learning pine script v5 and i am trying to code a "simple" indicator which calculates the lowest high and the highest low among 60 min candles of the last 5 days of trade. Also, I want to define the perimeter of 5 full trade days (for instance, if today is Fri, I want to consider Thu, Wed, Tue, Mon and previous Fri) and among the 60 min candles of these days, calculate the lowest high / highest low, and assign these 2 values to each day, and plot them. In practice, in a 60 min timeframe chart, there will be two solid lines every day (one for lowest highs and one for highest lows), and then having a step the next day. How it is possible to do it in pinescript? I tried to use chatGPT but it is not helping. Thanks in advance
Yes, I would like to plot on a 60m chart in order to have a kind of step-line chart. The point is that i want to calculate the lowest high off the hourly candles, not the daily candle..and I am not able to manage this kind of command in the code due to my unexperience
You've made the simple sounds complicated. Why not simply say ... Give me the lowest high and the highest low, among 60 minutes bars, from the past 5 trading days. If it's what you want then ... //@version=5 indicator(title="highestLow_lowestHigh", overlay = true) string timeFrame = input.timeframe("D", "Time Frame") int lookBack = input.int(5, "lookBack") [securityHigh , securityLow] = request.security(syminfo.tickerid, timeFrame , [high, low]) float highestSecurityLow = securityLow[0] float lowestSecurityHigh = securityHigh[0] for i = 1 to lookBack by 1 if highestSecurityLow < securityLow // indent by 1 highestSecurityLow := securityLow // indent by 2 if lowestSecurityHigh > securityHigh // indent by 1 lowestSecurityHigh := securityHigh //indent by 2 plot(lowestSecurityHigh, color=color.green) plot(highestSecurityLow, color=color.red) I think it's about it
It doesn’t work as planned. It doesn’t look at intraday bars, With the settings Daily, 5 on a 60min chart. Gotta check tomorrow Also … securityLow[0] and securityHigh[0] is the current bar Which you don’t want to take into account.