Heiken Ashi Swing High/Low
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © wallneradam

//@version=5
indicator("Heiken Ashi Swing High/Low", "HASwing", overlay=true, timeframe="", timeframe_gaps=false)

import wallneradam/TAExt/9

type = input.string("High/Low", "Type", ["High/Low", "HA Open/Close"], tooltip="Which levels to use for upper and lower?")


[o, h, l, c] = TAExt.heiken_ashi()

var float swing_high = na
var float swing_low = na

if c[1] > o[1] and c < o
    swing_high := type == "High/Low" ? high[1] : c[1]
else if c[1] < o[1] and c > o
    swing_low := type == "High/Low" ? low[1] : o[1]

plot(swing_high, "Swing High", color=color.new(color.green, 40), style=plot.style_stepline)
plot(swing_low, "Swing Low", color=color.new(color.red, 40), style=plot.style_stepline)
