PDA

View Full Version : How can I call mysql Stored procedure from VTL Script



rizwanali89
11-06-2015, 05:42 PM
Hi every one,
1) I had develop a plugin in java but i need it to integrate it with vertex. Now all i need is to how can i call a mysql Stored procedure from VTL script?
2) Sample code about how to read the values of some item(gold) into my variable continuously? like run a loop that take a value and send these values to mysql Stored procedure??

Please share some simple code, as i am new user on this forum and to VTL too.

Thanks,

Hassan-HS
11-07-2015, 09:31 AM
Hi and welcome,

I will check your inquiries and I will update you.

Pleased stand by

rizwanali89
11-07-2015, 05:59 PM
Hi and welcome,

I will check your inquiries and I will update you.

Pleased stand by


Thanks for helping me out I am here waiting for your reply with some sample code.

rizwanali89
11-07-2015, 06:01 PM
Thanks for your reply. I hare waiting for you with some sample code.

rizwanali89
11-07-2015, 07:03 PM
I want to create a dashboard like the image i attached VTL script.
How can i make this form in VTL? Please anybody can give me some beginning guidelines.


405

rizwanali89
11-07-2015, 07:05 PM
Hi and welcome,

I will check your inquiries and I will update you.

Pleased stand by


Thanks for your reply I am here waiting fro you with some sample code.

Rawan-HS
11-08-2015, 10:32 AM
Dear Sir,


Thanks for contacting us.

The following code is a sample for connecting DB using VTL



Public Sub main()



Dim Connection
Dim Recordset
Dim SQL


'declare the SQL statement that will query the database
SQL = "SELECT * FROM Test"
'create an instance of the ADO connection and recordset objects
Set Connection = CreateObject("ADODB.Connection")
Set Recordset = CreateObject("ADODB.Recordset")
'open the connection to the database
Connection.Open "DSN=Examples_dsn"
'Open the recordset object executing the SQL statement and return records
Recordset.Open SQL,Connection
'first of all determine whether there are any records
If Recordset.EOF Then
AlertMessage "No records returned."
Else
'if there are records then loop through the fields
Do While NOT Recordset.Eof
AlertMessage Recordset("row")
AlertMessage Recordset("row2")
Recordset.MoveNext
Loop
End If
'close the connection and recordset objects freeing up resources
Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing
End Sub


To create form by VTL you can use CreateVTLForm (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2761) method , and to create control you can use CreateVTLControl (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2760)

for more information about the VTL GUI Check our documentation (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2567).

Check the following sample to learn how you can get any Symbol Info.


Dim exeResult
Dim rst
Dim symbolName

Public Sub main()
symbolName="EUR/USD"
ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_STOP_OFFSET,rst) ,"SYMBOL_STOP_OFFSET",cstr(symbolName)
ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_ASK,rst) , "SYMBOL_ASK",cstr(symbolName)
ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_BID,rst) , "SYMBOL_BID",cstr(symbolName)
ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_High,rst) , "SYMBOL_High",cstr(symbolName)
ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_LOW,rst) , "SYMBOL_LOW",cstr(symbolName)
ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_VOLUME_MIN,rst) ,"SYMBOL_VOLUME_MIN",cstr(symbolName)
ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_VOLUME_MAX,rst) ,"SYMBOL_VOLUME_MAX",cstr(symbolName)
ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_COMMISSION,rst) ,"SYMBOL_COMMISSION",cstr(symbolName)
ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_LIMIT_OFFSET,rst) ,"SYMBOL_LIMIT_OFFSET",cstr(symbolName)
ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_MARGIN_INITIAL,rst) ,"SYMBOL_MARGIN_INITIAL",cstr(symbolName)
ShowResult SymbolInfoDouble( cstr(symbolName),SYMBOL_CONTRACT_SIZE,rst) ,"SYMBOL_CONTRACT_SIZE",cstr(symbolName)
AlertMessage cstr(exeResult)
End Sub

Public Sub ShowResult(isTrue,enumDescription,symName)
if isTrue then
exeResult=exeResult & CSTR(enumDescription) & " for " & CSTR(symName) & " is : " & rst
else
exeResult=exeResult & "Error during Get " & CSTR(enumDescription) & " due to error code " & ErrorDescription(GetLastError())
end if
exeResult=exeResult & vbNewLine
rst=""
End Sub

rizwanali89
11-08-2015, 09:40 PM
Hi,
I am unable run you second code.. i got these error while run it on server side vtl..

getlasterror is not declared it may be inaccessible due to its protection level.

Can you please share me some startup guide. like helloworld program and some syntax related important points. because i am new to this IDE. and totally no idea about how to run that GUI code at client side VTL..

Thanks,
Rizwan Ali.

rizwanali89
11-09-2015, 02:21 AM
please tell me how can i run this sample code for client side script. Also share some startup guide with me for VTL development.

Hassan-HS
11-09-2015, 07:33 AM
Hello :)

VertexFX Trading Language (VTL)


This is the soul of the scripting language in VertexFX. It is a procedural programming language that was developed specifically to serve traders, strategy makers and Technical Analysts (TA). VTL is a powerful and versatile programming language for traders. The language provides the framework required to build sophisticated trading programs as Expert Advisers (EA), Auto Traders, Robots, Alerts and Custom Indicators.


It is supported by a user friendly Editor for its both Server Side VTL where script is hosted at the VertexFX Server and Client Side VTL where Script is running at the client terminal itself. A free community forum is available to deliver enough development support for VTL.


VTL offers great advanced features that represent the future of trading and start the new generation of online trading systems, VertexFX has penetrated the trading world by its advanced scripting language VTL.


VTL has many competitive features, VTL has two modes:


1- VTL Server: Where Script is hosted at VertexFX Server. Programmers can program scripts in a .NET-like syntax with all its capability include Object Oriented Programming functionality. Usually Auto traders, Expert Advisers and Robots can be built using VTL server where no need to keep your Client Terminal running.


2-VTL Client: Where Script is running regularly at Client terminal and can be programmed using VTL Editor using a VB6-like language. Usually Custom Indicators, Alerts and Expert Advisors (again) are built using VTL Client where a GUI interface is expected as output.


As for the startup guide you can Read this course (http://www.hybrid-solutions.com/VTL%20Course.pdf)

rizwanali89
11-09-2015, 09:37 AM
Hassan you just copy and paste the above reply from a URL i already have go through. Please answer my question rather than wasting your time. Even the course I already learn about it. I am software engineer have enough experience to understand these thing. What I need was to start the development but not know how to debug, and resolved the error I am facing as I asked you in my last post "getlasterror is not declared it may be inaccessible due to its protection level."
Even the sample code you give me about the form is not run. In both case server side and client side script. Is there any tutorial from where I can learn the ABC about this platform how to use it properly. Any developer guide not like that http://www.hybrid-solutions.com/VTL%20Course.pdf

Hassan-HS
11-11-2015, 08:31 AM
Hello ;)


As you read in the course that I sent you, there is two types of the VTL ( VTL Server, VTL Client) with different syntax & technologies & methods. that mean you can't run a client VTL code on the VTL server.


I sent you a client code because you cannot access your database which is located on your PC probably (not on a server with static IP) using server script which is located on our servers.

keep cool and sorry for any inconvenience but we supposed that you did not read any thing before :)

rizwanali89
11-12-2015, 12:03 AM
Hi Hassan,

Ok lest me explain how I want to use vertex. As I show you an image that is a software GUI I develop for trading in stocks. As you see in the image some of the inputs files and last trade price,bid ,ask and other market data goes in to mysql stored procedure and in the result it generate buy or sell signals as return result set. On the bases of these signals I have to do trade through your system. Now please suggests me from where I can start? as you know I am new to this verfex type of thing ;)
On more thing I need to develop that type of GUI your help will be very appreciated.
Regards,
rizwanali89

rizwanali89
11-12-2015, 12:05 AM
One more suggestion for your forum, when I replay to this thread its not appear immaterially. In fact it show after 12-24 hours if I am not wrong.

Rawan-HS
11-12-2015, 02:06 PM
Hello

I got your point, I believe that you can done your project using our

1-VertexFX Client API

By adding our ActiveX DLL to your project, you can fetch All data you want to build your own plugin, fill this form (http://www.hybrid-solutions.com/sales/partnership/isv-program.html) to get it with a sample code and visit client API documentation (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2061) for more info about it.

2-VertexFX VTL (Client)

The following code is a VTL client script that build a simple form.

Note: VTL GUI methods is still a beta version code.

[CODE]

Public Sub main()


dim formId
formId = "1"
CreateVTLForm Cstr(formId), false ,"Test"
CreateVTLControl Cstr(formId),"lblA" ,GUI_LABEL
SetGUIObject Cstr(formId) , "lblA",GUI_PROPERTY_CAPTION, "Lable "
SetGUIObject Cstr(formId) , "lblA",GUI_PROPERTY_TOP,200
CreateVTLControl Cstr(formId),"TextBox" ,GUI_TEXT_BOX
SetGUIObject Cstr(formId) , "TextBox",GUI_PROPERTY_ENABLED , true
SetGUIObject Cstr(formId) , "TextBox",GUI_PROPERTY_HEIGHT , 300
SetGUIObject Cstr(formId) , "TextBox",GUI_PROPERTY_WIDTH ,1500
SetGUIObject Cstr(formId) , "TextBox",GUI_PROPERTY_TOP, 400
SetGUIObject Cstr(formId) , "TextBox",GUI_PROPERTY_LEFT, 800
CreateVTLControl Cstr(formId),"Button" ,GUI_BUTTON
SetGUIObject Cstr(formId) , "Button",GUI_PROPERTY_CAPTION, "click "
SetGUIObject Cstr(formId) , "Button",GUI_PROPERTY_ENABLED , true
SetGUIObject Cstr(formId) , "Button",GUI_PROPERTY_HEIGHT , 300
SetGUIObject Cstr(formId) , "Button",GUI_PROPERTY_WIDTH ,1500
SetGUIObject Cstr(formId) , "Button",GUI_PROPERTY_TOP, 400
SetGUIObject Cstr(formId) , "Button",GUI_PROPERTY_LEFT, 2500
End Sub


[/CODE

rizwanali89
11-13-2015, 10:34 PM
How to use VertexFX APIs
VertexFX APIs are mostly ActiveX components (DLLs) that can be imported with any programming language (VB6, C++, VB.NET, JAVA etc). So import them, make objects from the classes (you may need help from a programmer to do this) and start using the events, functions and subs to create your applications.

As This was written on your web site.....
After installation of VertexFX APIs can you please guide me how can I use your VertexFX API with java environment. Thanks,

rizwanali89
11-16-2015, 01:42 AM
I asked you about how I can use this client API with JAVA please give me some suggestions.

Hassan-HS
11-16-2015, 07:50 AM
Hello :)




You have to turn DEP off on your development machine ( please make sure to disable the secure boot also on bios) please check this article (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/3540), as for client machines please note there is no need to turn the DEP off or the secure boot on the clients computers for more info check this article (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/4741/0/api-connection-on-windows-78)
Connect the company server using the following points

Reference the {VertexFX Client API} Dll to your project, you can find them on System32 or Syswow64 (VertexFXClientAPI10.X.X.DLL, HSGeneralDLL10.X.X.DLLL,HSClient10.X.X.DLL,VertexT rading10.X.X.DLL). As for how to add them to Java I think that you need to use JACOB, JACOB is a JAVA-COM Bridge that allows you to call COM DLL (Sorry i cant help you in this matter because i'm not a java developer.)
Define Object with events of type CVertexFXClientAPI class, after that call the following two methods:

Object.SetLoginInfo (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1978)
Object.Login (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1979)

rizwanali89
11-17-2015, 12:25 AM
Can you pleas prove me simple basic code for login and where i can find out the ip address and port of server of my demo account???

rizwanali89
11-17-2015, 12:38 AM
Can you please provide me the same thing for java as in this link...

http://www.hybrid-solutions.com/opendemoaccountaspsample.zip

Thanks,

Hassan-HS
11-17-2015, 09:03 AM
Our demo server IP is 74.54.46.178 Port 4401 , sorry I cant help you in java you can contact java expert about how to add the Activex DLL's to JAVA

rizwanali89
11-17-2015, 11:14 AM
I had done that thing Add activex dll in java... but don't have any clue about how can I start about what you said... in point 2

Define Object with events of type CVertexFXClientAPI class, after that call the following two methods:


Object.SetLoginInfo (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1978)
Object.Login (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1979)


Can you please explain this point in little bit more details..... That could be helpful for me.

Rawan-HS
11-17-2015, 11:45 AM
first of all you must create an object of type CVertexFXClientAPI
like this to see all events and methods on the API

Public withEvents API as CvertexFXClientAPI


then set this code on where you want to start login such as on the button



API.SetLoginInfo("UserName", "Password", "ServerIP", Port)
API.Login()


for more details check our client API documentation (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2061).

rizwanali89
11-17-2015, 08:03 PM
after placing this code how can i resolve the import issue about this variable??
withEvents cannot be resolved to a type?
Please give me some sample code. After that this documentation will help me and what is the full ISV Development API KIT???
hava a look at this url http://www.dreamincode.net/forums/topic/114094-using-dll-library-in-java-application-using-jacob/

I am not in case of vertex what i should have to pass instead of this "Com.Calculation"

ActiveXComponent comp=new ActiveXComponent("Com.Calculation");

This example working fine. Even i registered vertex client api dlls too. But need some clue to break through to start up.

rizwanali89
11-17-2015, 09:04 PM
Hi I got it its the string registered in the registry of the machine HKEY_LOCAL_MACHINE\SOFTWARE\Classes\VertexFXClient API10.CVertexFXClientAPI need to pass this "VertexFXClientAPI10.CVertexFXClientAPI" and it will create object.

rizwanali89
11-17-2015, 10:37 PM
Hi every time Run my program its says this.... even when i try to get some information related to my account it give me this error "You have to use Vertex FX API Version 10.5.0 or more" also attach the image.

408

rizwanali89
11-18-2015, 03:43 PM
"Our demo server IP is 74.54.46.178 Port 4401" what about the if i want to connect to my Live account??

Hassan-HS
11-19-2015, 02:26 PM
Hello,


Our main class is CvertexFXClientAPI which is exist inVertexFXClientAPI library (VertexFXClientAPI10.5.2.DLL), in this class you can find all methods & events that exist on our documentation.


Notes:


you can find a VB6 & .Net on the installation path (C:\Program Files (x86)\VertexFX Client API).
we sent you the VertexFX Client API 10.5 & 10.2 , you have to use Client API 10.5 if you connect system with version 10.5 and Client API 10.2 if your system version is 10.2 to check the system version open Help tab then click on About button

rizwanali89
11-19-2015, 05:37 PM
Thanks Hassan for your help...

I had done a lot of things now.

Now I need what about Ip address and Port if I want to connect to my Live account??

In other words Port 4401 is standard for all vertex??

rizwanali89
11-19-2015, 11:58 PM
Java code successfully login through API...

System.out.println(Dispatch.call(vertexClient, "SetLoginInfo","USER21250", "XXXX", "74.54.46.178", 4401));
System.out.println(Dispatch.call(vertexClient, "Login"));

System.out.println("ServerIP-->"+vertexClient.getProperty("ServerIP").getString());
System.out.println("ServerPort-->"+vertexClient.getProperty("ServerPort").getString());
System.out.println("LoginUsername-->"+vertexClient.getProperty("LoginUsername").getString());
//System.out.println("LoginPassword-->"+vertexClient.getProperty("LoginPassword").getString());
System.out.println("Version-->"+vertexClient.getProperty("Version").getString());
System.out.println("ServerGMTOffset-->"+vertexClient.getProperty("ServerGMTOffset").getString());
System.out.println("OrdersCount-->"+vertexClient.getProperty("OrdersCount").getString());
System.out.println("Release-->"+vertexClient.getProperty("Release").getString());
System.out.println("Patch-->"+vertexClient.getProperty("Patch").getString());
System.out.println("LogedOn-->"+vertexClient.getProperty("LogedOn").getString());
// System.out.println(vertexClient.getProperty("LimitPrice").getString());
System.out.println("SymbolsCount-->"+vertexClient.getProperty("SymbolsCount").getString());

The console output.....
Why i am getting some property null and this error when trying to get property of account object.... the code is : ActiveXComponent vertexClientAccountt =new ActiveXComponent("VertexFXClientAPI10.COAccount"); Variant account = vertexClientAccountt.getProperty("Account");

The Library been loaded, and an activeX component been created
null
8. WaitingMode event fired..[Lcom.jacob.com.Variant;@15a0305
8. WaitingMode event fired..[Lcom.jacob.com.Variant;@765a16
8. WaitingMode event fired..[Lcom.jacob.com.Variant;@e80842
8. WaitingMode event fired..[Lcom.jacob.com.Variant;@16fe0f4
null
ServerIP-->74.54.46.178
ServerPort-->null
LoginUsername-->USER21250
Version-->null
ServerGMTOffset-->null
OrdersCount-->null
Release-->null
Patch-->null
LogedOn-->null
SymbolsCount-->null
8. WaitingMode event fired..[Lcom.jacob.com.Variant;@cbf30e
8. WaitingMode event fired..[Lcom.jacob.com.Variant;@1ec6696
8. WaitingMode event fired..[Lcom.jacob.com.Variant;@a4e2e3
2. ConnectionState event fired..[Lcom.jacob.com.Variant;@134f69a
8. WaitingMode event fired..[Lcom.jacob.com.Variant;@fd68b1
8. WaitingMode event fired..[Lcom.jacob.com.Variant;@4b035d
8. WaitingMode event fired..[Lcom.jacob.com.Variant;@198a455
#
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7723e3be, pid=19740, tid=17744
#
# Java VM: Java HotSpot(TM) Client VM (11.0-b16 mixed mode windows-x86)
# Problematic frame:
# C [ntdll.dll+0x2e3be]
#
# An error report file with more information is saved as:
# D:\backups\projects\workspace\VertexDemo\hs_err_pi d19740.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

rizwanali89
11-20-2015, 08:11 AM
Can you please reply me on my 2 questions i had asked.

Hassan-HS
11-21-2015, 08:18 AM
Hello :)


After calling login method one of the following events will be raised.
1-AllDataAreLoaded (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1995) means that the API has loaded all needed data from the sever.
2-InvalidUsernamePassword (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1998)means your credential is invalid

Please don't call any property or method before receiving "AllDataAreLoaded (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1995)" event, if you face problem with receiving the mentioned events you have to turn the DEP off as I told you in a previous post.

rizwanali89
11-22-2015, 04:07 PM
Hi,

I am able to received these event and but no idea how to call property ? can you please explain that.

rizwanali89
11-22-2015, 05:04 PM
com.jacob.com.ComFailException: Invoke of: Name
Source: VertexFXClientAPI10
Description: Object variable or With block variable not set

rizwanali89
11-22-2015, 05:06 PM
com.jacob.com.ComFailException: Can't get object clsid from progid

Rawan-HS
11-23-2015, 10:45 AM
Dear

we have created a small vb.net sample about client API (Events and methods) , wish it help you .

rizwanali89
11-24-2015, 11:50 PM
Syntax


ReadOnly Property Account(ByRef AccountID As Long) As VertexFXClientAPI.COAccount


This property takes the account ID and returns an object of type COAccount.

object of type COAccount==> My question is that what are the properties of that object "COAccount"

I am able to call all the properties list here in this link http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2061
except those who return an object with specific type like Account property with object type VertexFXClientAPI.COAccount and VertexFXClientAPI10.COOrder and some others
I called the property like this
new ActiveXComponent("VertexFXClientAPI10.CVertexFXClientAPI").getProperty("LoginUsername").getString());
as I mention earlier in the post but unable to find the way to call the property like Account, OrderByID and other properties that returns the some sort of object. Please can you explain how to get the object of these properties.

2nd thing the code your give me was very helpful. When I call the same method "AccountSummaries" after AllDataAreLoaded event
long accountID = 1234573405;
double balance = 0;
double fltp = 0;
double credit = 0;
double equity = 0;
double marginreq = 0;
double margin_level = 0;
double effmargin = 0;
Dispatch.call(Vertex.vertexClient, "AccountSummaries",new Variant(accountID),vbalance,vfltp,vcredit,vequity, vmarginreq,vmargin_level,veffmargin)

It return me 1. according to CallingResultsEnum (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2027) the Successfully result but I am unable to see the values even in debug mode. I mean where are the values of AccountSummaries has been save.
Same is the case with AccountHistory function.

Please of you have the sample client in java as you send earlier. I will be very thank full to you.
I could assist you regarding the java prospective by sending you the eclipse project of e vertex demo version.
You can easily run it in your environment. The issue is the objects? how can I get the Account,COSymbol and COOrder e.t.c objects..

Thanks.

Hassan-HS
11-25-2015, 10:54 AM
Hello,

We are already developing a Java sample for you and we will pass it for you once it finished, but you can find the documentation for COAccount class here (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/4877)

rizwanali89
11-25-2015, 03:01 PM
Hi Hassan,

Thanks I appreciate your efforts and hope for your soon response that help me to complete my development on this weekend.

rizwanali89
11-26-2015, 08:40 AM
Hi Hassan,
Please send me your email address its difficult to sen you private message there is no reply button and other options. One more thing unfortunately I shift to the default mobile style of this forum. Please help me to revert it back to standard style.
Mean while I am preparing a e-mail for you.

Rawan-HS
11-26-2015, 09:29 AM
Dear

can you try now , or you can reply here about private massage

rizwanali89
11-26-2015, 09:53 AM
Hi..
Import that project in eclipse. You can download eclipse simple one from internet if you don't have. If you do not have installed java then installed that first.


To import project in eclipse fallow this link http://agile.csc.ncsu.edu/SEMaterials/tutorials/import_export/ (extract the VertexDemo.rar)
then download jacob jar file from here http://danadler.com/jacob/
how to add library to java project in eclipse please see this link http://www.oxfordmathcenter.com/drupal7/node/44
I assume that you have installed the vertexAPI 10.5 or above.
After configuration there are two files Vertex and VertexEvents.
When you run that Vertex by right click on the file and run as java application it login to my demo account and VertexEvents start triggering.
How you know how to registered the dll file with windows.
If you have any question please let me know.

Thanks,

Rawan-HS
11-26-2015, 10:10 AM
Ok , thanx for you

Rawan-HS
11-26-2015, 11:30 AM
Is there a specific Path I must put the vertex Client Dll ?

rizwanali89
11-26-2015, 01:14 PM
When you install the vertex api. make sure it has an entery in the registry.

rizwanali89
11-26-2015, 01:21 PM
you may have to register the dll through command prompt using

https://msdn.microsoft.com/en-us/library/tzat5yw6(v=vs.110).aspx
http://www.geeksengine.com/article/register-dll.html

go the folder where regasm.exe exist it will be in your .netframwork or just search it in C "regasm.exe"

run this command regasm vertexapi10.dll

Let me know where you get stuck.. I will try to help you.

rizwanali89
11-29-2015, 11:28 PM
416417

please can you explain that ????

Hassan-HS
12-01-2015, 09:07 AM
Hello,

This error appear when you connect the Client API to incompatible VFX server, which version of API do you use,and to which IP you connect.


As I mentioned in a previous post


We sent you the VertexFX Client API 10.5 & 10.2 , you have to use Client API 10.5 (VertexfxClientAPI10.5.XX.DLL) if you connect system with version 10.5 and Client API 10.2 (VertexfxClientAPI10.2.XX.DLL) if your system version is 10.2 to check the system version open Help tab then click on About button.
Please don't do any call after you call Login sub procedure for the Client API object before receiving AllDataAreLoaded event.


This is the true scenario to select any account.


Public WithEvents API As CVertexFXClientAPI


Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
API.SetLoginInfo(txtUserName.Text, txtPassword.Text, txtServerIP.Text, Val(txtPort.Text))
API.Login()
End Sub
Private Sub API_AllDataAreLoaded() Handles API.AllDataAreLoaded
API.SelectAccount(CInt(txtAcountNumber.Text))
End Sub


not like this.



Public WithEvents API As CVertexFXClientAPI
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
API.SetLoginInfo(txtUserName.Text, txtPassword.Text, txtServerIP.Text, Val(txtPort.Text))
API.Login()
API.SelectAccount(CInt(txtAcountNumber.Text))
End Sub

rizwanali89
12-01-2015, 11:16 AM
Is there are two different ways for calling 2 different versions???

Hassan-HS
12-01-2015, 12:25 PM
You mean you want to use both version of the VFX Client API on your plugin ? If yes, no you can't reference two version of VFX Client API to the same project.

rizwanali89
12-02-2015, 01:45 PM
Helloo Hassan,

The issue is that I had develop my project with (VertexfxClientAPI10.5.XX.DLL) api version for demo account.
But when I i am going to run it for my real account with seawolf they are using (VertexfxClientAPI10.2.XX.DLL).
When i change the core calls to that api 10.2 its give me error. while the same code run ok with api10.5 with your server. How can i had to handle that??

Hassan-HS
12-02-2015, 02:10 PM
Hello

Send me the error please.

rizwanali89
12-02-2015, 10:18 PM
ok i will... send you.

rizwanali89
12-06-2015, 06:44 PM
Hi Hassan.
I am able to successfully communicate through vertex demo account using API 10.5
ow every thing is now good. But I am facing issue while getting the result of GetAccountHistory.
I have successfully call the function GetAccountHistory() and it trigger the event AccountHistoryReceived(Variant[] args).

public void AccountHistoryReceived(Variant[] args) {
System.out.println("36. AccountHistoryReceived event fired.." + args.length);// This give me a one record and it is one in the demo account as well. that is ok.
for (Variant variant : args) {
System.out.println("v.isNull=" + variant.isNull());
AccountHistory accountHistory = new AccountHistory(variant.getDispatchRef());// I create AccountHistory object you can see that in the attachment.
System.out.println("AccountHistoryReceived--->"+accountHistory.m_pDispatch);
System.out.println("getSymbol_id--->"+accountHistory.getSymbol_id()); ///////// But at this line i got the exception as i show below.
System.out.println("getAccountTransactionAmount--->"+accountHistory.getAccountTransactionAmount());
}

AccountHistoryReceived--->1880514940515591340
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.jacob.com.InvocationProxyAllVariants.invoke(In vocationProxyAllVariants.java:80)
Caused by: com.jacob.com.ComFailException: Can't map name to dispid: Symbol ID
at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.com.Dispatch.invokev(Dispatch.java:625)
at com.jacob.com.Dispatch.get(Dispatch.java:788)
at com.vv.AccountHistory.getSymbol_id(AccountHistory. java:79)
at com.vv.VertexEvents.AccountHistoryReceived(VertexE vents.java:315)
... 5 more

rizwanali89
12-06-2015, 06:46 PM
Please can you suggest any solution for that problem.

Rawan-HS
12-07-2015, 10:37 AM
Dear

I have created a VB.net sample to know how to get data from account History
Check it and check CAccountHistory (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/4176) Documentation may it help you

rizwanali89
12-09-2015, 12:56 AM
Hi,

I create a VTL client side script that do the following

IF( CDbl(arrSELL(BARS_COUNT)) = UNDEFINED AND Not CBool(BuyPositionOpen)) THEN
closeAllSellPositionsAtMarketOrder /// Close All sell positions at market order
placeBuyMarketOrder /// Open a Sell position at market order
BuyPositionOpen = 1
SellPositionOpen = 0
END IF
IF( CDbl(arrBUY(BARS_COUNT)) = UNDEFINED AND Not CBool(SellPositionOpen)) THEN
closeAllBuyPositionsAtMarketOrder /// Close All Buy positions at market order
placeSellMarketOrder /// Open a buy position at market order
BuyPositionOpen = 0
SellPositionOpen = 1
END IF

Public Sub closeAllSellPositionsAtMarketOrder() // As you said http://www.hybrid-solutions.com/forum/archive/index.php?t-31438.html
Dim ID
'Symbol = InputBox("Please enter the symbol name?", "Close all positions")
If Symbol <> "" then
StringToUpper Symbol
For i = 1 to PositionTotal
ID = PositionGetTicket(Cint(i))
PositionSelect(Clng(ID))
if PositionGetSymbol(Cint(i)) = Symbol then
Dim Amount
PositionGetDouble 8,Amount
'PositionGetString 2, Type
'MsgBox"Do you wish to display chart symbol ?" & Amount& GetPositionType , vbOKOnly, "Confirm"
IF CInt(GetPositionType) = -1 then ' -1 = Sell Type
CloseMarketOrder Clng(ID) , Cdbl(Amount)

end if
end if


Next
End If
'NewMarketOrder -1,"EUR/CHF",0.1 '(1/-1 = Buy / Sell, SymbolName, Lots)
End Sub
Public Sub closeAllBuyPositionsAtMarketOrder()


Dim ID
'Symbol = InputBox("Please enter the symbol name?", "Close all positions")
If Symbol <> "" then
StringToUpper Symbol
For i = 1 to PositionTotal
ID = PositionGetTicket(Cint(i))
PositionSelect(Clng(ID))
if PositionGetSymbol(Cint(i)) = Symbol then
Dim Amount
PositionGetDouble 8,Amount
'PositionGetString 2, Type
'MsgBox"Do you wish to display chart symbol ?" & Amount& GetPositionType , vbOKOnly, "Confirm"
IF CInt(GetPositionType) = 1 then ' -1 = Buy Type
CloseMarketOrder Clng(ID) , Cdbl(Amount)
MsgBox "BUY "& GetLastError
end if
end if


Next
End If


'NewMarketOrder -1,"EUR/CHF",0.1 '(1/-1 = Buy / Sell, SymbolName, Lots)
End Sub

Public Sub placeBuyMarketOrder()
NewMarketOrder 1,Symbol,0.1 '(1/-1 = Buy / Sell, SymbolName, Lots)
End Sub


Public Sub placeSellMarketOrder()
NewMarketOrder -1,Symbol,0.1 '(1/-1 = Buy / Sell, SymbolName, Lots)
End Sub

This code Run fine on your Hybrid Solution demo system Version 10.5.3

But When I run It on my Live Account that is on version 10.2.3 (I can't update that client software) it can not close all the opened position just close the firs one. and when it try to open another position system give some sort of error sound but not display the error message. and most of time it shows message "unable to get a quote due to bad connection" some time it says "unable to get a quote due current market condition". how can handle this situation pragmatically???
i need the guarantee of all the order execution that's the reason i am placing market order. But during placement i got these situation.
Can you please recompile that code to vertex version version 10.2.3??? or suggest any other solution??

anderson01
12-09-2015, 06:00 AM
Thank you for sharing this. I face a problem then i find your post and i use it . and its worked .

Rawan-HS
12-09-2015, 09:35 AM
Dear :)

If you need to close multiple positions in the same time you have to use CloseMultiPositions (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/3746) method.


Check the following code.



Public Sub main()
''''TODO: Script program start method
Dim Ticket
Dim lot
If PositionTotal= 0 then exit sub
If PositionTotal = 1 then ' to close just one position
Ticket = PositionGetTicket(1)
If PositionSelect(Clng(Ticket)) = true then
PositionGetDouble POSITION_AMOUNT , lot
CloseMarketOrder Clng(Ticket),Cdbl(lot)
End if
Else ' to close multi position in the same time
Dim Tickets
Dim Lots
For i= 1 to PositionTotal
Ticket = PositionGetTicket(Clng(i))
result = PositionSelect(Clng(Ticket))
if (Cbool(result) = True) then
PositionGetDouble POSITION_AMOUNT, lot
if i = 1 then
Tickets = cstr(Ticket)
else
Tickets = cstr(Tickets) + "," + cstr(Ticket)
end if
if i = 1 then
lots = cstr(lot)
else
lots = cstr(lots) + "," + cstr(lot)
end if
end if
next
CloseMultiPositions cstr(tickets), cstr(lots)
end if
End Sub




Note: You cannot call "Trading function" in a loop because the system cannot send any request before receiving the result of the first request so you need to wait the result for each request you send.

The result returned through this events (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2565).

rizwanali89
12-09-2015, 12:20 PM
If this was the issue then why it work on other version??
Had you test my code on version 10.2.3..??
Its preferentially working fine on new version of 10.5...

You did not answer my about the
when it try to open another position system give some sort of error sound but not display the error message. and most of time it shows message "unable to get a quote due to bad connection" some time it says "unable to get a quote due current market condition". how can handle this situation pragmatically???

I saw on this forum some day ago about this issue.... somebody implement a 3 seconds wait to try again to place the order... Can you please share that link as well..

Rawan-HS
12-09-2015, 01:23 PM
Dear

Can you send to me your fully code as private message, it is not working in my side

rizwanali89
12-09-2015, 05:38 PM
My question is just that how can i avoid these errors "unable to get a quote due to bad connection" and "unable to get a quote due current market condition" occurred when place marketorder(buy/sell)??? how can i do to attempt again again until order get executed......????

Rawan-HS
12-10-2015, 08:45 AM
Dear :)

"unable to get a quote due to bad connection " error occurs:
1- when your internet connection is bad.
2- when you use MsgBox method on your code, the client terminal suspended until the user responds to the message box, which is delay your request, I suggest to use AlertMessage (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/4766) instead of it.

And about "unable to get a quote due current market condition" message it is not problem the system prevents you to get any order at symbol if not tick for X time

rizwanali89
12-10-2015, 11:09 AM
I need some sample code that attempt again for order placement on tick for next time/Xtime.....
I want code for example that try until the order get executed... even these order occurred. I see some one had done it but i did not remember the link
Please Dear share some code that attempt again when these error happen until market order get executed......

Hassan-HS
12-11-2015, 08:24 AM
Hello :)

OK, we will send you sample code soon please standby.

rizwanali89
12-11-2015, 10:13 AM
Thanks Hassan!!! and please give me sample the close all my opened positions(buy/sell) for specific symbol and open a new position(buy/sell) for that symbol with desire lot size....????

Rawan-HS
12-14-2015, 10:33 AM
Dear :)

You can handle the happen error by waiting the OnOrderTrade (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2565) event by using the returnValue (http://www.hybrid-solutions.com/support/index.php?/hs/Knowledgebase/Article/View/3348) form this event check this sample.




Dim SymbolName
SymbolName= "EUR/USD"
Dim lot
lot= 1
Public Sub main()
''''TODO: Script program start method
If AccountInfoInteger(ACCOUNT_LOGIN) Then ' Check if account is selected.
NewMarketOrder TRADE_ACTION_BUY,Cstr(SymbolName) ,CDBL(lot) ' Returns True if buy operation was successful.
Else
AlertMessage "Select account."
End if
End Sub


Public Sub OnOrderTrade(actionType ,orderID , returnValue)
if returnValue = 4 then
NewMarketOrder TRADE_ACTION_BUY,Cstr(SymbolName) ,CDBL(lot)
else
AlertMessage "returnValue"
End IF
End Sub





And the bellow code to close all position by using CloseMultiPositions (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/3746) method may it will help you



Dim Ticket
Dim lot
Dim Tickets
Dim Lots
If PositionTotal= 0 then exit sub
For i= 1 to PositionTotal
Ticket = PositionGetTicket(Clng(i))
result = PositionSelect(Clng(Ticket))
if (Cbool(result) = True) then
PositionGetDouble POSITION_AMOUNT, lot
if i = 1 then
Tickets = cstr(Ticket)
else
Tickets = cstr(Tickets) + "," + cstr(Ticket)
end if
if i = 1 then
lots = cstr(lot)
else
lots = cstr(lots) + "," + cstr(lot)
end if
end if
next
CloseMultiPositions cstr(tickets), cstr(lots)

rizwanali89
12-15-2015, 09:09 PM
I want to know when these message/alert trigger???
Similarly the case with the alert message of bad connection??? when that message/alert occure


427

Hassan-HS
12-16-2015, 02:01 PM
Hello,

This error occurs when your request takes more than 5 seconds to reach the server.

rizwanali89
12-17-2015, 10:00 AM
Its mean if I run this type of script on server side VTL then this issue will not occur. also the bad connection error will also not come in that case?? is am right??

How can I debug the server Side Script????

Rawan-HS
12-17-2015, 01:44 PM
Dear :)

Yes this problem will be solved if you run it on the server side

you can check our VTL server side (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2566) documentation .
and you can check this server side script (http://www.hybrid-solutions.com/plugins/client-vtl-plugins/free/close-by-equity.html) may be it will help you to write your code .

rizwanali89
12-23-2015, 02:30 PM
What is the best way to convert VTL client side script to VTL server side script..???

Rawan-HS
12-23-2015, 02:52 PM
Dear rizwan

there is no bast way to convert from client side to server side.