Explorar el Código

ATR Trailing Stoploss

- use high
Alexey Kim hace 3 días
padre
commit
598e9a855a

+ 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
 			}