Skip to content

Commit 938eb4b

Browse files
authored
Merge pull request #23 from brhurley/master
Added Moving Average tracking page
2 parents c610793 + b729eef commit 938eb4b

5 files changed

+145
-2
lines changed

FAQ.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public TradingRecord run(Strategy strategy, OrderType orderType) {
1818
return run(strategy, orderType, NaN);
1919
}
2020
```
21-
The standard value for this mehtod is `OrderType.BUY`. That means entry signals generated by your `Strategy` will create a buying order and every exit signal will create a complementary (in this case `OrderType.SELL`) order. If you change this parameter to `OrderType.SELL`, the `BarSeriesManager` will create **selling** orders for entry signals and **buying** orders for exit signals.
21+
The standard value for this method is `OrderType.BUY`. That means entry signals generated by your `Strategy` will create a buying order and every exit signal will create a complementary (in this case `OrderType.SELL`) order. If you change this parameter to `OrderType.SELL`, the `BarSeriesManager` will create **selling** orders for entry signals and **buying** orders for exit signals.
2222
* **Note:** At the moment it is only possible to run a `Strategy` with [long](https://www.investopedia.com/terms/l/long.asp) (buy-sell) **or** with [short](https://www.investopedia.com/terms/s/short.asp) (sell-buy) trades. There is no possibility to mix short and long trades in one and the same run done by the `BarSeriesManager`.
2323

2424
### What does `Num` or `Function<Number, Num>`?

Moving-Average-Indicators.md

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# Summary of Moving Averages
2+
3+
## History of Moving Averages
4+
Moving averages have been a cornerstone of technical analysis for decades. They were first developed in the early 20th century to help traders and analysts smooth out price data and identify trends in financial markets. Among the earliest applications was the **Simple Moving Average (SMA)**, which gained popularity due to its simplicity. Over time, more sophisticated moving averages, such as the **Exponential Moving Average (EMA)**, were introduced to address the lag associated with the SMA. Notable contributions include the work of J. Welles Wilder, who developed the **Wilder’s Moving Average** in his 1978 book, *New Concepts in Technical Trading Systems*. The development of modern computational tools has further enabled innovations like the **Zero Lag EMA (ZLEMA)** and **Displaced Moving Average (DMA)**.
5+
6+
---
7+
8+
## What Moving Averages Can Tell Us
9+
Moving averages provide insight into market trends and price behavior by smoothing out short-term fluctuations in price data. Key takeaways include:
10+
11+
- **Trend Direction**: The slope of a moving average indicates the current trend. An upward slope suggests a bullish trend, while a downward slope indicates a bearish trend.
12+
- **Support and Resistance**: Moving averages often act as dynamic support or resistance levels where prices may reverse or consolidate.
13+
- **Market Momentum**: Comparing shorter and longer-term moving averages (e.g., 50-day vs. 200-day) can reveal momentum and potential shifts in market sentiment.
14+
15+
---
16+
17+
## How Moving Averages Are Used
18+
Moving averages are versatile tools used in a variety of ways:
19+
20+
1. **Identifying Trends**:
21+
- Traders use moving averages to determine whether the market is trending upwards, downwards, or sideways.
22+
23+
2. **Crossover Strategies**:
24+
- Common strategies involve using two moving averages of different lengths. For example:
25+
- A **Golden Cross** occurs when a short-term moving average (e.g., 50-day) crosses above a long-term moving average (e.g., 200-day), signaling a potential uptrend.
26+
- A **Death Cross** occurs when a short-term moving average crosses below a long-term moving average, signaling a potential downtrend.
27+
28+
3. **Support and Resistance**:
29+
- Moving averages are often used as dynamic support/resistance levels in price charts, providing entry or exit points.
30+
31+
4. **Volatility Reduction**:
32+
- By smoothing out noise in price data, moving averages help traders focus on the overall trend rather than short-term fluctuations.
33+
34+
5. **Baseline for Indicators**:
35+
- Many technical indicators, such as Bollinger Bands, MACD, and RSI, are built using moving averages as a foundation.
36+
37+
---
38+
39+
## Moving Averages in TA4J
40+
41+
| Abbreviation | Full Name | Indicator Name | Moving Average Type |
42+
|--------------|-----------------------------------------------|----------------------------|--------------------------------|
43+
| ATMA | Asymmetric Triangular Moving Average | ATMAIndicator | Specialized Moving Average |
44+
| DEMA | Double Exponential Moving Average | DoubleEMAIndicator | Exponential Moving Average |
45+
| DMA | Displaced Moving Average | DMAIndicator | Specialized Moving Average |
46+
| EDMA | Exponential Displaced Moving Average | EDMAIndicator | Exponential Moving Average |
47+
| EMA | Exponential Moving Average | EMAIndicator | Exponential Moving Average |
48+
| HMA | Hull Moving Average | HMAIndicator | Specialized Moving Average |
49+
| JMA | Jurik Moving Average | JMAIndicator | Specialized Moving Average |
50+
| KAMA | Kaufman Adaptive Moving Average | KAMAIndicator | Adaptive Moving Average |
51+
| KiJunV2 | Kihon Moving Average | KiJunV2Indicator | Specialized Moving Average |
52+
| LSMA | Least Squares Moving Average | LSMAIndicator | Polynomial-Based Moving Average|
53+
| LWMA | Linear Weighted Moving Average | LWMAIndicator | Weighted Moving Average |
54+
| McGinley | McGinleys Moving Average | McGinleyMAIndicator | Adaptive Moving Average |
55+
| MMA | Modified Moving Average | MMAIndicator | Exponential Moving Average |
56+
| SMA | Simple Moving Average | SMAIndicator | Simple Moving Average |
57+
| SGMA | Savitzky-Golay Moving Average | SGMAIndicator | Polynomial-Based Moving Average|
58+
| SMMA | Smoothed Moving Average | SMMAIndicator | Smoothed Moving Average |
59+
| TEMA | Triple Exponential Moving Average | TripleEMAIndicator | Exponential Moving Average |
60+
| TMA | Triangular Moving Average | TMAIndicator | Simple Moving Average |
61+
| VIDYA | Chandes Variable Index Dynamic Moving Average | VIDYAIndicator | Adaptive Moving Average |
62+
| VMA | Variable Moving Average | | Adaptive Moving Average |
63+
| VWMA | Volume Weighted Moving Average | | Weighted Moving Average |
64+
| WilderMA | Wilders Moving Average | WildersMAIndicator | Smoothed Moving Average |
65+
| WMA | Weighted Moving Average | WMAIndicator | Weighted Moving Average |
66+
| ZLEMA | Zero Lag Exponential Moving Average | ZLEMAIndicator | Exponential Moving Average |
67+
68+
69+
## Classification of Moving Averages
70+
71+
### 1. Simple Moving Averages
72+
- These averages assign equal weight to all data points in the period.
73+
- **Indicators**:
74+
- SMA (Simple Moving Average)
75+
- TMA (Triangular Moving Average)
76+
77+
---
78+
79+
### 2. Weighted Moving Averages
80+
- These averages assign different weights to data points, typically emphasizing recent data.
81+
- **Indicators**:
82+
- LWMA (Linear Weighted Moving Average)
83+
- WMA (Weighted Moving Average)
84+
- VWMA (Volume Weighted Moving Average)
85+
86+
---
87+
88+
### 3. Exponential Moving Averages
89+
- These averages assign exponentially increasing weights to recent data.
90+
- **Indicators**:
91+
- EMA (Exponential Moving Average)
92+
- ZLEMA (Zero Lag Exponential Moving Average)
93+
- DEMA (Double Exponential Moving Average)
94+
- TEMA (Triple Exponential Moving Average)
95+
- EDMA (Exponential Displaced Moving Average)
96+
97+
---
98+
99+
### 4. Adaptive Moving Averages
100+
- These averages adjust dynamically based on market conditions such as volatility or trend strength.
101+
- **Indicators**:
102+
- KAMA (Kaufman Adaptive Moving Average)
103+
- VIDYA (Chande Variable Index Dynamic Moving Average)
104+
- VMA (Variable Moving Average)
105+
- McGinley (McGinley Moving Average)
106+
107+
---
108+
109+
### 5. Smoothed Moving Averages
110+
- These averages reduce short-term fluctuations to produce a smoother trendline.
111+
- **Indicators**:
112+
- SMMA (Smoothed Moving Average)
113+
- WilderMA (Wilder’s Moving Average)
114+
115+
---
116+
117+
### 6. Polynomial-Based Moving Averages
118+
- These averages use polynomial regression or curve fitting to calculate the trend.
119+
- **Indicators**:
120+
- SGMA (Savitzky-Golay Moving Average)
121+
- LSMA (Least Squares Moving Average)
122+
123+
---
124+
125+
### 7. Specialized Moving Averages
126+
- These averages use unique algorithms or methodologies for specific purposes.
127+
- **Indicators**:
128+
- HMA (Hull Moving Average)
129+
- JMA (Jurik Moving Average)
130+
- ATMA (Asymmetric Triangular Moving Average)
131+
- KiJunV2 (Kihon Moving Average)
132+
- DMA (Displaced Moving Average)
133+
134+
135+
136+
137+
---
138+
139+
## Conclusion
140+
Moving averages remain essential in modern technical analysis due to their simplicity, flexibility, and effectiveness in revealing market trends and dynamics.

Technical-indicators.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ About technical indicators:
99

1010
In ta4j, all technical indicators implement the `Indicator` interface. So a list of all the indicators provided can be found [in the Javadoc](https://oss.sonatype.org/service/local/repositories/releases/archive/org/ta4j/ta4j-core/0.11/ta4j-core-0.11-javadoc.jar/!/index.html).
1111

12+
Ta4j list of [Moving average indicators](Moving-Average-Indicators.html)
13+
1214
### Backtesting indicators
1315

1416
Technicals also need to be backtested on historic data to see how effective they would have been to predict future prices. [Some examples](Usage-examples.html) are available in this sense.

Usage-examples.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ These examples demonstrate different aspects of the Ta4j API. Each example can b
77

88
##### Bar series and Num
99

10-
* [How to build a bar series with differen Num implementation and more](https://github.com/ta4j/ta4j/blob/master/ta4j-examples/src/main/java/ta4jexamples/barSeries/BuildBarSeries.java)
10+
* [How to build a bar series with different Num implementation and more](https://github.com/ta4j/ta4j/blob/master/ta4j-examples/src/main/java/ta4jexamples/barSeries/BuildBarSeries.java)
1111
* [How to build a bar series from trades](https://github.com/ta4j/ta4j/blob/master/ta4j-examples/src/main/java/ta4jexamples/loaders/CsvTradesLoader.java)
1212
* [How to build a bar series from ticks](https://github.com/ta4j/ta4j/blob/master/ta4j-examples/src/main/java/ta4jexamples/loaders/CsvBarsLoader.java)
1313
* [DoubleNum vs BigDecimalNum](https://github.com/ta4j/ta4j/blob/master/ta4j-examples/src/main/java/ta4jexamples/num/CompareNumTypes.java)

_layouts/default.html

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<dd><a href="Getting-started.html">Getting Started</a></dd>
4444
<dd><a href="Bar-series-and-bars.html">Bar series and Bars</a></dd>
4545
<dd><a href="Technical-indicators.html">Technical Indicators</a></dd>
46+
<dd><a href="Moving-Average-Indicators.html">Moving Average Indicators</a></dd>
4647
<dd><a href="Trading-strategies.html">Trading Strategies</a></dd>
4748
<dd><a href="Backtesting.html">Backtesting</a></dd>
4849
<dd><a href="Live-trading.html">Live Trading</a></dd>

0 commit comments

Comments
 (0)