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