Mac D Strategy *Free*

strategy(“MACD Strategy”, overlay=true)

// Define MACD parameters
fastLength =, title=”Fast Length”)
slowLength =, title=”Slow Length”)
signalSmoothing =, title=”Signal Smoothing”)

// Calculate MACD and Signal Line
[macdLine, signalLine, _] = ta.macd(close, fastLength, slowLength, signalSmoothing)

// Plot MACD and Signal Line
plot(macdLine,, title=”MACD Line”)
plot(signalLine,, title=”Signal Line”)

// Define Buy and Sell conditions
buyCondition = ta.crossover(macdLine, signalLine)
sellCondition = ta.crossunder(macdLine, signalLine)

// Plot Buy and Sell signals on the chart
plotshape(series=buyCondition, location=location.belowbar,, style=shape.labelup, title=”Buy Signal”)
plotshape(series=sellCondition, location=location.abovebar,, style=shape.labeldown, title=”Sell Signal”)

// Execute Buy and Sell orders
if (buyCondition)
strategy.entry(“Buy”, strategy.long)

if (sellCondition)
strategy.entry(“Sell”, strategy.short)