Fixed MORE bugs

This commit is contained in:
Luke I. Wilson
2023-05-24 15:58:59 -05:00
parent 46fd55ab8d
commit b5434fb5de
10 changed files with 205 additions and 55 deletions

View File

@@ -21,9 +21,9 @@ func (s *SMAStrategy) Next(t *auto.Trader) {
sma2 := t.Data().Closes().Copy().Rolling(s.period2).Mean()
// If the shorter SMA crosses above the longer SMA, buy.
if auto.CrossoverIndex(*t.Data().Date(-1), sma1, sma2) {
t.Buy(1000)
t.Buy(1000, 0, 0)
} else if auto.CrossoverIndex(*t.Data().Date(-1), sma2, sma1) {
t.Sell(1000)
t.Sell(1000, 0, 0)
}
}