getCalculatedLength (SDK Trading)
getCalculatedLength is a Fintechee API to get the length of the custom indicator's data that have been calculated.
number
getCalculatedLength(context) ⇒ Indicator SDK This function gets the length of data calculated.
Kind: global function
Returns: number
- the length of data calculated.
Param | Type | Description |
---|---|---|
context | object | the name should be the same with the name of parameter of indicatorFunction |
getCalculatedLength (SDK Trading)
registerIndicator("name", "desciption", function (context) {
var dataInput = getDataInput(context, 0)
var dataOutput = getDataOutput(context, "output")
var shift = getIndiParameter(context, "shift")
var calculatedLength = getCalculatedLength(context)
var i = calculatedLength
if (i == 0) {
dataOutput[0] = 0
i++
} else {
i--
}
while (i < dataInput.length) {
dataOutput[i] = Math.random()
i++
}
if (shift != null && calculatedLength == 0) {
setIndiShift(context, "output", shift)
}
},[{
name: "shift",
value: 5,
required: true,
type: "Integer",
range: [-10,10]
}],
[{
name: DATA_NAME.CLOSE,
index: 0
}],
[{
name: "output",
visible: true,
renderType: RENDER_TYPE.HISTOGRAM,
color: "steelblue"
}],
WHERE_TO_RENDER.SEPARATE_WINDOW)