indicators

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: GPL-3.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

View Source
const (
	//Open value will be used for the data
	Open = iota
	//High value will be used for the data
	High
	//Low value will be used for the data
	Low
	//Close value will be used for the data
	Close
	//Volume value will be used for the data
	Volume
	//Default is used when the data is something else than ohlcv
	Default
)

Variables

This section is empty.

Functions

func AddSlices

func AddSlices(slice1, slice2 []float64) []float64

AddSlices adds two slices.

func AddToAll

func AddToAll(slice []float64, val float64) []float64

AddToAll adds a value to all slice elements.

func Avg

func Avg(data []float64) float64

Avg returns 'data' average.

func DivSlice

func DivSlice(slice []float64, n float64) []float64

DivSlice divides a slice by a float.

func EMA

func EMA(series []float64, period int) []float64

EMA is to start a new exponential moving average EMA = Price(t) * k + EMA(y) * (1 – k) t = today, y = yesterday, N = number of days in EMA, k = 2/(N+1)

func ExponentialMovingAverage

func ExponentialMovingAverage(series []float64, period int) []float64

ExponentialMovingAverage is to start a new exponential moving average

func MA

func MA(series []float64, period int) []float64

MA is the Moving Average, other alias are SMA or SimpleMovingAverage

func RMI

func RMI(series []float64, fastRMIlength, fastMomentum, slowRMIlength, slowMomentum int) ([]float64, []float64)

************************* CALCULATION ***************************** FastemaInc = ema(max(close - close[FastMomentum], 0), FastLenght) FastemaDec = ema(max(close[FastMomentum] - close, 0), FastLenght) FastRMI = FastemaDec == 0 ? 0 : 50 - 100 / (1 + FastemaInc / FastemaDec)

SlowemaInc = ema(max(close - close[SlowMomentum], 0), SlowLenght) SlowemaDec = ema(max(close[SlowMomentum] - close, 0), SlowLenght) SlowRMI = SlowemaDec == 0 ? 0 : 50 - 100 / (1 + SlowemaInc / SlowemaDec)

********************************************************************

func ROC100

func ROC100(series []float64, period int) []float64

ROC100 is the Rate Of Change, other alias are RateOfChange

func RateOfChange100

func RateOfChange100(series []float64, period int) []float64

RateOfChange100 is used to get a value between 1 and 100 to pin point the rate of change ROC=(previous value / current value−1)∗100

func SMA

func SMA(series []float64, period int) []float64

SMA is the Moving Average, other alias are MA or SimpleMovingAverage

func SimpleMovingAverage

func SimpleMovingAverage(series []float64, period int) []float64

SimpleMovingAverage to start a new moving average

func StandardDeviation

func StandardDeviation(series []float64, period int) float64

Std returns standard deviation of a slice.

func Std

func Std(slice []float64, period int) float64

func SubSlices

func SubSlices(slice1, slice2 []float64) []float64

SubSlices subtracts two slices.

func Sum

func Sum(data []float64) float64

Sum returns the sum of all elements of 'data'.

Types

type Comparison

type Comparison interface {
	LargerThanValue(number2 float64) bool
	LargerThanInd(ind Indicator)
}

Comparison type interface

type Indicator

type Indicator interface {
	Historic(index int) float64
	Current() float64
	Values() []float64
	Update(values []float64)
	GetDataType() OHLC
	GetName() string
	GetPeriod() int
}

Indicator Interface for all indicators

type IndicatorStruct

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

IndicatorStruct contains a default set of values

func (IndicatorStruct) Current

func (m IndicatorStruct) Current() float64

func (IndicatorStruct) GetName

func (m IndicatorStruct) GetName() string

func (IndicatorStruct) GetParams

func (m IndicatorStruct) GetParams() Param

func (IndicatorStruct) GetPeriod

func (m IndicatorStruct) GetPeriod() int

func (*IndicatorStruct) Historic

func (m *IndicatorStruct) Historic(index int) float64

func (IndicatorStruct) LargerThanInd

func (m IndicatorStruct) LargerThanInd(ind Indicator) []bool

LargerThanInd

func (IndicatorStruct) LargerThanValue

func (m IndicatorStruct) LargerThanValue(ind Indicator) bool

LargerThan the larger than operator

func (*IndicatorStruct) SetParams

func (m *IndicatorStruct) SetParams(low float64, high float64)

func (IndicatorStruct) Values

func (m IndicatorStruct) Values() []float64

type OHLC

type OHLC int

OHLC is the value which will be used for the indicator

type Param

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

type Updatable

type Updatable interface {
	Update()
}

Updatable tells generatinok this it is possible to run Update()

Jump to

Keyboard shortcuts

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