Syntax
Public function CorrelationAnalysis(ByRef Source1 As Field, ByRef Source2 As Field) As Double
Overview
Correlation analysis is used to show the relationship between two different securities or indicators.
Note
The CorrelationAnalysis function returns a double value indicating the relationship between two Field objects.
The Field objects may contain price, indicator or other values.
Class: General
Parameters
Return Type |
Double that indicate the relationship between two Field. |
Default Field Name(s) |
EnvelopeTop, EnvelopeBottom. |
Sample
Public Sub main()
'Variables
Dim _symbolInfo As VTLGeneral.CSymbol=ClientCode.GetSymbolByName("GOLD")
Dim DB As New VTLGeneral.Database()
Dim rsOHLCV As New VTLGeneral.RecordSet()
Dim RecordCount As Integer
Dim m_Recordset As VTLGeneral.RecordSet
Dim _historyData As object()
Dim output As String
Dim Record As Integer
Dim m_High As VTLGeneral.Field
Dim m_Low As VTLGeneral.Field
Dim m_Open As VTLGeneral.Field
Dim m_Close As VTLGeneral.Field
Dim j As Integer = 0
Dim i As Integer = 0
Dim _recordCount As Integer =100
m_Recordset = DB.CreateRecord
m_Open = New VTLGeneral.Field
m_High = New VTLGeneral.Field
m_Low = New VTLGeneral.Field
m_Close = New VTLGeneral.Field
m_Recordset = DB.CreateRecord
m_High = New VTLGeneral.Field
m_Close = New VTLGeneral.Field
DB.RecordCount = _recordCount
RecordCount = _recordCount
'Initialize Recordsets
m_High.initialize(_recordCount, "High")
m_Close.initialize(_recordCount, "Close")
'load high, low ,open and data
_historyData = ClientCode.GetChartHistory(_symbolInfo.ID, VTLGeneral.ENUM_PERIOD.Day,VTLGeneral.ENUM_HISTORY_TYPE.HIS_HIGH, _recordCount)
For i = 1 To _recordCount-1
m_High.setValue(i,_historyData(i))
Next
_historyData = ClientCode.GetChartHistory(_symbolInfo.ID, VTLGeneral.ENUM_PERIOD.Day,VTLGeneral.ENUM_HISTORY_TYPE.HIS_CLOSE, _recordCount)
For i = 1 To _recordCount-1
m_Close.setValue(i,_historyData(i))
Next
m_Recordset.addField(m_High)
m_Recordset.addField(m_Close)
Dim gnl As New VTLGeneral.General( )
GUI.MsgDialog( gnl.CorrelationAnalysis(m_High,m_Close))
End Sub
See Also
Back to VTL Server Script Index
|