GaryStad
GaryStad

Reputation: 25

plot manually supplied values in a pane - Pine-Script:TradingView

might there be a way to have a pane that plots number/date pairs that I manually supply (example:[05/24/2021 09:00, 27.8],[05/25/2021 09:00, 31.2],[05/26/2021 09:00, 30.1],[05/27/2021 09:00, 28.3], etc...), instead of plotting data sourced from price, ema, rsi, etc? I can use labels to daily place my number along the price action, but that doesn't give me a visualization like having them plotted against their own scale, to correlate with price action in the other pane. Any help, ideas, or suggestions would be greatly appreciated.

Upvotes: 2

Views: 854

Answers (1)

rumpypumpydumpy
rumpypumpydumpy

Reputation: 3803

You could do something like this if you're staying with one timeframe and arrange your data simply as comma separated values for that timeframe. You could expand on it and use a second array with array.from() to store timestamps for the corresponding value array.

var int index = na

start_ts = timestamp(2021, 5, 21)
if time >= start_ts and time[1] < start_ts
    index := 0
else if time > start_ts
    index += 1
    
var prices = array.from(38000, 39000, 40000, 41000)

to_plot = time >= start_ts and index <= array.size(prices) - 1

plot(to_plot ? array.get(prices, index) : na)

The simplest approach would be to generate your CSVs for each timeframe you want to work with, then you only need to have the start date/time. It could become quite difficult, though not impossible to work from one master array of low timeframe values. You are also restricted to an array size of 100,000. So that will limit your ability to render higher timeframes. ie <70 days of 1 minute data. You will also need to be careful of the script character limit, especially using multiple CSV arrays.

Upvotes: 2

Related Questions