Indicator recalculation

Custom indicators, trading strategies, data export and recording and more...
DGDario
Posts: 14
Joined: Wed Feb 26, 2020 8:39 pm
Has thanked: 6 times

Indicator recalculation

Post by DGDario » Tue Feb 16, 2021 1:11 pm

Hi,
I've developed an indicator that has a parameter configurable.
The only way to recalculate the past when the parameter's configuration changes is saving the data at every interval?

Andry API support
Posts: 548
Joined: Mon Jul 09, 2018 11:18 am
Has thanked: 25 times
Been thanked: 85 times

Re: Indicator recalculation

Post by Andry API support » Tue Feb 16, 2021 2:47 pm

Hi,
If you are using Simplified API you need to call reload() method of your Api object on a parameter change.

Code: Select all

private Api api;

@Override
public void initialize(String alias, InstrumentInfo info, Api api, InitialState initialState) {
    this.api = api;

Code: Select all

//on settings updated
    api.reload();
If you are using Core API you need to call the invalidate() method of the InvalidateInterface object associated with your indicator.

DGDario
Posts: 14
Joined: Wed Feb 26, 2020 8:39 pm
Has thanked: 6 times

Re: Indicator recalculation

Post by DGDario » Wed Feb 17, 2021 9:14 am

I've tryed with the api.reload() but it doesn't recalculate the indicator for the past data

Check the image:
https://ibb.co/30QHw9P

Andry API support
Posts: 548
Joined: Mon Jul 09, 2018 11:18 am
Has thanked: 25 times
Been thanked: 85 times

Re: Indicator recalculation

Post by Andry API support » Wed Feb 17, 2021 10:36 am

Does you module implement HistoricalDataListener or HistoricalModeListener?

DGDario
Posts: 14
Joined: Wed Feb 26, 2020 8:39 pm
Has thanked: 6 times

Re: Indicator recalculation

Post by DGDario » Wed Feb 17, 2021 5:49 pm

Implementing HistoricalDataListener works! thank you Andrey

Post Reply