Skip to content

Commit

Permalink
doc: add one more example to chain the indicators together
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Feb 18, 2024
1 parent 97cdf42 commit 35b15c3
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion doc/development/indicator.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,32 @@ To create an EMA indicator instance, again, simply pass the closePrice indicator
ema := indicatorv2.EMA(closePrices, 17)
```

If you want to listen to the EMA value events, just add a callback on the indicator instance:
If you want to listen to the EMA value events, add a callback on the indicator instance:

```go
ema.OnUpdate(func(v float64) { .... })
```


To combine these techniques together:

```go

// use dot import to use the constructors as helpers
import . "github.com/c9s/bbgo/pkg/indicator/v2"

func main() {
// you should get the correct stream instance from the *bbgo.ExchangeSession instance
stream := &types.Stream{}

ema := EMA(
ClosePrices(
KLines(stream, types.Interval1m)), 14)
_ = ema
}
```


## Adding New Indicator

Adding a new indicator is pretty straightforward. Simply create a new struct and insert the necessary parameters as
Expand Down

0 comments on commit 35b15c3

Please sign in to comment.