Pine Script 5

result = tool.add(close, high) plot(result)

//@version=5 indicator("Dynamic MA") length = input.int(14, "Period", minval=1, maxval=200) src = input.source(close, "Source") ma_type = input.string("SMA", "MA Type", options=["SMA", "EMA"]) pine script 5

if exitCondition and strategy.position_size > 0 strategy.close("Long", comment="Exit Cross") result = tool