OPEN-SOURCE SCRIPT

Two MA Crossover with Labels

141
//version=5
indicator("Two MA Crossover with Labels", overlay=true)

// === Input Parameters ===
shortPeriod = input.int(10, title="Short MA Period")
longPeriod = input.int(100, title="Long MA Period")

// === Moving Averages ===
shortMA = ta.sma(close, shortPeriod)
longMA = ta.sma(close, longPeriod)

// === Plotting MAs ===
plot(shortMA, color=color.orange, title="Short MA")
plot(longMA, color=color.blue, title="Long MA")

// === Crossover Conditions ===
bullishCross = ta.crossover(shortMA, longMA)
bearishCross = ta.crossunder(shortMA, longMA)

// === Labels ===
if bullishCross
label.new(bar_index, low, "Buy", style=label.style_label_up, color=color.green, textcolor=color.white)

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

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.