formula

package
v1.3.12 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FloatDefault float64 = 0.00
)

Variables

This section is empty.

Functions

func BARSSINCEN

func BARSSINCEN[V int64 | float64](slice []V, n int, iterator func(a, b V) bool) int

BARSSINCEN N周期内第一次X不为0到现在的周期数,N为常量

func CROSS

func CROSS[V int64 | float64](a, b []V, n int) bool

CROSS 金叉判断 当期 a > b 并且 前一期 a < b a和b对调就是死叉

func EXMPA

func EXMPA(hds []float64, n int, x int) float64

若求X的N日指数平滑移动平均, 则表达式为: EMA(X, N) 算法是: 若Y=EMA(X, N), 则Y=[2*X+(N-1)*Y’]/(N+1), 其中Y’表示上一周期的Y值。

func HHV

func HHV[V int64 | float64](slice []V, n int) V

HHV 计算n周期内的flag的最大值

func LLV

func LLV[V int64 | float64](slice []V, n int) V

LLV 计算n周期内的flag的最小值

func MA

func MA[V int64 | float64](slice []V, n int) V

计算n周期的算术平均值

func REF

func REF(slice []float64, n int) float64

REF 引用

func SMA

func SMA(slice []float64, n, m int) float64

这个sma公式有个计算起点,当周期数小于等于n时,是按ma计算的。超过n后,就可以按sma计算了。 示例:Y = SMA(收盘价,30,2)= [(当天的收盘价* 2 + Y *前一个交易日的(30-1))/ 30,即今天收盘价的扩展乘以2并计算30天平均值,今天的价值对平均值有很大的影响,即,平均价格中的权重很大。 在大多数情况下,M取1而不取2,Y是循环参考或先前的值,类似于a = a +1。严格来说,Y不是平均值,包括股票上市首日的价值,但权重越远,价值就越小,其变化比平均值ma慢。

SMA SMA(X,N,M), 求X的N日移动平均,M为权重。算法:若Y=SMA(X,N,M) 则 Y=(M*X+(N-M)*Y')/N,其中Y'表示上一周期Y值,N必须大于M。

func SUM

func SUM[V int64 | float64](slice []V, n int) V

SUM 计算n周期内的flag的总和

Types

type BarHandler

type BarHandler = func(a, b float64) bool

指标计算接口

Jump to

Keyboard shortcuts

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