Search code examples
pine-scriptcandlestick-chartcryptocurrencyforexcandlesticks

Can i get data of specific old candles in Pinescript?


I wanna to get data of old candles such as high, low , close , open

Can i get the data of candle 1 and 2 ?

click to see the image

Note : the code in this link that i use to select those candles

How to check if the candle is the largest one in Pine-Script?


Solution

  • Use the valuewhen function, if you want the high price you can use:

    valuewhen(rising(r,50),high,0)
    

    for "candle 2" in your image, for candle 1 use

    valuewhen(rising(r,50),high,2)