OPEN-SOURCE SCRIPT

EMA 65 and 200 Strategy (Updated)

413
//version=5
strategy("EMA 65 and 200 Strategy (Updated)", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// Define EMAs
ema65 = ta.ema(close, 65)
ema200 = ta.ema(close, 200)

// Plot EMAs
plot(ema65, color=color.blue, linewidth=2, title="EMA 65")
plot(ema200, color=color.red, linewidth=2, title="EMA 200")

// Conditions for sell entry (Price touching EMA65 or EMA200 with a bearish trend)
sell_condition = (close < ema65 and close[1] > ema65) or (close < ema200 and close[1] > ema200)
sell_stop_loss = close + 20 // 20 points above the entry
sell_take_profit = close - 10 // 10 points below the entry

// Conditions for buy entry (Price touching EMA65 or EMA200 with a bullish trend)
buy_condition = (close > ema65 and close[1] < ema65) or (close > ema200 and close[1] < ema200)
buy_stop_loss = close - 20 // 20 points below the entry
buy_take_profit = close + 10 // 10 points above the entry

// Strategy execution: Buy and Sell orders
if (sell_condition)
strategy.entry("Sell", strategy.short, stop=sell_stop_loss, limit=sell_take_profit)

if (buy_condition)
strategy.entry("Buy", strategy.long, stop=buy_stop_loss, limit=buy_take_profit)

// Plot buy and sell signals
plotshape(series=sell_condition, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal", text="SELL")
plotshape(series=buy_condition, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal", text="BUY")

// Draw stop loss and take profit levels for visualization
plot(sell_condition ? sell_stop_loss : na, color=color.red, style=plot.style_line, linewidth=1, title="Sell Stop Loss")
plot(sell_condition ? sell_take_profit : na, color=color.green, style=plot.style_line, linewidth=1, title="Sell Take Profit")
plot(buy_condition ? buy_stop_loss : na, color=color.red, style=plot.style_line, linewidth=1, title="Buy Stop Loss")
plot(buy_condition ? buy_take_profit : na, color=color.green, style=plot.style_line, linewidth=1, title="Buy Take Profit")

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.