OPEN-SOURCE SCRIPT

My Strategy

140
//version=5
strategy("My Strategy", overlay = true)

// Create Indicator's
ema1 = ta.ema(close, 8)
ema2 = ta.ema(close, 18)
ema3 = ta.ema(close, 44)

//plot the Indicators

plot(ema1, title = "EMA1", color = color.blue, linewidth = 2)
plot(ema2, title = "EMA2", color = color.red, linewidth = 2)
plot(ema3, title = "EMA3", color = color.black, linewidth = 2)

// Specify crossover conditions

Enterlong = ta.crossover(ema2, ema3)
Exitlong = ta.crossunder(ema1,ema2)

Entershort = ta.crossunder(ema2, ema3)
Exitshort = ta.crossover(ema1,ema2)

//Execution Logic - Placing Orders

strategy.entry("Long", strategy.long, 1, when = Enterlong)
strategy.close("Long", when = Exitlong)

strategy.entry("Short", strategy.short, 1, when = Entershort)
strategy.close("Short", when = Exitshort)



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.