OPEN-SOURCE SCRIPT

SHIVSHANKAR BIND MACD Crossover

Theo shivshankarbind123
//version=5
indicator("MACD Crossover with Vertical Lines", overlay=true)

// MACD Parameters
fast_length = input(12, title="MACD Fast Length")
slow_length = input(26, title="MACD Slow Length")
signal_length = input(9, title="MACD Signal Length")

// MACD Calculation
[macdLine, signalLine, _] = ta.macd(close, fast_length, slow_length, signal_length)

// MACD Crossover conditions
bullishCrossover = ta.crossover(macdLine, signalLine)
bearishCrossover = ta.crossunder(macdLine, signalLine)

// Plot MACD and Signal lines (not necessary if only vertical lines are required)
plot(macdLine, title="MACD Line", color=color.blue, linewidth=1)
plot(signalLine, title="Signal Line", color=color.orange, linewidth=1)

// Add vertical line on crossover
var line bullLine = na
var line bearLine = na

if (bullishCrossover)
line.delete(bullLine)
bullLine := line.new(bar_index, high, bar_index, low, color=color.green, width=2)
if (bearishCrossover)
line.delete(bearLine)
bearLine := line.new(bar_index, high, bar_index, low, color=color.red, width=2)

// Buy/Sell labels
plotshape(series=bullishCrossover, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=bearishCrossover, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
Moving AveragesTrend Analysis

Mã nguồn mở

Theo tinh thần TradingView thực sự, tác giả của tập lệnh này đã xuất bản dưới dạng nguồn mở để các nhà giao dịch có thể hiểu và xác minh. Chúc mừng tác giả! Bạn có thể sử dụng miễn phí. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?

Thông báo miễn trừ trách nhiệm