Syntax
Public Function AddCustomIndicator(chart_ID As Long, bufferAry As Variant, startPos As Integer, subWindow As Boolean, Optional win As Long = 0 ,Optional Indicator As String = Custom Indicator)As String
Description
This function is used to add an indicator to the specified chart by a given the buffer array and chart index.
Parameters
Key | Description |
chart_ID | Chart identifier, 0 is the current chart, a value of type Long |
bufferAry | The indicator input array to be drawn. |
startPos | Start position to draw a custom indicator, value of type Integer. |
subWindow | Indicates to drawing a custom indicator in separate panel .if the value true, the indicator will be int he separate panel, otherwise, it will be in the same panel (current panel). |
Win | Panel(Sub window) Number. To Get the panel Number base on the series name, you can callGetSubWindow(). value of type Long. |
Indicator | Indicator name on data window, if the value not set, the name will appear asCustoms indicator , a value of type String. |
Return value
Returns the indicator name as a value of a string. If the function fails, the returned value will be an empty string, otherwise, it will be a string value. To get the detailed error information, one has to call GetLastError() to read the error.
Sample
Dim indKeyDim vchartIdDim vchartNameDim resultValuePublic Sub Main()Dim highArry()vchartId=chartId vchartName=ChartSymbol(Clng(vchartId)) CopyHigh 0,1, bars(0),highArry indKey=AddCustomIndicator(0, highArry,1,False,0,"Indicator")End SubPublic Sub OnTick(SymbolName)if symbolName = ChartSymbol(0) then ObjectSeriesSetValue 0,CSTR(indKey),CLNG(bars(0)),CDBL(GetHigh(0,bars(0)))end ifEnd SubPublic Sub OnCalculate(symbol ,symPeriod, openVal , highVal , lowVal , closeVal )SetIndicatorData 0,CSTR(indKey),CDbl(highVal)End Sub
See Also