Anchored Average Price by Atilla Yurtseven (AAP)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AtillaYurtseven

//@version=5
indicator("Anchored Average Price // Atilla Yurtseven", shorttitle="AAP", overlay=true, max_bars_back=300)

src = input.source(hlc3, title="Source")
startCalculationDate = input.time(timestamp("01 Jun 2023"), "Start Date", confirm=true)
clr = input.color(color.green, title="Color")

var arr = array.new_float(na)
var float val = na

if time >= startCalculationDate
    array.push(arr, src)
    val := array.avg(arr)
else
    array.clear(arr)
    val := na

plot(val, color=clr, title="Average Price")
