OPEN-SOURCE SCRIPT

YO

//version=5
indicator("Custom MA Crossover", overlay=true, shorttitle="CMA Cross")

// Inputs
fast_length = input.int(9, title="Fast MA Length", minval=1)
slow_length = input.int(21, title="Slow MA Length", minval=1)
ma_type = input.string(title="MA Type", options=["SMA", "EMA"], defval="EMA")

// Calculations
fast_ma = ma_type == "SMA" ? ta.sma(close, fast_length) : ta.ema(close, fast_length)
slow_ma = ma_type == "SMA" ? ta.sma(close, slow_length) : ta.ema(close, slow_length)

// Crossover signals
bullish = ta.crossover(fast_ma, slow_ma)
bearish = ta.crossunder(fast_ma, slow_ma)

// Plotting
plot(fast_ma, color=color.new(color.blue, 0), title="Fast MA")
plot(slow_ma, color=color.new(color.red, 0), title="Slow MA")

// Plot signals
plotshape(bullish, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(bearish, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)

// Alerts
alertcondition(bullish, title="Bullish Crossover", message="Fast MA crossed above Slow MA")
alertcondition(bearish, title="Bearish Crossover", message="Fast MA crossed below Slow MA")

Feragatname