Hello fellow coder/traders. I am currently attempting to use the ForexConnect API COM with a programming language called autoit. The syntax is very similar to VBSscript. So I have been using the examples in "C:\Program Files\Candleworks\ForexConnectAPIx64\samples\com\VBS" to help me out.
THE PROBLEM is my process is not catching the session_SessionStatusChanged or session_SessionStatusLoginError events which let me know if I have connected. I have been reading through the help file for COM but it mostly contains vb/vba examples which I don't think are similar enough. Any help would be greatly appreciated.
A few things to know about my system.
Windows 8.1 64 bit.
ForexConnectAPI-1.3.0-win64 installed
ForexConnectAPI-1.3.0-win64-COM installed
The VBS example works fine but not when I converted the code to autoit.
The code is also similar to PHP.
THE PROBLEM is my process is not catching the session_SessionStatusChanged or session_SessionStatusLoginError events which let me know if I have connected. I have been reading through the help file for COM but it mostly contains vb/vba examples which I don't think are similar enough. Any help would be greatly appreciated.
A few things to know about my system.
Windows 8.1 64 bit.
ForexConnectAPI-1.3.0-win64 installed
ForexConnectAPI-1.3.0-win64-COM installed
The VBS example works fine but not when I converted the code to autoit.
The code is also similar to PHP.
PHP Code:
;###Right here would be a long list of constants found in fxcore2_com_enums.vbs###
$username = "***************"
$password = "****"
If $username = "" Or $password = "" Then
MsgBox(16, "Error", "Please provide username and password to the appropriate variables")
Exit
EndIf
$LastStatus = ""
$LastError = ""
MsgBox(0, "", "Login and logout")
$core = ObjCreate("fxcore2.com.Transport")
$session = $core.createSession()
$Event = ObjEvent($session, "session_")
MsgBox(0, "", "Log in...")
$session.login($username, $password, "http://ift.tt/1HEXj9O", "Demo")
While $LastStatus <> $SessionStatusCode_Connected And $LastError = ""
Sleep(50)
WEnd
MsgBox(0, "", "Log out...")
$session.logout
While $LastStatus <> $SessionStatusCode_Disconnected
Sleep(50)
WEnd
MsgBox(0, "", "Session status:" & GetStatusName($LastStatus))
$session = ""
MsgBox(0, "", "Done !")
Func session_SessionStatusChanged($status)
MsgBox(0, "", "Status changed: " & GetStatusName($status))
$LastStatus = $status
EndFunc ;==>session_SessionStatusChanged
Func session_SessionStatusLoginError($err)
MsgBox(16, "Error", "Error occured: " & $err)
$LastError = "err"
EndFunc ;==>session_SessionStatusLoginError
Func GetStatusName($status)
Switch $status
Case $SessionStatusCode_Connected
$varGetStatusName = "connected"
Case $SessionStatusCode_Disconnected
$varGetStatusName = "disconnected"
Case $SessionStatusCode_Connecting
$varGetStatusName = "connecting"
Case $SessionStatusCode_TradingSessionRequested
$varGetStatusName = "trading session requested"
Case $SessionStatusCode_Disconnecting
$varGetStatusName = "disconnecting"
Case $SessionStatusCode_SessionLost
$varGetStatusName = "session lost"
Case $SessionStatusCode_PriceSessionReconnecting
$varGetStatusName = "price session reconnecting"
Case $SessionStatusCode_Unknown
$varGetStatusName = "unknown"
Case Else
$varGetStatusName = $status
EndSwitch
Return $varGetStatusName
EndFunc ;==>GetStatusName
Aucun commentaire:
Enregistrer un commentaire