From 190ab31c51479c99f0504a5a25483d362c5e761d Mon Sep 17 00:00:00 2001 From: "Bobby (aider)" Date: Sat, 8 Feb 2025 08:39:21 -0800 Subject: [PATCH] feat: Add Pine Script implementation of Three ATR EMA indicator --- pinescripts/Three_ATR_EMA.pine | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 pinescripts/Three_ATR_EMA.pine diff --git a/pinescripts/Three_ATR_EMA.pine b/pinescripts/Three_ATR_EMA.pine new file mode 100644 index 0000000..7651e1c --- /dev/null +++ b/pinescripts/Three_ATR_EMA.pine @@ -0,0 +1,42 @@ +//@version=5 +indicator(title="Three ATR EMA Bands", shorttitle="3ATR EMA", overlay=true) + +// Inputs +ema_length = input.int(21, "EMA Length", minval=1) +atr_multiplier = input.float(3.0, "ATR Multiplier", step=0.1) +show_bullish_arrows = input.bool(true, "Show Bullish Signals") + +// Calculate EMA +ema = ta.ema(close, ema_length) + +// Calculate True Range +tr = math.max(high - low, math.max(math.abs(high - nz(close[1])), math.abs(low - nz(close[1])))) + +// Calculate Bands +upper_band = ema + (tr * atr_multiplier) +lower_band = ema - (tr * atr_multiplier) + +// Bullish Signal Condition +bullish_signal = close < ema and + close[1] <= lower_band[1] and + close > close[1] + +// Plotting +plot(ema, "EMA", color=color.new(#00BFFF, 0)) +plot(upper_band, "Upper Band", color=color.new(#FFA500, 0), linewidth=2) +plot(lower_band, "Lower Band", color=color.new(#32CD32, 0), linewidth=2) + +// Signal Arrows +plotshape(show_bullish_arrows and bullish_signal ? low : na, + "Bullish Signal", + shape.triangleup, + location.belowbar, + color=color.new(#00FF00, 0), + size=size.small) + +// Alerts +alertcondition(bullish_signal, "Bullish Signal Triggered", "3ATR EMA Bullish Signal") + +// Strategy Calculations for Visual Reference +if (bullish_signal) + strategy.entry("Bullish", strategy.long)