Skip to content

Commit 617dbde

Browse files
committed
Add ADL, CHAIKIN indicators
1 parent 46274d3 commit 617dbde

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,6 @@ Port of Python library [peerchemist/finta](https://github.com/peerchemist/finta)
2828
- **STOCH** (Stochastic Oscillator %K)
2929
- **STOCHD** (Stochastic Oscillator %D)
3030
- **StochRSI** (Stochastic RSI)
31+
- **ADL** (Accumulation/Distribution Line)
32+
- **CHAIKIN** (Chaikin Oscillator)
3133
- **VZO** (Volume Zone Oscillator)

fta.go

+29
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,32 @@ func StochRSI(price series.Data, rsiPeriod, stochPeriod int, adjust bool) (stoch
320320

321321
return stochRSI
322322
}
323+
324+
// The accumulation/distribution line was created by Marc Chaikin to determine the flow of money into or out of a security.
325+
// It should not be confused with the advance/decline line. While their initials might be the same, these are entirely different indicators,
326+
// and their uses are different as well. Whereas the advance/decline line can provide insight into market movements,
327+
// the accumulation/distribution line is of use to traders looking to measure buy/sell pressure on a security or confirm the strength of a trend.
328+
func ADL(high, low, close series.Data) (adl series.Data) {
329+
subCloseLow := close.Clone().Sub(low)
330+
subHighClose := high.Clone().Sub(close)
331+
subHighLow := high.Clone().Sub(low)
332+
333+
mfv := subCloseLow.Sub(subHighClose).Div(subHighLow)
334+
335+
return mfv.Cumsum()
336+
}
337+
338+
// Chaikin Oscillator, named after its creator, Marc Chaikin, the Chaikin oscillator is an oscillator that measures the accumulation/distribution
339+
// line of the moving average convergence divergence (MACD). The Chaikin oscillator is calculated by subtracting a 10-day exponential moving average (EMA)
340+
// of the accumulation/distribution line from a three-day EMA of the accumulation/distribution line, and highlights the momentum implied by the
341+
// accumulation/distribution line.
342+
func CHAIKIN(high, low, close series.Data, adjust bool) (chaikin series.Data) {
343+
adl := ADL(high, low, close)
344+
345+
short := adl.EWM(series.AlphaSpan, 3, adjust, false).Mean()
346+
long := adl.EWM(series.AlphaSpan, 10, adjust, false).Mean()
347+
348+
chaikin = short.Sub(long)
349+
350+
return chaikin
351+
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/WinPooh32/fta
22

33
go 1.13
44

5-
require github.com/WinPooh32/series v0.3.11
5+
require github.com/WinPooh32/series v0.3.13

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
github.com/WinPooh32/math v1.0.5 h1:w3F/tVyIPjiC0S3uRq+ioXDIjE2/p3n8gd9z0Tkegq4=
22
github.com/WinPooh32/math v1.0.5/go.mod h1:/1wbgRu0iLftvv22oePIv967br82NfIcRPX5cAyQP6I=
3-
github.com/WinPooh32/series v0.3.11 h1:CamzsbwCy75ejQr3qnASNHIPr9nF/6Ok79yX0yL4jwE=
4-
github.com/WinPooh32/series v0.3.11/go.mod h1:0Lm8KcG/eI1Vei8QK8cCqMN1Sy1RlUHctaQkGGAVS1Q=
3+
github.com/WinPooh32/series v0.3.13 h1:/5Ictv8S1HG8yzG8GdusbZqvb1PY171Dd3cDuPrU4Ro=
4+
github.com/WinPooh32/series v0.3.13/go.mod h1:0Lm8KcG/eI1Vei8QK8cCqMN1Sy1RlUHctaQkGGAVS1Q=

0 commit comments

Comments
 (0)