Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wilder's Moving Average #150

Open
femtotrader opened this issue Jul 8, 2024 · 4 comments
Open

Wilder's Moving Average #150

femtotrader opened this issue Jul 8, 2024 · 4 comments

Comments

@femtotrader
Copy link
Contributor

femtotrader commented Jul 8, 2024

Hello,

See
https://www.incrediblecharts.com/indicators/wilder_moving_average.php

A number of popular indicators, including Relative Strength Index (RSI), Average True Range (ATR) and Directional Movement were developed by J. Welles Wilder and introduced in his 1978 book: New Concepts in Technical Trading Systems. Users should beware that Wilder does not use the standard exponential moving average formula.

Do we have WilderMA in talipp ? (not to be confused with WeightedMA)

Kind regards

PS: see also https://www.tradingview.com/script/wXtQeoOg/#:~:text=Wilder%20did%20not%20use%20the,where%20K%20%3D1%2FN.

@femtotrader femtotrader changed the title Wilders Moving Average Wilder's Moving Average Jul 8, 2024
@femtotrader
Copy link
Contributor Author

Looking at

return (self.output_values[-1] * (self.period - 1) + self.tr[-1]) / self.period

$$output_{i} = \frac{output_{i-1} \cdot (period - 1) + TR_{i - 1}}{period}$$

with $k = \frac{1}{period}$

we have

$$output_{i} = output_{i-1} \cdot \frac{(period - 1)}{period} + \frac{1}{period} \cdot TR_{i - 1}$$

which is also

$$output_{i} = output_{i-1} \cdot (1 - \frac{1}{period}) + \frac{1}{period} \cdot TR_{i - 1}$$

and so

$$output_{i} = output_{i-1} \cdot (1 - k) + k \cdot TR_{i - 1}$$

So we can say that current talipp implementation at ATR is using Wilder's Moving Average for smoothing true range (which is fine!)

Maybe we could define such a MA in talipp and give user opportunity to use it's own MA for ATR calculation?

@femtotrader
Copy link
Contributor Author

femtotrader commented Jul 8, 2024

Maybe we should have an indicator called simply TrueRange which simply computes True Range of incoming bars and use a smoother as exposed in #146 to build ATR with Wilder's Moving Average.

@femtotrader
Copy link
Contributor Author

femtotrader commented Jul 8, 2024

This would simplify CHOP code which currently uses ATR(1) but will use instead just TrueRange() (because with period=1, k=1 and so

$$output_i = output_{i-1} \cdot (1 - 1) + 1 \cdot TR_{i - 1} $$

$$output_i = TR_{i-1}$$

@femtotrader
Copy link
Contributor Author

Wilder's MA and SMMA seems to be the exact same thing.

This code
https://github.com/nardew/talipp/blob/main/talipp/indicators/ATR.py#L53-L58
and https://github.com/nardew/talipp/blob/main/talipp/indicators/SMMA.py#L34-L40
could probably be refactored to use in ATR calculation SMMA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant