getData (SDK Trading)

getData is a Fintechee API to get the data of the specific chart or indicator by the handle(a kind of selector) of the chart or indicator.

You can call the getChartHandle and the getIndicatorHandle APIs to get the handle of the specific chart or indicator. The handle would be used to get the data in the onTick callback function. So you need to transfer it to the onTick function by setting it as a property of window object.

You need to specify the name to get the corresponding data because the handle may stand for several lines of a chart or indicator. For example, MACD has two lines as the outputted data(main and signal), so you need to make the API know the data of which line to get.

The data returned by the getData API are organized as an array. The index zero of the array(n-length) refers to the oldest data, the latest index(n - 1) refers to the latest data.

getData(context, handle, name) ⇒ array

EA SDK This function gets the data of the specific handle. Phase (this API's scope): onTick | deinit

Kind: global function
Returns: array - data.

Param Type Description
context object the name should be the same with the name of parameter of onTickFunction
handle number the return value of getChartHandle or getIndicatorHandle
name string name of the specific data

getData (SDK Trading)

registerEA(
"test_api",
"An EA to test APIs",
[],
function (context) { // Init()
    var account = getAccount(context, 0)
	var brokerName = getBrokerNameOfAccount(account)
	var accountId = getAccountIdOfAccount(account)
	var symbolName = "EUR/USD"

    window.chartHandle = getChartHandle(context, brokerName, accountId, symbolName, TIME_FRAME.M1)

    window.indiHandle = getIndicatorHandle(context, brokerName, accountId, symbolName, TIME_FRAME.M1, "sma", [{
		name: "period",
		value: 10
	}])
},
function (context) { // Deinit()
},
function (context) { // OnTick()
    var arrClose = getData(context, window.chartHandle, DATA_NAME.CLOSE)
	var arrSma = getData(context, window.indiHandle, "sma")
})