TradingView
Decam9
17 de Mai de 2022 05:43

Moving Average Crossover Strategy 

Eli Lilly and CompanyNYSE

Descrição

The Moving Average Crossover indicator uses 3 moving averages (2 simple moving averages and 1 exponential moving average ) to signal long and short opportunities based on moving average crossovers. This strategy serves as a backtest to that indicator. By taking entry and exit positions based on moving average crossovers, we are able to project profit with this script. You are given the option to select which moving average crossings trigger entry and exit signals. Fast refers to an EMA which should be your shortest MA. Slow refers to the first SMA which will serve as a signal line. Trend refers to a long SMA which will help determine if you should take long positions or short. You can also filter by extra conditions such as minimum volume or RSI. For example, you may have the script trigger a buy signal if the 5ema crosses the 20 sma while RSI reads 60 and sell if it crosses again.

This strategy starts with $100,000 and uses 10% of the account per trade.
Comentários
lalitcpanchal
Hi, want to formula for close crossover sma ?

Eg.
Long = crossover close SMA close, 34
Long exit = crossunder close SMA close 34

but not working
thanks
Decam9
@lalitcpanchal, Hi you could try something like this:

Long = ta.crossover(close, ta.sma(close,20))
Exit = ta.crossunder(close, ta.sma(close, 20))

Long should be true when the close of the candle closes above the 20sma and exit should be true when the close of the candle closes under the 20sma
lalitcpanchal
@Decam9, Wow,
Thank You
Mais