Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace and "What if" Scenarios #665

Closed
ozum opened this issue Apr 14, 2024 · 4 comments · Fixed by #734
Closed

Replace and "What if" Scenarios #665

ozum opened this issue Apr 14, 2024 · 4 comments · Fixed by #734

Comments

@ozum
Copy link
Contributor

ozum commented Apr 14, 2024

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,

@bennycode
Copy link
Owner

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.

@ozum
Copy link
Contributor Author

ozum commented Apr 16, 2024

I have some thoughts, but first could you please check #668? If my findings in #668 are true, I will shape my suggestion accordingly.

@bennycode
Copy link
Owner

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

@bennycode
Copy link
Owner

bennycode commented Jan 13, 2025

Hi @ozum, I just published trading-signals v6 and it comes with support for the replace parameter in the update function for all indicators. The indicators now even have their own replace function. Hope it works for you! 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants