2016-06-20 6 views
-1

以下のVB.NET 2010が動作しています。しかし、TA-Libのドキュメントに記載されているデフォルト値TA_INTEGER_DEFAULTまたはTA_REAL_DEFAULTをオプションのパラメータとして使用する必要があります。私はそれをコーディングにどのように使用できますか? 現在、私は値を手動で割り当てます(値は何かを知る必要があります)。VB.NET 2010でTA_INTEGER_DEFAULTとTA_REAL_DEFAULTを使用するTA-Lib

Public Sub CalcMACD() 
     ' CALCULATE allocationSize 
     Dim lookback As Integer = TicTacTec.TA.Library.Core.MacdLookback(optInFastPeriod, optInSlowPeriod, optInSignalPeriod) 
     Dim temp As Integer = Math.Max(lookback, startIdx) 
     If (temp > endIdx) Then 
      allocationSize = 0     ' No output 
     Else 
      allocationSize = endIdx - temp + 1 
     End If 

     optInFastPeriod = 12         ' Set optional values <==== HOW TO USE TA_INTEGER_DEFAULT 
     optInSlowPeriod = 26         ' Set optional values <==== HOW TO USE TA_INTEGER_DEFAULT 
     optInSignalPeriod = 9        ' Set optional values <==== HOW TO USE TA_INTEGER_DEFAULT 

     Dim outMACD As Double()              ' Declare output variable type 
     ReDim outMACD(allocationSize) 
     Dim outMACDSignal As Double()             ' Declare output variable type 
     ReDim outMACDSignal(allocationSize) 
     Dim outMACDHist As Double()             ' Declare output variable type 
     ReDim outMACDHist(allocationSize) 

     ' the calculation 
     Dim res As TicTacTec.TA.Library.Core.RetCode = TicTacTec.TA.Library.Core.Macd(startIdx, endIdx, openPrice, optInFastPeriod, optInSlowPeriod, optInSignalPeriod, outBegIdx, outNBElement, outMACD, outMACDSignal, outMACDHist) 


     ' Add result column to Datagridview 
     ' #1 add column to Datagridview1 
     DataGridView1.ColumnCount = DataGridView1.ColumnCount + 3 
     Dim columnID As Integer = DataGridView1.ColumnCount - 3 
     ' #2 define column header 
     DataGridView1.Columns(columnID).HeaderText = "MACD" 
     DataGridView1.Columns(columnID + 1).HeaderText = "MACD Signal" 
     DataGridView1.Columns(columnID + 2).HeaderText = "MACD Histogram" 
     '#3 insert values to column 
     For i As Integer = startIdx To endIdx 
      DataGridView1(columnID, i).Value = outMACD(i) 
      DataGridView1(columnID + 1, i).Value = outMACDSignal(i) 
      DataGridView1(columnID + 2, i).Value = outMACDHist(i) 
     Next 
End Sub 
+0

この質問はdownvoteますなぜですか? – RainerJ

答えて

0
Public Sub CalcMACD(Optional ByVal optInFastPeriod As Integer = TA_INTEGER_DEFAULT, Optional ByVal optInSlowPeriod As Integer = TA_INTEGER_DEFAULT, Optional ByVal optInSignalPeriod As Integer = TA_INTEGER_DEFAULT) 

    ' CALCULATE allocationSize 
    Dim allocationSize As Integer = 0 
    Dim lookback As Integer = TicTacTec.TA.Library.Core.MacdLookback(optInFastPeriod, optInSlowPeriod, optInSignalPeriod) 

    Dim temp As Integer = Math.Max(lookback, startIdx) 
    If (temp < endIdx) Then 
     allocationSize = endIdx - temp + 1 
    End If 

    ' Declare output variables 
    Dim outMACD(allocationSize) As Double 
    Dim outMACDSignal(allocationSize) As Double            
    Dim outMACDHist(allocationSize) As Double 

    ' the calculation 
    Dim res As TicTacTec.TA.Library.Core.RetCode = TicTacTec.TA.Library.Core.Macd(startIdx, endIdx, openPrice, optInFastPeriod, optInSlowPeriod, optInSignalPeriod, outBegIdx, outNBElement, outMACD, outMACDSignal, outMACDHist) 

    ' Add result column to Datagridview 
    ' #1 add column to Datagridview1 
    DataGridView1.ColumnCount = DataGridView1.ColumnCount + 3 
    Dim columnID As Integer = DataGridView1.ColumnCount - 3 
    ' #2 define column header 
    DataGridView1.Columns(columnID).HeaderText = "MACD" 
    DataGridView1.Columns(columnID + 1).HeaderText = "MACD Signal" 
    DataGridView1.Columns(columnID + 2).HeaderText = "MACD Histogram" 
    '#3 insert values to column 
    For i As Integer = startIdx To endIdx 
     DataGridView1(columnID, i).Value = outMACD(i) 
     DataGridView1(columnID + 1, i).Value = outMACDSignal(i) 
     DataGridView1(columnID + 2, i).Value = outMACDHist(i) 
    Next 
End Sub 
+0

1.オプションパラメータの値を定義していませんか?それは値がゼロだからできません。 – RainerJ

+0

オプションのパラメータの値は、関数定義で設定または定義されています。 –

+0

エラー 'TA_INTEGER_DEFAULT'は宣言されていません。保護レベルのためにアクセスできない場合があります。 – RainerJ

関連する問題