I am looking into modifying my indicators to include the ability of forecast.
We arbitrarily set a future price (for example in 10 candles from now), and our indicator calculates upon this new set of modified data, and plots accordingly.
First of all I would add recent price data (i.e. 100 candles) on an array for me to be able to edit the data. Price data would need to be shifted 10 days back (the first 10 candles of the 100 would be sacrificed).
I replace each of the final 10 candles with a price formula (i.e. p[i+1] = p[i] * factor) with a factor such that in 10 days it would return the price I arbitrarily set. (the arbitrary price in 10 days from now would be available for the user to enter in the settings)
So we end up with an array of 100 points to analyze upon.
I am not experienced with arrays in Pine Script. On other topics I am very familiar.
How can I make this new dataset of modified values (90 shifted originals + 10 forecasted) ? Is there some sort of recursion I should do to add new values one by one?
And how can I modify my indicators to reference this new dataset?
Now indicators reference on source data, that begins on zero (the first data point).
This is something rudimentary I tried.
indicator(title='EMA', shorttitle='EMA', overlay=true)
source = input(close, title = "Source", inline = '1')
scale = input.bool(true, title="Log Scale", inline = '1')
length = input.int(27, title="Length", inline='2')
ar = array.from(source)
array.shift(ar)
array.push(ar, 4700.0)
m01 = ta.ema(ar, length)
plot(m01, title='MA', color=#005488, linewidth=2)