mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-23 15:25:14 +00:00
rsicross: add more conditions to rsicross
This commit is contained in:
parent
d730bc8d41
commit
ba909d857d
|
@ -16,8 +16,10 @@ exchangeStrategies:
|
|||
rsicross:
|
||||
symbol: BTCUSDT
|
||||
interval: 5m
|
||||
fastWindow: 3
|
||||
slowWindow: 12
|
||||
fastWindow: 6
|
||||
slowWindow: 18
|
||||
openBelow: 30.0
|
||||
closeAbove: 60.0
|
||||
|
||||
quantity: 0.1
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ type Strategy struct {
|
|||
Interval types.Interval `json:"interval"`
|
||||
SlowWindow int `json:"slowWindow"`
|
||||
FastWindow int `json:"fastWindow"`
|
||||
OpenBelow fixedpoint.Value `json:"openBelow"`
|
||||
CloseAbove fixedpoint.Value `json:"closeAbove"`
|
||||
|
||||
bbgo.OpenPositionOptions
|
||||
}
|
||||
|
@ -56,6 +58,10 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
|||
rsiCross.OnUpdate(func(v float64) {
|
||||
switch indicatorv2.CrossType(v) {
|
||||
case indicatorv2.CrossOver:
|
||||
if s.OpenBelow.Sign() > 0 && fastRsi.Last(0) > s.OpenBelow.Float64() {
|
||||
return
|
||||
}
|
||||
|
||||
opts := s.OpenPositionOptions
|
||||
opts.Long = true
|
||||
|
||||
|
@ -70,6 +76,10 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
|||
}
|
||||
|
||||
case indicatorv2.CrossUnder:
|
||||
if s.CloseAbove.Sign() > 0 && fastRsi.Last(0) < s.CloseAbove.Float64() {
|
||||
return
|
||||
}
|
||||
|
||||
if err := s.OrderExecutor.ClosePosition(ctx, fixedpoint.One); err != nil {
|
||||
logErr(err, "failed to close position")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user