--

//@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 πŸ±πŸŽ‰")

--

--

Henrique Centieiro & Bee Lee
Henrique Centieiro & Bee Lee

Written by Henrique Centieiro & Bee Lee

πŸ‘‘8X Medium Top Writer | ✍🏻AI, Tech, Crypto, Money, Investing, Mindset | 🧠Be part of our Be Limitless community: https://www.skool.com/be-limitless-4003/about

No responses yet