-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
23 changed files
with
215 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
|
||
namespace Skender.Stock.Indicators | ||
{ | ||
[Serializable] | ||
public class DemaResult : ResultBase | ||
{ | ||
public decimal? Dema { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Double Exponential Moving Average (DEMA) | ||
|
||
[Double exponential moving average](https://en.wikipedia.org/wiki/Double_exponential_moving_average) of the Close price over a lookback window. | ||
[[Discuss] :speech_balloon:](https://github.com/DaveSkender/Stock.Indicators/discussions/256 "Community discussion about this indicator") | ||
|
||
![image](chart.png) | ||
|
||
DEMA is shown as the dashed line above. [EMA](../Ema/README.md#content) (solid line) and [Triple EMA](../TripleEma/README.md#content) (dotted line) are also shown here for comparison. | ||
|
||
```csharp | ||
// usage | ||
IEnumerable<DemaResult> results = | ||
quotes.GetDoubleEma(lookbackPeriods); | ||
``` | ||
|
||
## Parameters | ||
|
||
| name | type | notes | ||
| -- |-- |-- | ||
| `lookbackPeriods` | int | Number of periods (`N`) in the moving average. Must be greater than 0. | ||
|
||
### Historical quotes requirements | ||
|
||
You must have at least `3×N` or `2×N+100` periods of `quotes`, whichever is more. Since this uses a smoothing technique, we recommend you use at least `2×N+250` data points prior to the intended usage date for better precision. | ||
|
||
`quotes` is an `IEnumerable<TQuote>` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide](../../docs/GUIDE.md#historical-quotes) for more information. | ||
|
||
## Response | ||
|
||
```csharp | ||
IEnumerable<DemaResult> | ||
``` | ||
|
||
- This method returns a time series of all available indicator values for the `quotes` provided. | ||
- It always returns the same number of elements as there are in the historical quotes. | ||
- It does not return a single incremental indicator value. | ||
- The first `2×N-1` periods will have `null` values since there's not enough data to calculate. | ||
|
||
:hourglass: **Convergence Warning**: The first `2×N+100` periods will have decreasing magnitude, convergence-related precision errors that can be as high as ~5% deviation in indicator values for earlier periods. | ||
|
||
### DemaResult | ||
|
||
| name | type | notes | ||
| -- |-- |-- | ||
| `Date` | DateTime | Date | ||
| `Dema` | decimal | Double exponential moving average for `N` lookback period | ||
|
||
### Utilities | ||
|
||
- [.Find(lookupDate)](../../docs/UTILITIES.md#find-indicator-result-by-date) | ||
- [.RemoveWarmupPeriods()](../../docs/UTILITIES.md#remove-warmup-periods) | ||
- [.RemoveWarmupPeriods(qty)](../../docs/UTILITIES.md#remove-warmup-periods) | ||
|
||
See [Utilities and Helpers](../../docs/UTILITIES.md#utilities-for-indicator-results) for more information. | ||
|
||
## Example | ||
|
||
```csharp | ||
// fetch historical quotes from your feed (your method) | ||
IEnumerable<Quote> quotes = GetHistoryFromFeed("SPY"); | ||
|
||
// calculate 20-period DEMA | ||
IEnumerable<DemaResult> results = quotes.GetDema(20); | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<indicators> | ||
<summary> | ||
Double Exponential Moving Average (DEMA) of the Close price. | ||
See | ||
<see href="https://daveskender.github.io/Stock.Indicators/indicators/DoubleEma/#content">documentation</see> | ||
for more information. | ||
</summary> | ||
<typeparam name="TQuote">Configurable Quote type. See Guide for more information.</typeparam> | ||
<param name="quotes">Historical price quotes.</param> | ||
<param name="lookbackPeriods">Number of periods in the lookback window.</param> | ||
<returns>Time series of Double EMA values.</returns> | ||
<exception cref="ArgumentOutOfRangeException">Invalid parameter value provided.</exception> | ||
<exception cref="BadQuotesException">Insufficient quotes provided.</exception> | ||
</indicators> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<indicators> | ||
<type name="EMA"> | ||
<summary> | ||
Exponential Moving Average (EMA) of the Close price. | ||
<summary> | ||
Exponential Moving Average (EMA) of the Close price. | ||
See | ||
<see href="https://daveskender.github.io/Stock.Indicators/indicators/Ema/#content">documentation</see> | ||
for more information. | ||
</summary> | ||
<typeparam name="TQuote">Configurable Quote type. See Guide for more information.</typeparam> | ||
<param name="quotes">Historical price quotes.</param> | ||
<param name="lookbackPeriods">Number of periods in the lookback window.</param> | ||
<returns>Time series of EMA values.</returns> | ||
<exception cref="ArgumentOutOfRangeException">Invalid parameter value provided.</exception> | ||
<exception cref="BadQuotesException">Insufficient quotes provided.</exception> | ||
</type> | ||
<type name="DEMA"> | ||
<summary> | ||
Double Exponential Moving Average (DEMA) of the Close price. | ||
See | ||
<see href="https://daveskender.github.io/Stock.Indicators/indicators/Ema/#content">documentation</see> | ||
for more information. | ||
</summary> | ||
<typeparam name="TQuote">Configurable Quote type. See Guide for more information.</typeparam> | ||
<param name="quotes">Historical price quotes.</param> | ||
<param name="lookbackPeriods">Number of periods in the lookback window.</param> | ||
<returns>Time series of Double EMA values.</returns> | ||
<exception cref="ArgumentOutOfRangeException">Invalid parameter value provided.</exception> | ||
<exception cref="BadQuotesException">Insufficient quotes provided.</exception> | ||
</type> | ||
<type name="TEMA"> | ||
<summary> | ||
Triple Exponential Moving Average (TEMA) of the Close price. Note: TEMA is often confused with the alternative TRIX oscillator. | ||
See | ||
<see href="https://daveskender.github.io/Stock.Indicators/indicators/Ema/#content">documentation</see> | ||
for more information. | ||
</summary> | ||
<typeparam name="TQuote">Configurable Quote type. See Guide for more information.</typeparam> | ||
<param name="quotes">Historical price quotes.</param> | ||
<param name="lookbackPeriods">Number of periods in the lookback window.</param> | ||
<returns>Time series of Triple EMA values.</returns> | ||
<exception cref="ArgumentOutOfRangeException">Invalid parameter value provided.</exception> | ||
<exception cref="BadQuotesException">Insufficient quotes provided.</exception> | ||
</type> | ||
<see href="https://daveskender.github.io/Stock.Indicators/indicators/Ema/#content">documentation</see> | ||
for more information. | ||
</summary> | ||
<typeparam name="TQuote">Configurable Quote type. See Guide for more information.</typeparam> | ||
<param name="quotes">Historical price quotes.</param> | ||
<param name="lookbackPeriods">Number of periods in the lookback window.</param> | ||
<returns>Time series of EMA values.</returns> | ||
<exception cref="ArgumentOutOfRangeException">Invalid parameter value provided.</exception> | ||
<exception cref="BadQuotesException">Insufficient quotes provided.</exception> | ||
</indicators> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Triple Exponential Moving Average (TEMA) | ||
|
||
[Triple exponential moving average](https://en.wikipedia.org/wiki/Triple_exponential_moving_average) of the Close price over a lookback window. | ||
Note: TEMA is often confused with the alternative [TRIX](../Trix/README.md#content) oscillator. | ||
[[Discuss] :speech_balloon:](https://github.com/DaveSkender/Stock.Indicators/discussions/256 "Community discussion about this indicator") | ||
|
||
![image](chart.png) | ||
|
||
TEMA is shown as the dotted line above. [EMA](../Ema/README.md#content) (solid line) and [Double EMA](../DoubleEma/README.md#content) (dashed line) are also shown here for comparison. | ||
|
||
```csharp | ||
// usage | ||
IEnumerable<TemaResult> results = | ||
quotes.GetTripleEma(lookbackPeriods); | ||
``` | ||
|
||
## Parameters | ||
|
||
| name | type | notes | ||
| -- |-- |-- | ||
| `lookbackPeriods` | int | Number of periods (`N`) in the moving average. Must be greater than 0. | ||
|
||
### Historical quotes requirements | ||
|
||
You must have at least `4×N` or `3×N+100` periods of `quotes`, whichever is more. Since this uses a smoothing technique, we recommend you use at least `3×N+250` data points prior to the intended usage date for better precision. | ||
|
||
`quotes` is an `IEnumerable<TQuote>` collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See [the Guide](../../docs/GUIDE.md#historical-quotes) for more information. | ||
|
||
## Response | ||
|
||
```csharp | ||
IEnumerable<TemaResult> | ||
``` | ||
|
||
- This method returns a time series of all available indicator values for the `quotes` provided. | ||
- It always returns the same number of elements as there are in the historical quotes. | ||
- It does not return a single incremental indicator value. | ||
- The first `3×N-2` periods will have `null` values since there's not enough data to calculate. Also note that we are using the proper [weighted variant](https://en.wikipedia.org/wiki/Triple_exponential_moving_average) for TEMA. If you prefer the unweighted raw 3 EMAs value, please use the `Ema3` output from the [TRIX](../Trix/README.md) oscillator instead. | ||
|
||
:hourglass: **Convergence Warning**: The first `3×N+100` periods will have decreasing magnitude, convergence-related precision errors that can be as high as ~5% deviation in indicator values for earlier periods. | ||
|
||
### TemaResult | ||
|
||
| name | type | notes | ||
| -- |-- |-- | ||
| `Date` | DateTime | Date | ||
| `Tema` | decimal | Triple exponential moving average for `N` lookback period | ||
|
||
### Utilities | ||
|
||
- [.Find(lookupDate)](../../docs/UTILITIES.md#find-indicator-result-by-date) | ||
- [.RemoveWarmupPeriods()](../../docs/UTILITIES.md#remove-warmup-periods) | ||
- [.RemoveWarmupPeriods(qty)](../../docs/UTILITIES.md#remove-warmup-periods) | ||
|
||
See [Utilities and Helpers](../../docs/UTILITIES.md#utilities-for-indicator-results) for more information. | ||
|
||
## Example | ||
|
||
```csharp | ||
// fetch historical quotes from your feed (your method) | ||
IEnumerable<Quote> quotes = GetHistoryFromFeed("SPY"); | ||
|
||
// calculate 20-period TEMA | ||
IEnumerable<TemaResult> results = quotes.GetTripleEma(20); | ||
``` |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
|
||
namespace Skender.Stock.Indicators | ||
{ | ||
[Serializable] | ||
public class TemaResult : ResultBase | ||
{ | ||
public decimal? Tema { get; set; } | ||
} | ||
} |
Oops, something went wrong.