How to update indicator's values in history

Custom indicators, trading strategies, data export and recording and more...
Serg
Posts: 113
Joined: Mon Jun 11, 2018 12:40 pm
Has thanked: 15 times
Been thanked: 35 times

How to update indicator's values in history

Post by Serg » Tue May 28, 2019 6:42 pm

Here is a typical scenario: You have implemented an indicator, which has some UI configuration. Once user changes the settings, you want also to update the historical part of the indicator.

The solution is to use IndicatorModifiable object instead of Indicator. It supports two additional methods:

Code: Select all

void addPoint(long timestamp, double value);
void clear(long fromTimestamp, long toTimestamp);

Javadoc
In general, the above and similar information can be found in the API javadoc. Notice the first two items there: AllDataModule, and Api. This is essentially the entire API for addons. The AllDataModule page describes what interfaces your addon can implement to receive the data that it needs. The Api page describes how your addon can call the API. For instance, to create an object of IndicatorModifiable

Code: Select all

@Override
public void initialize(String alias, InstrumentInfo info, Api api, InitialState initialState) {
double initialValue = 0;
IndicatorModifiable line = api.registerIndicatorModifiable("My indicator", GraphType.PRIMARY, initialValue);
}
This javadoc is also included in Bookmap installation: "C:\Program Files\Bookmap\lib\bm-simplified-api-wrapper-javadoc.jar", so you can use it offline. Copy this jar file to some other place, extract it like a zip, for instance, using 7z program, and double click on index.html.