indicators

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignalNeutral = 0
	SignalBuy     = 1
	SignalSell    = -1
	CrossAbove    = 1
	CrossBelow    = -1
)

Variables

This section is empty.

Functions

func BatchCalculate added in v0.0.3

func BatchCalculate(ind Indicator, indices []int) []decimal.Decimal

BatchCalculate calculates an indicator for a range of indices in parallel NOTE: This only works for non-recursive indicators (like SMA, RSI, but NOT EMA) unless the cache is already populated or the indicator handles concurrency internally.

func ClearCache

func ClearCache(indicator cachedIndicator)

func GetCacheCapacity

func GetCacheCapacity(indicator cachedIndicator) int

func GetCacheSize

func GetCacheSize(indicator cachedIndicator) int

func Max

func Max(a, b int) int

func Min

func Min(a, b int) int

func MultiCalculate added in v0.0.3

func MultiCalculate(index int, indicators ...Indicator) []decimal.Decimal

MultiCalculate calculates multiple indicators for a given index in parallel

func NewCache

func NewCache(initialSize int) *cache

func NewPivotPointsIndicator

func NewPivotPointsIndicator(s *series.TimeSeries) *pivotPointsIndicator

NewPivotPointsIndicator returns an indicator that calculates standard Pivot Points. It uses the previous candle's H, L, C to calculate today's levels. Kept for backward compatibility. Panics if s is nil.

func RegisterMetadata added in v0.0.3

func RegisterMetadata(name string, meta IndicatorMetadata)

RegisterMetadata registers metadata for an indicator name

Types

type DerivativeIndicator

type DerivativeIndicator struct {
	Indicator Indicator
}

DerivativeIndicator returns an indicator that calculates the derivative of the underlying Indicator. The derivative is defined as the difference between the value at the previous index and the value at the current index. Eg series [1, 1, 2, 3, 5, 8] -> [0, 0, 1, 1, 2, 3]

func (DerivativeIndicator) Calculate

func (di DerivativeIndicator) Calculate(index int) decimal.Decimal

Calculate returns the derivative of the underlying indicator. At index 0, it will always return 0.

type FibonacciExtension added in v0.0.6

type FibonacciExtension struct {
	High decimal.Decimal
	Low  decimal.Decimal
}

FibonacciExtension holds the swing high and low for calculating standard Fibonacci extension levels above the high or below the low.

func NewFibonacciExtension added in v0.0.6

func NewFibonacciExtension(high, low decimal.Decimal) *FibonacciExtension

NewFibonacciExtension creates an extension calculator from explicit swing high and low values. If high < low, the values are swapped.

func NewFibonacciExtensionFromSeries added in v0.0.6

func NewFibonacciExtensionFromSeries(s *series.TimeSeries, lookback int, index int) *FibonacciExtension

NewFibonacciExtensionFromSeries auto-detects the swing high and low over the lookback window ending at index.

func (*FibonacciExtension) LevelsDown added in v0.0.6

LevelsDown computes extension levels below the swing low.

func (*FibonacciExtension) LevelsUp added in v0.0.6

LevelsUp computes extension levels above the swing high.

type FibonacciExtensionResult added in v0.0.6

type FibonacciExtensionResult struct {
	Level1272 decimal.Decimal
	Level1618 decimal.Decimal
	Level2000 decimal.Decimal
	Level2618 decimal.Decimal
	Level3000 decimal.Decimal
	Level4236 decimal.Decimal
}

FibonacciExtensionResult holds standard extension levels.

type FibonacciRetracement added in v0.0.6

type FibonacciRetracement struct {
	High decimal.Decimal
	Low  decimal.Decimal
}

FibonacciRetracement holds the swing high and low for calculating standard Fibonacci retracement levels.

func NewFibonacciRetracement added in v0.0.6

func NewFibonacciRetracement(high, low decimal.Decimal) *FibonacciRetracement

NewFibonacciRetracement creates a retracement calculator from explicit swing high and low values. If high < low, the values are swapped.

func NewFibonacciRetracementFromSeries added in v0.0.6

func NewFibonacciRetracementFromSeries(s *series.TimeSeries, lookback int, index int) *FibonacciRetracement

NewFibonacciRetracementFromSeries auto-detects the swing high and low over the lookback window ending at index.

func (*FibonacciRetracement) Levels added in v0.0.6

Levels computes all standard Fibonacci retracement levels. Level0 corresponds to the swing low and Level100 to the swing high (low-anchored convention).

type FibonacciRetracementResult added in v0.0.6

type FibonacciRetracementResult struct {
	Level0   decimal.Decimal
	Level236 decimal.Decimal
	Level382 decimal.Decimal
	Level500 decimal.Decimal
	Level618 decimal.Decimal
	Level786 decimal.Decimal
	Level100 decimal.Decimal
}

FibonacciRetracementResult holds all standard retracement levels.

type FloatIndicator added in v0.0.3

type FloatIndicator struct {
	// contains filtered or unexported fields
}

FloatIndicator wraps a slice of float64 as a GenericIndicator

func NewFloatIndicator added in v0.0.3

func NewFloatIndicator(values []float64) FloatIndicator

func (FloatIndicator) Calculate added in v0.0.3

func (fi FloatIndicator) Calculate(index int) float64

type GenericIndicator added in v0.0.3

type GenericIndicator[T any] interface {
	Calculate(int) T
}

GenericIndicator is a generic interface for indicators

type GenericSMA added in v0.0.3

type GenericSMA[T Numeric] struct {
	// contains filtered or unexported fields
}

GenericSMA is a generic Simple Moving Average

func NewGenericSMA added in v0.0.3

func NewGenericSMA[T Numeric](indicator GenericIndicator[T], window int, zero T, add func(T, T) T, div func(T, float64) T) *GenericSMA[T]

func (*GenericSMA[T]) Calculate added in v0.0.3

func (s *GenericSMA[T]) Calculate(index int) T

type IchimokuCloudResult

type IchimokuCloudResult struct {
	TenkanSen   decimal.Decimal
	KijunSen    decimal.Decimal
	SenkouSpanA decimal.Decimal
	SenkouSpanB decimal.Decimal
	ChikouSpan  decimal.Decimal
}

type IchimokuIndicator

type IchimokuIndicator interface {
	Indicator
	TenkanSen(index int) decimal.Decimal
	KijunSen(index int) decimal.Decimal
	SenkouSpanA(index int) decimal.Decimal
	SenkouSpanB(index int) decimal.Decimal
	ChikouSpan(index int) decimal.Decimal
	Cloud(index int) IchimokuCloudResult
}

func NewIchimokuIndicator

func NewIchimokuIndicator(s *series.TimeSeries) IchimokuIndicator

type Indicator

type Indicator interface {
	Calculate(int) decimal.Decimal
}

Indicator is an interface that describes a methodology by which to analyze a trading record for a specific property or trend. For example. MovingAverageIndicator implements the Indicator interface and, for a given index in the timeSeries, returns the current moving average of the prices in that series.

func NewADLineIndicator

func NewADLineIndicator(s *series.TimeSeries) Indicator

NewADLineIndicator returns an indicator that calculates the Accumulation/Distribution Line. https://www.investopedia.com/terms/a/accumulationdistributionplus.asp

func NewADXIndicator

func NewADXIndicator(s *series.TimeSeries, period int) Indicator

func NewALMAIndicator added in v0.0.3

func NewALMAIndicator(indicator Indicator, window int, offset, sigma float64) Indicator

NewALMAIndicator returns a new Arnaud Legoux Moving Average. Panics if indicator is nil or window <= 0.

func NewALMAIndicatorFromSeries added in v0.0.6

func NewALMAIndicatorFromSeries(s *series.TimeSeries, window int, offset, sigma float64) Indicator

NewALMAIndicatorFromSeries returns an ALMA from a TimeSeries using close prices. Panics if s is nil.

func NewATRRatioIndicator added in v0.0.3

func NewATRRatioIndicator(atr, price Indicator) Indicator

func NewATRRatioIndicatorFromSeries added in v0.0.3

func NewATRRatioIndicatorFromSeries(s *series.TimeSeries, atrWindow int) Indicator

func NewAlligatorIndicators added in v0.0.6

func NewAlligatorIndicators(s *series.TimeSeries) (jaw, teeth, lips Indicator)

NewAlligatorIndicators returns the three lines of the Williams Alligator: Jaw (blue), Teeth (red), and Lips (green). Each line is a smoothed moving average (SMMA/MMA) of the median price, displaced forward by a fixed number of bars.

Defaults: Jaw(13,8), Teeth(8,5), Lips(5,3). Panics if s is nil.

func NewAlligatorIndicatorsCustom added in v0.0.6

func NewAlligatorIndicatorsCustom(
	s *series.TimeSeries,
	jawPeriod, jawShift int,
	teethPeriod, teethShift int,
	lipsPeriod, lipsShift int,
) (jaw, teeth, lips Indicator)

NewAlligatorIndicatorsCustom returns Alligator lines with custom periods and shifts. Panics if s is nil or if any period <= 0 or shift < 0.

func NewAroonDownIndicator

func NewAroonDownIndicator(indicator Indicator, window int) Indicator

NewAroonDownIndicator returns a derivative indicator that will return a value based on the number of ticks since the lowest price in the window https://www.investopedia.com/terms/a/aroon.asp

Note: this indicator should be constructed with a either a LowPriceIndicator or a derivative thereof

func NewAroonOscillator added in v0.0.6

func NewAroonOscillator(aroonUp, aroonDown Indicator) Indicator

NewAroonOscillator returns an Aroon Oscillator indicator. The oscillator is calculated as: AroonUp - AroonDown. Callers must supply pre-constructed Aroon Up and Aroon Down indicators (typically built from high-price and low-price sources respectively).

func NewAroonOscillatorFromSeries added in v0.0.6

func NewAroonOscillatorFromSeries(s *series.TimeSeries, window int) Indicator

NewAroonOscillatorFromSeries returns an Aroon Oscillator built from a time series. It automatically creates the high and low price indicators internally. Panics if window < 1.

func NewAroonUpIndicator

func NewAroonUpIndicator(indicator Indicator, window int) Indicator

NewAroonUpIndicator returns a derivative indicator that will return a value based on the number of ticks since the highest price in the window https://www.investopedia.com/terms/a/aroon.asp

Note: this indicator should be constructed with a either a HighPriceIndicator or a derivative thereof

func NewAverageGainsIndicator

func NewAverageGainsIndicator(indicator Indicator, window int) Indicator

NewAverageGainsIndicator Returns a new average gains indicator, which returns the average gains in the given window based on the given indicator.

func NewAverageLossesIndicator

func NewAverageLossesIndicator(indicator Indicator, window int) Indicator

NewAverageLossesIndicator Returns a new average losses indicator, which returns the average losses in the given window based on the given indicator.

func NewAveragePriceIndicator added in v0.0.3

func NewAveragePriceIndicator(series *series.TimeSeries) Indicator

func NewAverageTrueRangeIndicator

func NewAverageTrueRangeIndicator(series *series.TimeSeries, window int) Indicator

NewAverageTrueRangeIndicator returns a base indicator that calculates the average true range of the underlying over a window. Panics if window < 2 (requires at least one true range value to average). https://www.investopedia.com/terms/a/atr.asp

func NewAwesomeOscillatorIndicator

func NewAwesomeOscillatorIndicator(s *series.TimeSeries, windowFast, windowSlow int) Indicator

func NewBollingerBandwidthIndicator added in v0.0.3

func NewBollingerBandwidthIndicator(indicator Indicator, window int, sigma float64) Indicator

NewBollingerBandwidthIndicator returns an indicator which calculates the width of bollinger bands

func NewBollingerLowerBandIndicator

func NewBollingerLowerBandIndicator(indicator Indicator, window int, sigma float64) Indicator

NewBollingerLowerBandIndicator returns a a derivative indicator which returns the lower bound of a bollinger band on the underlying indicator

func NewBollingerUpperBandIndicator

func NewBollingerUpperBandIndicator(indicator Indicator, window int, sigma float64) Indicator

NewBollingerUpperBandIndicator a a derivative indicator which returns the upper bound of a bollinger band on the underlying indicator

func NewCCIIndicator

func NewCCIIndicator(ts *series.TimeSeries, window int) Indicator

NewCCIIndicator Returns a new Commodity Channel Index Indicator http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:commodity_channel_index_cci

func NewCamarillaPivotPointIndicators added in v0.0.6

func NewCamarillaPivotPointIndicators(s *series.TimeSeries) (pp, r1, r2, r3, r4, s1, s2, s3, s4 Indicator)

NewCamarillaPivotPointIndicators returns Camarilla indicators (P, R1-R4, S1-S4). Panics if s is nil.

func NewChaikinMoneyFlowIndicator added in v0.0.6

func NewChaikinMoneyFlowIndicator(s *series.TimeSeries, window int) Indicator

NewChaikinMoneyFlowIndicator returns a Chaikin Money Flow indicator. The CMF is calculated as: Sum(Money Flow Volume, window) / Sum(Volume, window). Panics if window < 1.

func NewChandeMomentumOscillatorIndicator added in v0.0.3

func NewChandeMomentumOscillatorIndicator(indicator Indicator, window int) Indicator

NewChandeMomentumOscillatorIndicator returns a new Chande Momentum Oscillator

func NewChandelierExitLong added in v0.0.6

func NewChandelierExitLong(s *series.TimeSeries, period int, atrWindow int, multiplier float64) Indicator

NewChandelierExitLong returns a long Chandelier Exit indicator. The long exit is calculated as: Highest High(period) - multiplier * ATR(atrWindow). Panics if period < 1 or atrWindow < 2.

func NewChandelierExitShort added in v0.0.6

func NewChandelierExitShort(s *series.TimeSeries, period int, atrWindow int, multiplier float64) Indicator

NewChandelierExitShort returns a short Chandelier Exit indicator. The short exit is calculated as: Lowest Low(period) + multiplier * ATR(atrWindow). Panics if period < 1 or atrWindow < 2.

func NewClosePriceIndicator

func NewClosePriceIndicator(series *series.TimeSeries) Indicator

NewClosePriceIndicator returns an Indicator which returns the close price of a candle for a given index

func NewConstantIndicator

func NewConstantIndicator(constant float64) Indicator

NewConstantIndicator returns an indicator which always returns the same value for any index. It's useful when combined with other, fluxuating indicators to determine when an indicator has crossed a threshold.

func NewCumulativeGainsIndicator

func NewCumulativeGainsIndicator(indicator Indicator, window int) Indicator

NewCumulativeGainsIndicator returns a derivative indicator which returns all gains made in a base indicator for a given window.

func NewCumulativeLossesIndicator

func NewCumulativeLossesIndicator(indicator Indicator, window int) Indicator

NewCumulativeLossesIndicator returns a derivative indicator which returns all losses in a base indicator for a given window.

func NewDEMAIndicator

func NewDEMAIndicator(s *series.TimeSeries, window int) Indicator

func NewDefaultALMAIndicator added in v0.0.6

func NewDefaultALMAIndicator(indicator Indicator) Indicator

NewDefaultALMAIndicator returns an ALMA with default period=9, offset=0.85, sigma=6.0. Panics if indicator is nil.

func NewDefaultAwesomeOscillatorIndicator

func NewDefaultAwesomeOscillatorIndicator(s *series.TimeSeries) Indicator

func NewDefaultChandelierExitLong added in v0.0.6

func NewDefaultChandelierExitLong(s *series.TimeSeries) Indicator

NewDefaultChandelierExitLong returns a long Chandelier Exit indicator with standard defaults: period=22, atrWindow=22, multiplier=3.0.

func NewDefaultChandelierExitShort added in v0.0.6

func NewDefaultChandelierExitShort(s *series.TimeSeries) Indicator

NewDefaultChandelierExitShort returns a short Chandelier Exit indicator with standard defaults: period=22, atrWindow=22, multiplier=3.0.

func NewDefaultEaseOfMovementIndicator added in v0.0.6

func NewDefaultEaseOfMovementIndicator(s *series.TimeSeries) Indicator

NewDefaultEaseOfMovementIndicator returns an EOM with default window=14. Panics if s is nil.

func NewDefaultForceIndexIndicator added in v0.0.6

func NewDefaultForceIndexIndicator(s *series.TimeSeries) Indicator

NewDefaultForceIndexIndicator returns a Force Index with default window=13. Panics if s is nil.

func NewDefaultT3Indicator added in v0.0.6

func NewDefaultT3Indicator(indicator Indicator) Indicator

NewDefaultT3Indicator returns a T3 with default period=6 and volumeFactor=0.7. Panics if indicator is nil.

func NewDefaultVIDYAIndicator added in v0.0.6

func NewDefaultVIDYAIndicator(indicator Indicator) Indicator

NewDefaultVIDYAIndicator returns a VIDYA with default period=14. Panics if indicator is nil.

func NewDerivativeIndicator

func NewDerivativeIndicator(indicator Indicator) Indicator

NewDerivativeIndicator returns an indicator that calculates the derivative of the underlying Indicator.

func NewDifferenceIndicator

func NewDifferenceIndicator(minuend, subtrahend Indicator) Indicator

NewDifferenceIndicator returns an indicator which returns the difference between one indicator (minuend) and a second indicator (subtrahend).

func NewDominantCyclePeriod added in v0.0.3

func NewDominantCyclePeriod(indicator Indicator) Indicator

func NewDonchianLowerBandIndicator added in v0.0.6

func NewDonchianLowerBandIndicator(s *series.TimeSeries, window int) Indicator

NewDonchianLowerBandIndicator returns the Donchian Channel lower band. Panics if window < 1.

func NewDonchianMiddleBandIndicator added in v0.0.6

func NewDonchianMiddleBandIndicator(s *series.TimeSeries, window int) Indicator

NewDonchianMiddleBandIndicator returns the Donchian Channel middle band.

func NewDonchianUpperBandIndicator added in v0.0.6

func NewDonchianUpperBandIndicator(s *series.TimeSeries, window int) Indicator

NewDonchianUpperBandIndicator returns the Donchian Channel upper band. Panics if window < 1.

func NewEMAIndicator

func NewEMAIndicator(indicator Indicator, window int) Indicator

NewEMAIndicator returns a derivative indicator which returns the average of the current and preceding values in the given windowSize, with values closer to current index given more weight. A more in-depth explanation can be found here: http://www.investopedia.com/terms/e/ema.asp

func NewEaseOfMovementIndicator added in v0.0.6

func NewEaseOfMovementIndicator(s *series.TimeSeries, window int) Indicator

NewEaseOfMovementIndicator returns the Ease of Movement indicator smoothed with a simple moving average over the given window. Panics if s is nil or window <= 0.

func NewFAMAIndicator added in v0.0.3

func NewFAMAIndicator(indicator Indicator, fastLimit, slowLimit float64) Indicator

NewFAMAIndicator returns the Following Adaptive Moving Average based on MAMA

func NewFastStochasticIndicator

func NewFastStochasticIndicator(series *series.TimeSeries, timeframe int) Indicator

NewFastStochasticIndicator returns a derivative Indicator which returns the fast stochastic indicator (%K) for the given window. https://www.investopedia.com/terms/s/stochasticoscillator.asp

func NewFibonacciPivotPointIndicators added in v0.0.6

func NewFibonacciPivotPointIndicators(s *series.TimeSeries) (pp, r1, r2, r3, s1, s2, s3 Indicator)

NewFibonacciPivotPointIndicators returns Fibonacci indicators (P, R1-R3, S1-S3). Panics if s is nil.

func NewFibonacciRetracementIndicator added in v0.0.6

func NewFibonacciRetracementIndicator(s *series.TimeSeries, lookback int, level float64) Indicator

NewFibonacciRetracementIndicator returns an Indicator that calculates a specific Fibonacci retracement level (e.g. 0.618) at each index.

func NewFixedDecimalIndicator

func NewFixedDecimalIndicator(vals ...decimal.Decimal) Indicator

func NewFixedIndicator

func NewFixedIndicator(vals ...float64) Indicator

NewFixedIndicator returns an indicator with a fixed set of values that are returned when an index is passed in

func NewForceIndexIndicator added in v0.0.6

func NewForceIndexIndicator(s *series.TimeSeries, window int) Indicator

NewForceIndexIndicator returns the Force Index smoothed with an EMA over the given window. Panics if s is nil or window <= 0.

func NewGainIndicator

func NewGainIndicator(indicator Indicator) Indicator

NewGainIndicator returns a derivative indicator that returns the gains in the underlying indicator in the last bar, if any. If the delta is negative, zero is returned

func NewGatorOscillatorIndicators added in v0.0.6

func NewGatorOscillatorIndicators(s *series.TimeSeries) (upper, lower Indicator)

NewGatorOscillatorIndicators returns the upper and lower histogram bars of the Gator Oscillator derived from the Alligator lines. Upper = |Jaw - Teeth|, Lower = -|Teeth - Lips|. Panics if s is nil.

func NewGatorOscillatorIndicatorsFromAlligator added in v0.0.6

func NewGatorOscillatorIndicatorsFromAlligator(jaw, teeth, lips Indicator) (upper, lower Indicator)

NewGatorOscillatorIndicatorsFromAlligator creates Gator Oscillator bars from pre-computed Alligator indicators, avoiding redundant SMMA computation.

func NewHMAIndicator

func NewHMAIndicator(indicator Indicator, window int) Indicator

func NewHTTrendline added in v0.0.3

func NewHTTrendline(indicator Indicator) Indicator

func NewHighPriceIndicator

func NewHighPriceIndicator(series *series.TimeSeries) Indicator

NewHighPriceIndicator returns an Indicator which returns the high price of a candle for a given index

func NewHilbertTransform added in v0.0.3

func NewHilbertTransform(indicator Indicator) Indicator

func NewKAMAIndicator

func NewKAMAIndicator(s *series.TimeSeries, window int) Indicator

func NewKVOIndicator

func NewKVOIndicator(s *series.TimeSeries) Indicator

NewKVOIndicator returns an indicator that calculates the Klinger Volume Oscillator. https://www.investopedia.com/terms/k/klingeroscillator.asp

func NewKeltnerChannelLowerIndicator

func NewKeltnerChannelLowerIndicator(series *series.TimeSeries, window int) Indicator

func NewKeltnerChannelUpperIndicator

func NewKeltnerChannelUpperIndicator(series *series.TimeSeries, window int) Indicator

func NewLinearRegressionAngleIndicator added in v0.0.6

func NewLinearRegressionAngleIndicator(indicator Indicator, window int) Indicator

NewLinearRegressionAngleIndicator returns an Indicator for the angle in degrees.

func NewLinearRegressionChannel added in v0.0.6

func NewLinearRegressionChannel(indicator Indicator, window int, deviations float64) (mid, upper, lower Indicator)

NewLinearRegressionChannel returns mid, upper, and lower band indicators for a Linear Regression Channel.

func NewLinearRegressionIndicator added in v0.0.6

func NewLinearRegressionIndicator(indicator Indicator, window int) Indicator

NewLinearRegressionIndicator returns an Indicator that calculates the linear regression forecast at each index.

func NewLinearRegressionInterceptIndicator added in v0.0.6

func NewLinearRegressionInterceptIndicator(indicator Indicator, window int) Indicator

NewLinearRegressionInterceptIndicator returns an Indicator for the intercept.

func NewLinearRegressionSlopeIndicator added in v0.0.6

func NewLinearRegressionSlopeIndicator(indicator Indicator, window int) Indicator

NewLinearRegressionSlopeIndicator returns an Indicator for the slope.

func NewLossIndicator

func NewLossIndicator(indicator Indicator) Indicator

NewLossIndicator returns a derivative indicator that returns the losses in the underlying indicator in the last bar, if any. If the delta is positive, zero is returned

func NewLowPriceIndicator

func NewLowPriceIndicator(series *series.TimeSeries) Indicator

NewLowPriceIndicator returns an Indicator which returns the low price of a candle for a given index

func NewMACDHistogramIndicator

func NewMACDHistogramIndicator(macdIdicator Indicator, signalLinewindow int) Indicator

NewMACDHistogramIndicator returns a derivative Indicator based on the MACDIndicator, the result of which is the macd indicator minus it's signalLinewindow EMA. A more in-depth explanation can be found here: http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:macd-histogram

func NewMACDIndicator

func NewMACDIndicator(baseIndicator Indicator, shortwindow, longwindow int) Indicator

NewMACDIndicator returns a derivative Indicator which returns the difference between two EMAIndicators with long and short windows. It's useful for gauging the strength of price movements. A more in-depth explanation can be found here: http://www.investopedia.com/terms/m/macd.asp

func NewMAMAIndicator added in v0.0.3

func NewMAMAIndicator(indicator Indicator, fastLimit, slowLimit float64) Indicator

NewMAMAIndicator returns a MESA Adaptive Moving Average. It also provides FAMA (Following Adaptive Moving Average) as a separate indicator if needed. This implementation returns MAMA.

func NewMFIIndicator

func NewMFIIndicator(s *series.TimeSeries, window int) Indicator

func NewMMAIndicator

func NewMMAIndicator(indicator Indicator, window int) Indicator

NewMMAIndicator returns a derivative indciator which returns the modified moving average of the underlying indictator. An in-depth explanation can be found here: https://en.wikipedia.org/wiki/Moving_average#Modified_moving_average

func NewMaximumDrawdownIndicator

func NewMaximumDrawdownIndicator(ind Indicator, window int) Indicator

NewMaximumDrawdownIndicator returns a derivative Indicator which returns the maximum drawdown of the underlying indicator over a window. Maximum drawdown is defined as the maximum observed loss from peak of an underlying indicator in a given timeframe. Maximum drawdown is given as a percentage of the peak. Use a window value of -1 to include all values present in the underlying indicator. See: https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp

func NewMaximumValueIndicator

func NewMaximumValueIndicator(ind Indicator, window int) Indicator

NewMaximumValueIndicator returns a derivative Indicator which returns the maximum value present in a given window. Use a window value of -1 to include all values in the underlying indicator.

func NewMeanDeviationIndicator

func NewMeanDeviationIndicator(indicator Indicator, window int) Indicator

NewMeanDeviationIndicator returns a derivative Indicator which returns the mean deviation of a base indicator in a given window. Mean deviation is an average of all values on the base indicator from the mean of that indicator.

func NewMedianPriceIndicator added in v0.0.3

func NewMedianPriceIndicator(series *series.TimeSeries) Indicator

func NewMinimumValueIndicator

func NewMinimumValueIndicator(ind Indicator, window int) Indicator

NewMinimumValueIndicator returns a derivative Indicator which returns the minimum value present in a given window. Use a window value of -1 to include all values in the underlying indicator.

func NewMomentumIndicator

func NewMomentumIndicator(s *series.TimeSeries, period int) Indicator

func NewOBVIndicator

func NewOBVIndicator(s *series.TimeSeries) Indicator

func NewOpenPriceIndicator

func NewOpenPriceIndicator(series *series.TimeSeries) Indicator

NewOpenPriceIndicator returns an Indicator which returns the open price of a candle for a given index

func NewParabolicSARIndicator

func NewParabolicSARIndicator(s *series.TimeSeries) Indicator

func NewPercentChangeIndicator

func NewPercentChangeIndicator(indicator Indicator) Indicator

NewPercentChangeIndicator returns a derivative indicator which returns the percent change (positive or negative) made in a base indicator up until the given indicator

func NewPivotPointIndicators added in v0.0.6

func NewPivotPointIndicators(s *series.TimeSeries) (pp, r1, r2, r3, s1, s2, s3 Indicator)

NewPivotPointIndicators returns standard Pivot Point indicators (P, R1-R3, S1-S3). Each level is computed from the previous candle's H, L, C. Panics if s is nil.

func NewRMAIndicator added in v0.0.3

func NewRMAIndicator(indicator Indicator, window int) Indicator

func NewROCIndicator

func NewROCIndicator(s *series.TimeSeries, period int) Indicator

func NewRawEaseOfMovementIndicator added in v0.0.6

func NewRawEaseOfMovementIndicator(s *series.TimeSeries) Indicator

NewRawEaseOfMovementIndicator returns the raw 1-period Ease of Movement.

func NewRawForceIndexIndicator added in v0.0.6

func NewRawForceIndexIndicator(s *series.TimeSeries) Indicator

NewRawForceIndexIndicator returns the raw 1-period Force Index.

func NewRelativeStrengthIndexIndicator

func NewRelativeStrengthIndexIndicator(indicator Indicator, timeframe int) Indicator

NewRelativeStrengthIndexIndicator returns a derivative Indicator which returns the relative strength index of the base indicator in a given time frame. A more in-depth explanation of relative strength index can be found here: https://www.investopedia.com/terms/r/rsi.asp

func NewRelativeStrengthIndicator

func NewRelativeStrengthIndicator(indicator Indicator, timeframe int) Indicator

NewRelativeStrengthIndicator returns a derivative Indicator which returns the relative strength of the base indicator in a given time frame. Relative strength is the average again of up periods during the time frame divided by the average loss of down period during the same time frame

func NewRelativeVigorIndexIndicator

func NewRelativeVigorIndexIndicator(series *series.TimeSeries) Indicator

NewRelativeVigorIndexIndicator returns an Indicator which returns the index of the relative vigor of the prices of a sercurity. Relative Vigor Index is simply the difference of the previous four days' close and open prices divided by the difference between the previous four days high and low prices. A more in-depth explanation of relative vigor index can be found here: https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/relative-vigor-index

func NewRelativeVigorSignalLine

func NewRelativeVigorSignalLine(series *series.TimeSeries) Indicator

NewRelativeVigorSignalLine returns an Indicator intended to be used in conjunction with Relative vigor index, which returns the average value of the last 4 indices of the RVI indicator.

func NewSimpleMovingAverage

func NewSimpleMovingAverage(indicator Indicator, window int) Indicator

NewSimpleMovingAverage returns a derivative Indicator which returns the average of the current value and preceding values in the given windowSize.

func NewSlowStochasticIndicator

func NewSlowStochasticIndicator(k Indicator, window int) Indicator

NewSlowStochasticIndicator returns a derivative Indicator which returns the slow stochastic indicator (%D) for the given window. https://www.investopedia.com/terms/s/stochasticoscillator.asp

func NewStandardDeviationIndicator

func NewStandardDeviationIndicator(ind Indicator) Indicator

NewStandardDeviationIndicator calculates the standard deviation of a base indicator. See https://www.investopedia.com/terms/s/standarddeviation.asp

func NewStandardErrorIndicator added in v0.0.6

func NewStandardErrorIndicator(indicator Indicator, window int) Indicator

NewStandardErrorIndicator returns an Indicator for the standard error.

func NewSuperTrendIndicator

func NewSuperTrendIndicator(s *series.TimeSeries, window int, multiplier float64) Indicator

NewSuperTrendIndicator returns an indicator that calculates the SuperTrend. https://www.tradingview.com/support/solutions/43000634738-supertrend/

func NewT3Indicator added in v0.0.3

func NewT3Indicator(indicator Indicator, window int, vFactor float64) Indicator

NewT3Indicator returns a new Tillson T3 Moving Average. Panics if indicator is nil or window <= 0.

func NewT3IndicatorFromSeries added in v0.0.6

func NewT3IndicatorFromSeries(s *series.TimeSeries, window int, vFactor float64) Indicator

NewT3IndicatorFromSeries returns a T3 from a TimeSeries using close prices. Panics if s is nil.

func NewTEMAIndicator

func NewTEMAIndicator(s *series.TimeSeries, window int) Indicator

func NewTRIMAIndicator added in v0.0.3

func NewTRIMAIndicator(indicator Indicator, window int) Indicator

func NewTRIXIndicator added in v0.0.6

func NewTRIXIndicator(indicator Indicator, window int) Indicator

NewTRIXIndicator returns a TRIX indicator. The indicator is calculated as:

TRIX = ((current TripleEMA - previous TripleEMA) / previous TripleEMA) * 100

Panics if window < 1.

func NewTRIXIndicatorFromSeries added in v0.0.6

func NewTRIXIndicatorFromSeries(s *series.TimeSeries, window int) Indicator

NewTRIXIndicatorFromSeries returns a TRIX built from a time series. Panics if window < 1.

func NewTrendlineIndicator

func NewTrendlineIndicator(indicator Indicator, window int) Indicator

NewTrendlineIndicator returns an indicator whose output is the slope of the trend line given by the values in the window.

func NewTrueRangeIndicator

func NewTrueRangeIndicator(series *series.TimeSeries) Indicator

NewTrueRangeIndicator returns a base indicator which calculates the true range at the current point in time for a series https://www.investopedia.com/terms/a/atr.asp

func NewTypicalPriceIndicator

func NewTypicalPriceIndicator(series *series.TimeSeries) Indicator

NewTypicalPriceIndicator returns an Indicator which returns the typical price of a candle for a given index. The typical price is an average of the high, low, and close prices for a given candle.

func NewUltimateOscillatorIndicator

func NewUltimateOscillatorIndicator(s *series.TimeSeries, period1, period2, period3 int) Indicator

func NewUnstableIndicator added in v0.0.3

func NewUnstableIndicator(indicator Indicator, unstablePeriod int) Indicator

NewUnstableIndicator wraps an indicator and returns ZERO for any index within the unstable period.

func NewVIDYAIndicator added in v0.0.3

func NewVIDYAIndicator(indicator Indicator, window int) Indicator

NewVIDYAIndicator returns a new Variable Index Dynamic Average. Panics if indicator is nil or window <= 0.

func NewVIDYAIndicatorFromSeries added in v0.0.6

func NewVIDYAIndicatorFromSeries(s *series.TimeSeries, window int) Indicator

NewVIDYAIndicatorFromSeries returns a VIDYA from a TimeSeries using close prices. Panics if s is nil.

func NewVWAPIndicator

func NewVWAPIndicator(s *series.TimeSeries) Indicator

NewVWAPIndicator returns an indicator that calculates the Volume Weighted Average Price. This implementation is cumulative since the start of the time series. https://www.investopedia.com/terms/v/vwap.asp

func NewVWMAIndicator added in v0.0.3

func NewVWMAIndicator(indicator, volume Indicator, window int) Indicator

NewVWMAIndicator returns a Volume Weighted Moving Average

func NewVWMAIndicatorFromSeries added in v0.0.3

func NewVWMAIndicatorFromSeries(s *series.TimeSeries, window int) Indicator

NewVWMAIndicatorFromSeries is a helper to create VWMA from series

func NewVarianceIndicator

func NewVarianceIndicator(ind Indicator) Indicator

NewVarianceIndicator provides a way to find the variance in a base indicator, where variances is the sum of squared deviations from the mean at any given index in the time series.

func NewVolumeIndicator

func NewVolumeIndicator(series *series.TimeSeries) Indicator

NewVolumeIndicator returns an indicator which returns the volume of a candle for a given index

func NewVolumeROCIndicator

func NewVolumeROCIndicator(s *series.TimeSeries, period int) Indicator

NewVolumeROCIndicator returns an indicator that calculates the Volume Rate of Change.

func NewVortexIndicator

func NewVortexIndicator(s *series.TimeSeries, period int) Indicator

func NewWMAIndicator

func NewWMAIndicator(indicator Indicator, window int) Indicator

NewWMAIndicator returns a new Weighted Moving Average

func NewWeightedCloseIndicator added in v0.0.3

func NewWeightedCloseIndicator(series *series.TimeSeries) Indicator

func NewWilliamsRIndicator

func NewWilliamsRIndicator(s *series.TimeSeries, window int) Indicator

func NewWindowedStandardDeviationIndicator

func NewWindowedStandardDeviationIndicator(ind Indicator, window int) Indicator

NewWindowedStandardDeviationIndicator returns a indicator which calculates the standard deviation of the underlying indicator over a window

func NewWindowedVWAPIndicator

func NewWindowedVWAPIndicator(s *series.TimeSeries, window int) Indicator

NewWindowedVWAPIndicator returns an indicator that calculates the VWAP over a fixed window.

func NewWoodiePivotPointIndicators added in v0.0.6

func NewWoodiePivotPointIndicators(s *series.TimeSeries) (pp, r1, r2, r3, s1, s2, s3 Indicator)

NewWoodiePivotPointIndicators returns Woodie indicators (P, R1-R3, S1-S3). Panics if s is nil.

func NewZigZagIndicator

func NewZigZagIndicator(s *series.TimeSeries, percent float64) Indicator

NewZigZagIndicator returns an indicator that calculates the ZigZag. It requires a percentage change (e.g. 0.05 for 5%) to form a new leg.

type IndicatorBuilder added in v0.0.3

type IndicatorBuilder struct {
	// contains filtered or unexported fields
}

IndicatorBuilder is a fluent API for building indicators

func NewIndicatorBuilder added in v0.0.3

func NewIndicatorBuilder(s *series.TimeSeries) *IndicatorBuilder

NewIndicatorBuilder starts a new indicator pipeline with a close price indicator

func (*IndicatorBuilder) BollingerLower added in v0.0.3

func (b *IndicatorBuilder) BollingerLower(window int, sigma float64) *IndicatorBuilder

BollingerLower adds a Bollinger Lower Band to the pipeline

func (*IndicatorBuilder) BollingerUpper added in v0.0.3

func (b *IndicatorBuilder) BollingerUpper(window int, sigma float64) *IndicatorBuilder

BollingerUpper adds a Bollinger Upper Band to the pipeline

func (*IndicatorBuilder) Build added in v0.0.3

func (b *IndicatorBuilder) Build() Indicator

Build returns the final indicator

func (*IndicatorBuilder) EMA added in v0.0.3

func (b *IndicatorBuilder) EMA(window int) *IndicatorBuilder

EMA adds an Exponential Moving Average to the pipeline

func (*IndicatorBuilder) MACD added in v0.0.3

func (b *IndicatorBuilder) MACD(fast, slow int) *IndicatorBuilder

MACD adds a MACD indicator to the pipeline

func (*IndicatorBuilder) RSI added in v0.0.3

func (b *IndicatorBuilder) RSI(window int) *IndicatorBuilder

RSI adds a Relative Strength Index to the pipeline

func (*IndicatorBuilder) SMA added in v0.0.3

func (b *IndicatorBuilder) SMA(window int) *IndicatorBuilder

SMA adds a Simple Moving Average to the pipeline

type IndicatorMetadata added in v0.0.3

type IndicatorMetadata struct {
	Name        string
	Category    string
	Description string
	Inputs      []string
	Lookback    int
}

IndicatorMetadata describes an indicator's properties

func GetMetadata added in v0.0.3

func GetMetadata(name string) (IndicatorMetadata, error)

GetMetadata returns metadata for an indicator name

type Numeric added in v0.0.3

type Numeric interface {
	~float64 | ~int | ~int64 | decimal.Decimal
}

Numeric is a constraint for types that support basic arithmetic

type PivotPointResult

type PivotPointResult struct {
	Pivot      decimal.Decimal
	R1, R2, R3 decimal.Decimal
	S1, S2, S3 decimal.Decimal
}

PivotPointResult holds all levels for standard pivot points.

type SelfDescribingIndicator added in v0.0.3

type SelfDescribingIndicator interface {
	Indicator
	Lookback() int
	Metadata() IndicatorMetadata
}

SelfDescribingIndicator is an Indicator that can describe its requirements and properties

type SignalIndicator added in v0.0.3

type SignalIndicator interface {
	CalculateSignal(int) int
}

func CombineSignals added in v0.0.3

func CombineSignals(signals ...SignalIndicator) []SignalIndicator

func NewCrossoverSignal added in v0.0.3

func NewCrossoverSignal(shortTerm, longTerm Indicator, crossType int) SignalIndicator

func NewMACDSignal added in v0.0.3

func NewMACDSignal(macd, signal Indicator) SignalIndicator

func NewMultiSignal added in v0.0.3

func NewMultiSignal(signals []SignalIndicator, voteThreshold int) SignalIndicator

func NewRSISignal added in v0.0.3

func NewRSISignal(rsi Indicator, overbought, oversold float64) SignalIndicator

func NewSupertrendSignal added in v0.0.3

func NewSupertrendSignal(supertrend Indicator) SignalIndicator

func NewThresholdSignal added in v0.0.3

func NewThresholdSignal(indicator Indicator, upper, lower float64) SignalIndicator

type StreamingEMA added in v0.0.3

type StreamingEMA struct {
	// contains filtered or unexported fields
}

StreamingEMA is a streaming version of EMA

func NewStreamingEMA added in v0.0.3

func NewStreamingEMA(window int) *StreamingEMA

func (*StreamingEMA) Calculate added in v0.0.3

func (s *StreamingEMA) Calculate(index int) decimal.Decimal

func (*StreamingEMA) Next added in v0.0.3

type StreamingIndicator added in v0.0.3

type StreamingIndicator interface {
	Indicator
	Next(val decimal.Decimal) decimal.Decimal
}

StreamingIndicator is an interface for indicators that can be updated with new values in real-time

type StreamingSMA added in v0.0.3

type StreamingSMA struct {
	// contains filtered or unexported fields
}

StreamingSMA is a streaming version of SMA

func NewStreamingSMA added in v0.0.3

func NewStreamingSMA(window int) *StreamingSMA

func (*StreamingSMA) Calculate added in v0.0.3

func (s *StreamingSMA) Calculate(index int) decimal.Decimal

func (*StreamingSMA) Next added in v0.0.3

type TimeSeriesIndicator added in v0.0.3

type TimeSeriesIndicator struct {
	// contains filtered or unexported fields
}

TimeSeriesIndicator is a helper to access TimeSeries from within indicators if needed

func NewTimeSeriesIndicator added in v0.0.3

func NewTimeSeriesIndicator(s *series.TimeSeries) *TimeSeriesIndicator

func (*TimeSeriesIndicator) Calculate added in v0.0.3

func (tsi *TimeSeriesIndicator) Calculate(index int) decimal.Decimal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL