From db75b7769dd1321704630b778b20a3f778d1b981 Mon Sep 17 00:00:00 2001 From: Pranav Date: Thu, 12 Oct 2023 23:59:04 +0530 Subject: [PATCH] Added atr_mamode argument to supertrend atr_mamode will be passed on to ATR as mamode. Useful because many libraries/platforms use SMA for calculating ATR leading to different values for supertrend. --- pandas_ta/overlap/supertrend.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas_ta/overlap/supertrend.py b/pandas_ta/overlap/supertrend.py index a99829ee..f868d19d 100644 --- a/pandas_ta/overlap/supertrend.py +++ b/pandas_ta/overlap/supertrend.py @@ -11,6 +11,7 @@ def supertrend( high: Series, low: Series, close: Series, length: Int = None, atr_length: Int = None, multiplier: IntFloat = None, + atr_mamode : str = None, offset: Int = None, **kwargs: DictLike ) -> DataFrame: """Supertrend (supertrend) @@ -31,6 +32,7 @@ def supertrend( variable of control. Default: length multiplier (float): Coefficient for upper and lower band distance to midrange. Default: 3.0 + atr_mamode (str) : Can be used to specify the type of MA to be used for ATR calculation. offset (int): How many periods to offset the result. Default: 0 Kwargs: @@ -60,7 +62,7 @@ def supertrend( long, short = [nan] * m, [nan] * m hl2_ = hl2(high, low) - matr = multiplier * atr(high, low, close, atr_length) + matr = multiplier * atr(high, low, close, atr_length, mamode=atr_mamode) lb = hl2_ - matr # Lowerband ub = hl2_ + matr # Upperband for i in range(1, m):