OPEN-SOURCE SCRIPT

Custom MA Crossover (1-10min)

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

// Inputs
fast_length = input.int(5, title="Fast MA Length", minval=1) // Adjusted for shorter timeframes
slow_length = input.int(14, title="Slow MA Length", minval=1) // Adjusted for shorter timeframes
ma_type = input.string(title="MA Type", options=["SMA", "EMA"], defval="EMA")
use_timeframe_filter = input.bool(true, title="Restrict to 1-10min Timeframes?")
volume_filter = input.bool(true, title="Use Volume Filter?")
min_volume = input.float(1.5, title="Minimum Volume Multiplier", step=0.1) // Filter for higher volume candles

// Timeframe Check
is_allowed_timeframe = (timeframe.isminutes and timeframe.multiplier >= 1 and timeframe.multiplier <= 10) or not use_timeframe_filter

// 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)

// Volume Filter
volume_avg = ta.sma(volume, 20) // 20-period average volume
is_high_volume = volume >= volume_avg * min_volume

// Crossover signals with filters
bullish = ta.crossover(fast_ma, slow_ma) and is_allowed_timeframe and (not volume_filter or is_high_volume)
bearish = ta.crossunder(fast_ma, slow_ma) and is_allowed_timeframe and (not volume_filter or is_high_volume)

// 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, title="Bullish Signal")
plotshape(bearish, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, title="Bearish Signal")

// Alerts
alertcondition(bullish, title="Bullish Crossover", message="Fast MA crossed above Slow MA on a 1-10min chart")
alertcondition(bearish, title="Bearish Crossover", message="Fast MA crossed below Slow MA on a 1-10min chart")

คำจำกัดสิทธิ์ความรับผิดชอบ