2
0
Prechádzať zdrojové kódy

Indicator

- AtrTrailingStopLoss
Alexey Kim 2 týždňov pred
rodič
commit
eece8ce747
2 zmenil súbory, kde vykonal 20 pridanie a 1 odobranie
  1. 19 0
      indicator/art_trailing_stop_loss.go
  2. 1 1
      talib/talib.go

+ 19 - 0
indicator/art_trailing_stop_loss.go

@@ -0,0 +1,19 @@
+package indicator
+
+import (
+	"git.beejay.kim/Gshopper/sentio/talib"
+)
+
+func AtrTrailingStopLoss(inHigh []float64, inLow []float64, inClose []float64, inTimePeriod int, multiplier float64, hhv int) []float64 {
+	atr := talib.Atr(inHigh, inLow, inClose, inTimePeriod)
+	sl := make([]float64, len(atr))
+	for i := range atr {
+		sl[i] = inClose[i] - multiplier*atr[i]
+	}
+
+	if hhv > 1 {
+		sl = talib.Max(sl, hhv)
+	}
+
+	return sl
+}

+ 1 - 1
talib.go → talib/talib.go

@@ -1,4 +1,4 @@
-package sentio
+package talib
 
 /*
 Copyright 2016 Mark Chenoweth