pine-script-v5

How can I get the prices of the previous days at the end of the exchange in pinescript?


I tried to use the following code line to get the average of the previous 365 days, but it returns the lasts 365 bar prices:

ta.sma(close, 365)

How can I get the prices of the previous days at the end of the exchange in pinescript?

I tried to use close, but it gets the price of the last bar. But what I want is the last price at the end of each of the 365 days.


Solution

  • Try request.security

    closeD = request.security(syminfo.tickerid, 'D', close)
    plot(closeD)