art_trailing_stop_loss.go 422 B

12345678910111213141516171819
  1. package indicator
  2. import (
  3. "git.beejay.kim/Gshopper/sentio/talib"
  4. )
  5. func AtrTrailingStopLoss(inHigh []float64, inLow []float64, inClose []float64, inTimePeriod int, multiplier float64, hhv int) []float64 {
  6. atr := talib.Atr(inHigh, inLow, inClose, inTimePeriod)
  7. sl := make([]float64, len(atr))
  8. for i := range atr {
  9. sl[i] = inClose[i] - multiplier*atr[i]
  10. }
  11. if hhv > 1 {
  12. sl = talib.Max(sl, hhv)
  13. }
  14. return sl
  15. }