OPEN-SOURCE SCRIPT

EMA 8/20 Crossover Strategy

112
iqhe mM23// SPDX-License-Identifier: MPL-2.0
//version=5
strategy("EMA 8/20 Crossover Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)

// EMA Definitions
ema8 = ta.ema(close, 8)
ema20 = ta.ema(close, 20)

// Buy condition: EMA 8 crosses above EMA 20
longCondition = ta.crossover(ema8, ema20)
if (longCondition)
strategy.entry("Buy", strategy.long)

// Sell condition: EMA 8 crosses below EMA 20
shortCondition = ta.crossunder(ema8, ema20)
if (shortCondition)
strategy.entry("Sell", strategy.short)

// Plot EMAs
plot(ema8, title="EMA 8", color=color.orange)
plot(ema20, title="EMA 20", color=color.blue)

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.