//@version=5
strategy("Moving Average Crossover Strategy", overlay=true, initial_capital=1000, pyramiding=100, currency=currency.USD)
// Define the moving averages
ma50 = ta.sma(close, 50)
ma300 = ta.sma(close, 300)
// Plot moving averages with colors
plot(ma50, title="MA 50", color=color.red)
plot(ma300, title="MA 300", color=color.blue)
// Define the conditions for entering and exiting trades
enterLong = ta.crossover(ma50, ma300) and (time >= timestamp("2018-01-01T00:00+0000"))
exitLong = ta.crossunder(ma50, ma300) and (time >= timestamp("2018-01-01T00:00+0000"))
// Execute the trading strategy
if (enterLong)
strategy.entry("Buy Order π", strategy.long, qty=1000)
if (exitLong)
strategy.close_all("Sell Order π±π")
// Plot the entries and exits on the chart
plotshape(series=enterLong, title="Buy Order π", location=location.belowbar, color=color.green, style=shape.labelup, text="Buy Order π")
plotshape(series=exitLong, title="Sell Order π±π", location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell Order π±π")