Sunday, November 18, 2007

Retrieving Calculations (API)

A number of accessors are available in the API to retrieve various calculations done by indicators and other analysis techniques. The most commonly used are :

BV_RetrievePivotsPrices
BV_RetrievePivotsIdx

To extract pivot info from the DLL after the Swing indicator calculates realtime pivots.

The API allows retrieving such info in a separate C++ program, but it is also possible to do the same within the TradeStation environment. Two sample indicators exist for that purpose:

RetrievePivotPrices
RetrievePivotInfo

The first one is very simple as it only prints pivots prices (normalised or original prices) in the TS debug window (View menu then "EasyLanguage Output Bar").



The second one (which can be improved) goes a little further and tries to calculate Fibonacci retracement and expansion levels when possible. A distinct leg is necessary to calculate retracement levels (38.2%, 50%, 61.8%), and a second leg i.e. a 3rd pivot is needed to calculate expansion levels (also called COP, OP and XOP levels). COP is a 61.8% expansion, OP a 100% expansion, and XOP a 161.8% expansion. Levels are plotted on the right hand side of the screen (L1 to L5). One shall recognise that:
L2 = Fib COP,
L3 = Fib OP,
L4 = Fib XOP.