Crunchster's Real Price
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Crunchster1

//@version=5
indicator("Crunchster's Real Price", overlay = true, scale = scale.none)

//Inputs
src = input(close, "Source")
length = input.int(title="Lookback period for normalisation filter", defval=14, minval=2, tooltip='This adjusts the lookback period for the volatility filter used to transform the original price series.')
roll = input.int(title="Rolling window length", defval=365, minval=10, tooltip='This value will adjust the length of the rolling lookback period over which the normalised price is summated. This only affects the normalised price over a rolling period')

// Calculation of normalised period returns
returns = (src - src[1]) / ta.stdev((src - src[1]), length)

// Convert the Normalised returns per period into a price series
nReal = ta.cum(returns)
nRolling = math.sum(returns, roll)

plot(nReal, title = "Real Price", color=color.new(#3d3ddd, 0))
plot(nRolling, title = "Normalised price series over rolling period", color=color.new(#000000, 0), display=display.none)
