'Is there a way to get next day price?

I am new to Pine Script. I need to draw support and resistance line. The rules for resistance is as follow :

If today's closing price is greater than Previous (Day-1) closing price  AND
   today's closing price is greater than Next (Day+1) closing price AND
   today's closing price is greater than Next (Day+2) closing price AND
   today's closing price is greater than Next (Day+3) closing price   then
   Resistance is today's closing price
else
   Resistance is previous (Day-1) closing price

I don't know how to get Day+1, Day+2, Day+3 Price in pine script.



Solution 1:[1]

You can not forward reference in pine so you have to refactor the logical operation from the perspective of close(day + 3) being the current close.

resistance = close[3] > close and close[3] > close[1] and close[3] > close[2] and close[3] > close[4] ? close[3] : close[4]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rumpypumpydumpy