Dominant Direction (DD)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © peacefulLizard50262

//@version=5
indicator("Dominant Direction", overlay = true, max_bars_back = 5000)
import lastguru/DominantCycle/2 as d

source = input.source(hl2, "Source")
colour = input.color(color.orange, "Color")
length = d.mamaPeriod(source, 2, 4096)
lines = line.new(bar_index, source, bar_index, source)
if barstate.islast
    lines := line.new(bar_index, source , bar_index + int(length), source + (source-source[int(length)]), color = colour, style = line.style_arrow_right)
if barstate.isconfirmed
    line.delete(lines)
