SIMPLE MAHACHAI

//version=5
strategy("SMA Crossover Strategy", overlay=true)

// Define the length for the SMA
smaLength = input.int(50, title="SMA Length", minval=1)

// Calculate the SMA
smaValue = ta.sma(close, smaLength)

// Plot the SMA on the chart
plot(smaValue, title="SMA", color=color.blue, linewidth=2)

// Buy condition: Price crosses above the SMA
if (ta.crossover(close, smaValue))
strategy.entry("Buy", strategy.long)

// Sell condition: Price crosses below the SMA
if (ta.crossunder(close, smaValue))
strategy.close("Buy")

// Optional: plot buy and sell signals on the chart
plotshape(series=ta.crossover(close, smaValue), title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=ta.crossunder(close, smaValue), title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
Trend Analysis

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