34 lines
1.2 KiB
Plaintext
34 lines
1.2 KiB
Plaintext
//@version=5
|
|
strategy(title="Three ATR EMA Strategy", shorttitle="3ATR-EMA Strategy", overlay=true, currency=currency.USD, initial_capital=10000, default_qty_type=strategy.percent_of_equity, commission_type=strategy.commission.percent, commission_value=0.1)
|
|
|
|
// Inputs
|
|
ema_length = input.int(21, "EMA Length", minval=1)
|
|
atr_multiplier = input.float(3.0, "ATR Multiplier", step=0.1)
|
|
show_bulls = input.bool(true, "Show Bullish Markers")
|
|
|
|
// Calculate EMA and ATR-based bands
|
|
ema = ta.ema(close, ema_length)
|
|
upper_band = ema + (ta.atr(ema_length) * atr_multiplier)
|
|
lower_band = ema - (ta.atr(ema_length) * atr_multiplier)
|
|
|
|
// Strategy Conditions
|
|
bullish_entry = (close < ema) and
|
|
(close[1] <= lower_band[1]) and
|
|
(close > close[1])
|
|
|
|
// Execute strategy orders
|
|
if bullish_entry
|
|
strategy.entry("Long", strategy.long)
|
|
|
|
// Visual elements (optional)
|
|
plot(ema, "EMA", color=color.new(#4A90E2, 0))
|
|
plot(upper_band, "Upper", color=color.new(#F5A623, 0))
|
|
plot(lower_band, "Lower", color=color.new(#7ED321, 0))
|
|
|
|
plotshape(show_bulls and bullish_entry ? low : na,
|
|
style=shape.triangleup,
|
|
location=location.belowbar,
|
|
color=color.new(#00FF00, 0),
|
|
size=size.small,
|
|
title="Bull Signal")
|