TA-Lib : Technical Analysis Library
http://ta-lib.org/index.html
I hope anyone could wrap this library for B4J.
And, I am willing to donate USD$100 for your precious time.
Fail to upload xml file with error message: the upload file is too large
Code snippet:
http://ta-lib.org/index.html
I hope anyone could wrap this library for B4J.
And, I am willing to donate USD$100 for your precious time.
Fail to upload xml file with error message: the upload file is too large
Code snippet:
B4X:
'with the following code to calculate ROC:
'ta-lib
Dim TOTAL_PERIODS = 90 As Int
Dim ta As TaLib
Dim i_OutBegIdx, i_OutNBElements As MInteger
Dim i_OptInTimePeriod As Int
Dim f_OutReal(TOTAL_PERIODS) As Double
i_OptInTimePeriod = 12
ta.roc(0, f_ClosePrice.Length-1,f_ClosePrice,i_OptInTimePeriod,i_OutBegIdx,i_OutNBElements,f_OutReal)
Log("ROC----")
Dim f_ROC As Double
Dim f_ROC_1 As Double
Dim f_ROC_2 As Double
f_ROC = Round2(f_OutReal(i_OutNBElements.value-1),2)
f_ROC_1 = Round2(f_OutReal(i_OutNBElements.value-2),2)
f_ROC_2 = Round2(f_OutReal(i_OutNBElements.value-3),2)
Log("f_ROC = "&f_ROC)
Log("f_ROC_1 = "&f_ROC_1)
Log("f_ROC_2 = "&f_ROC_2)
If f_ROC>=f_ROC_1 Then
Log("f_ROC is UP")
Else
Log("f_ROC is DOWN")
End If
If f_ROC>0 Then
Log("f_ROC > 0")
Else If f_ROC=0 Then
Log("f_ROC = 0")
Else
Log("f_ROC < 0")
End If
'with the following code to calculate MAROC:
Dim f_OutMaRoc(TOTAL_PERIODS) As Double
i_OptInTimePeriod = 6
ta.sma(0, i_OutNBElements.value-1,f_OutReal,i_OptInTimePeriod,i_OutBegIdx,i_OutNBElements,f_OutMaRoc)
Log("MAROC----")
Dim f_MAROC As Double
Dim f_MAROC_1 As Double
Dim f_MAROC_2 As Double
f_MAROC = Round2(f_OutMaRoc(i_OutNBElements.value-1),2)
f_MAROC_1 = Round2(f_OutMaRoc(i_OutNBElements.value-2),2)
f_MAROC_2 = Round2(f_OutMaRoc(i_OutNBElements.value-3),2)
Log("f_MAROC = "&f_MAROC)
Log("f_MAROC_1 = "&f_MAROC_1)
Log("f_MAROC_2 = "&f_MAROC_2)
If f_MAROC>=f_MAROC_1 Then
Log("f_MAROC is UP")
Else
Log("f_MAROC is DOWN")
End If
If f_MAROC>0 Then
Log("f_MAROC > 0")
Else If f_MAROC=0 Then
Log("f_MAROC = 0")
Else
Log("f_MAROC < 0")
End If
Dim b_ROC_SALE As Boolean
If f_ROC_1 >= f_MAROC_1 And f_ROC < f_MAROC Then
b_ROC_SALE = True
Log("b_ROC to SALE")
End If
Dim b_ROC_BUY As Boolean
If f_ROC_1 <= f_MAROC_1 And f_ROC > f_MAROC Then
b_ROC_BUY = True
Log("b_ROC to BUY")
End If
Attachments
Last edited: