OPEN-SOURCE SCRIPT

Custom MA Crossover with Volume

//version=5
indicator("Custom MA Crossover with Volume", overlay=true)

// User-defined moving average periods
fast_length = input.int(10, title="Fast MA Length")
slow_length = input.int(100, title="Slow MA Length")

// Calculate moving averages
fast_ma = ta.sma(close, fast_length)
slow_ma = ta.sma(close, slow_length)

// Calculate 10-day average volume
volume_avg = ta.sma(volume, 10)

// Define crossover conditions
bullish_crossover = ta.crossover(fast_ma, slow_ma) and volume > volume_avg
bearish_crossover = ta.crossunder(fast_ma, slow_ma) and volume > volume_avg

// Plot moving averages
plot(fast_ma, color=color.green, title="Fast MA")
plot(slow_ma, color=color.red, title="Slow MA")

// Plot buy and sell labels
if (bullish_crossover)
label.new(bar_index, na, "Buy", color=color.green, style=label.style_label_up, textcolor=color.white)

if (bearish_crossover)
label.new(bar_index, na, "Sell", color=color.red, style=label.style_label_down, textcolor=color.white)

// Display volume average for reference
plot(volume_avg, color=color.blue, title="10-Day Avg Volume", linewidth=1)
Cycles

오픈 소스 스크립트

진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

차트에 이 스크립트를 사용하시겠습니까?

면책사항