trading-signals
trading-signals copied to clipboard
Replace and "What if" Scenarios
Hi,
In the README I saw the replace feature:
// You can replace a previous value (useful for live charts):
sma.update('40', true);
However, it is unavailable for indicators such as DX. Any suggestions on replacing the last candle and the result of DX?
const dx = new DX(14);
// I want to see results for what-if scenarios.
const dxA = dx.update( { high: 10, low: 3, close: 2 } );
// I want to see the result without the previous update
const dxB = dx.update( { high: 8, low: 2, close: 6 }, true );
Thanks,
Hi @ozum, the "replace" functionality is not yet available for all indicators. It's an early draft by @iam-rohid and myself and we are open to suggestions and Pull Requests.
I have some thoughts, but first could you please check #668? If my findings in #668 are true, I will shape my suggestion accordingly.
Hi @ozum, the DX indicator doesn't have the "replace" functionality yet. To build it, it would be necessary to cache all its internal states (so a previous and current value can be stored) and forward the replace parameter to every call of setResult like here: https://github.com/bennycode/trading-signals/blob/v5.0.3/src/DX/DX.ts#L87