فهرست منبع

ATR Trailing Stoploss

- use high
Alexey Kim 22 ساعت پیش
والد
کامیت
598e9a855a
3فایلهای تغییر یافته به همراه9 افزوده شده و 9 حذف شده
  1. 1 1
      indicator/art_trailing_stop_loss.go
  2. 3 3
      strategy/alpaca/qqq15/strategy.go
  3. 5 5
      strategy/alpaca/qqq15_nodelay/strategy.go

+ 1 - 1
indicator/art_trailing_stop_loss.go

@@ -43,7 +43,7 @@ func AtrTrailingStopLoss(m sentio.Market,
 		atr := talib.Atr(h, l, c, int(length))
 		trailing := make([]float64, len(atr))
 		for i := range atr {
-			trailing[i] = c[i] - multiplier*atr[i]
+			trailing[i] = h[i] - multiplier*atr[i]
 		}
 
 		if hhv > 1 {

+ 3 - 3
strategy/alpaca/qqq15/strategy.go

@@ -8,9 +8,9 @@ import (
 )
 
 const (
-	ATR_MULTIPLIER = 1.5
-	ATR_PERIOD     = 14
-	ATR_HHV        = 4
+	ATR_MULTIPLIER = 3
+	ATR_PERIOD     = 21
+	ATR_HHV        = 10
 )
 
 var Strategy = qqq{}

+ 5 - 5
strategy/alpaca/qqq15_nodelay/strategy.go

@@ -7,9 +7,9 @@ import (
 )
 
 const (
-	ATR_MULTIPLIER = 1.5
-	ATR_PERIOD     = 14
-	ATR_HHV        = 4
+	ATR_MULTIPLIER = 3
+	ATR_PERIOD     = 21
+	ATR_HHV        = 10
 )
 
 var Strategy = qqq{}
@@ -85,7 +85,7 @@ func (strategy qqq) Handle(market sentio.Market, probability sentio.Probability)
 	for i := range orders {
 		if strategy.PositionSymbols()[sentio.LONG] == orders[i].GetSymbol() &&
 			probability.Value < 1.0008 {
-			if _, err = market.CloseOrder(orders[i].GetId()); err != nil {
+			if _, err = market.CloseOrder(orders[i]); err != nil {
 				return err
 			}
 
@@ -95,7 +95,7 @@ func (strategy qqq) Handle(market sentio.Market, probability sentio.Probability)
 
 		if strategy.PositionSymbols()[sentio.SHORT] == orders[i].GetSymbol() &&
 			probability.Value > .9998 {
-			if _, err = market.CloseOrder(orders[i].GetId()); err != nil {
+			if _, err = market.CloseOrder(orders[i]); err != nil {
 				return err
 			}