Jump to content

ActiveX/COM DLL method works in VB but not Autoit


Recommended Posts

I am able to use other methods etc for the following DLL using AutoIT, but 1 specific method creates the following error- (using autoit v3.3.6.1)

; Piece of applicable code---NOT ALL CODE

; Setup model input output arrays per model - 
; CH wants inarray(1..numrows, 1..NumInputs), outarray(1..numrows, 1..3)
Local $InArr[$NumRows +1 ][$ch.NumInputs +1]        ; +1 necc, cause COM DLL ignores 0. 
;YES $ch.NumInputs is properly filled as int by a call to the COM DLL 

Local $OutArr[$NumRows +1 ][3 +1 ]          ; Always 3 on 2nd dimension, per CH documentaion 
Local $price[$NumRows]

;$InArr[1][0]= 51.39
$InArr[1][1]= 51.39
$InArr[1][2]= 51.26
$InArr[1][3]= 51.37
$InArr[1][4]= 2938964


; Call Prediction model But ensure enough data present in data file

$ret = $ch.Predict($NumRows, $InArr, $OutArr)

If $ret <> 0 Then
    ConsoleWriteError("ERROR: OpenModel returned: " & $ret)


Error output from SCite

C:\Users\khan\CODE\CHwrapper.au3 (62) : ==> The requested action with this object has failed.:
$ret = $ch.Predict($NumRows, $InArr, $OutArr)
$ret = $ch.Predict($NumRows, $InArr, $OutArr)^ ERROR
>Exit code: 1    Time: 4.779

Interestingly the same type of error occurs when i use $ret = $ch.Predict()! (that is no args given)

Yet it works w/ no problem using the following code in VB 2010-

'Piece of applicable code---NOT ALL CODE

Dim inar(,) As Object
        Dim outar(,) As Object
        Dim price() As Object
        Dim objname As String
        Dim strStartupArguments(), mdfile As String
        Dim i, ret, intCount, numinputs, numrows As Integer

        numrows = 1

numinputs = model.numinputs

        ReDim inar(numrows, numinputs)

        'the output array always has 3 columns
        ReDim outar(numrows, 3)

        strStartupArguments = System.Environment.GetCommandLineArgs

        'Skip 0th cause its the name of program
        For intCount = 1 To UBound(strStartupArguments)

            'Select Case strStartupArguments(intCount).ToLower

            'Case "-arg1"
            'Do your code for the arg1 argument

            inar(1, intCount) = strStartupArguments(intCount)

            Console.WriteLine(inar(1, intCount))

            'End Select

        'Apply the model
        'ret = model.Predict(1, inar, outar, price)
        'Not a trading strategy model

        ReDim price(numrows)
        'Apply the model
        ret = model.Predict(numrows, inar, outar) ', price)

        'Outar contains the following:
        'column 1: raw formula output
        'column 2: trade signals (0=no signal, 1=enter long, -1=enter short)
        'column 3: equity curve

        'if col 1 return = model.MissingValue, means could not be computed. E.g. SMA(X), doesnt have X vals yet!

        If outar(numrows, 1) = model.MissingValue Then
            Console.WriteLine("Model Returning = Missing Value, E.g x data point missing for sma(x) not computing")
        End If

    End Sub

End Module

I've looked at VB debugger info and all the arrays seems the same going in (for autoit and VB), pls help been banging my head against this wall for 24+ hours now! I would hate to end up using VB2010 at this point.

Also OLE/COM Browser(OLEview.exe) and here's what it says about this method-

VARIANT Predict(
                [in, out] VARIANT* numrows, 
                [in, out] VARIANT* inar, 
                [in, out] VARIANT* outar, 
                [in, out, optional] VARIANT* price);
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...