Search
Products
Community
Markets
News
Brokers
More
IN
Get started
Community
/
Ideas
/
SIMPLE MAHACHAI
Gold Spot / U.S. Dollar
SIMPLE MAHACHAI
By joyjuhtarat2001
Follow
Follow
Sep 30
1
Sep 30
//
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
joyjuhtarat2001
Follow
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the
Terms of Use
.