mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
20 lines
359 B
Go
20 lines
359 B
Go
|
package indicator
|
||
|
|
||
|
type ATRPStream struct {
|
||
|
Float64Series
|
||
|
}
|
||
|
|
||
|
func ATRP2(source KLineSubscription, window int) *ATRPStream {
|
||
|
s := &ATRPStream{}
|
||
|
tr := TR2(source)
|
||
|
atr := RMA2(tr, window, true)
|
||
|
atr.OnUpdate(func(x float64) {
|
||
|
// x is the last rma
|
||
|
k := source.Last(0)
|
||
|
cloze := k.Close.Float64()
|
||
|
atrp := x / cloze
|
||
|
s.PushAndEmit(atrp)
|
||
|
})
|
||
|
return s
|
||
|
}
|