- on the desktop, by the chart of the user, like a built-in indicator;
- on the server, which calculates it once for every chart with the same symbol, bars and parameters, and sends what it draws to the charts which show it.
The portable API
On the desktop these interfaces are the real objects of the chart, with no layer in between. On the server they are objects which record what the indicator draws.
What is different on the server
The server has no user in front of it. So:- The style of a series is not there. Colors, width and style of a series are settings of each user. The indicator declares the defaults in the series attribute, the chart of each user applies its own.
- Colors stay references. A theme color or a series color is resolved by each chart, see Colors.
- The history is calculated with
OnOpenandOnClose. The trades of the history are not replayed. - Messages and sounds do nothing for now.
- Some data does not exist: the order book, other indicators of the chart, other symbols. These members are desktop only.
Writing code which works in both places
- Use theme colors and series colors, not fixed ones, for anything the user should be able to change.
- Take the history from the bars (
BarVars,VolTotList, volume by price) and useOnTickfor realtime only. - Do not keep state in static fields: the server runs many instances of the same indicator.
- Do not read the clock, files or the network. An indicator has to give the same result for the same bars.
- Keep
OnLoadcomplete: everything a calculation needs is reset there.
Checking your indicator
An indicator which uses only the portable API can be calculated on the server. One which uses a[DesktopOnly] member still works on your chart, and is calculated on the desktop wherever it is used. The Book Imbalance example shows the difference.