indicatorts
indicatorts copied to clipboard
MACD Strategy doesn't consider crosses
Describe the bug https://github.com/cinar/indicatorts/blob/main/src/strategy/trend/macdStrategy.ts
The strategy will say buy or sell based only on if the macd line is above or below the signal, and not when it crosses.
To Reproduce
import { macdStrategy } from 'indicatorts';
const asset: Asset = {
dates: [],
openings: [],
highs: [],
lows: [],
closings: [
19, 38, 55, 70, 83, 92, 98, 100, 98, 92, 83, 70, 55, 38, 19, 0, -19, -38,
-55, -70, -83, -92, -98, -100, -98, -92, -83, -70, -55, -38, -19, 0, 19, 38,
55, 70, 83, 92, 98, 100,
],
volumes: [],
};
const actions = macdStrategy(asset);
Will produce: [0, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1]
Expected behavior
Only show buy/sell actions on the cross.