PDA

View Full Version : Unable to get account summary and open positions from demo account



nhasan
07-01-2013, 05:25 AM
Dear Team

I am testing server side script in my demo account to understand VTL code environment.
I copy/paste code from 'All Open Positions' sample page and try to compile in VTL editor.
It has a number of error - but finally I can manage them to compile and execute.
Unfortunately it failed to get current running information from the account.
As you can see in this screenshot - I have three positions open - but the code shows nothing in the list and FltPL = 0
I have found that the function ClientCode.PositionsTotal() returns -1 for all the time
259
Please help me in getting a solution of this issue

Hassan-HS
07-01-2013, 08:11 AM
Dear Hasan,

PositionsTotal & Account methods already working, There was a problem in sample I've fix it.

The below Sample works 100%.

Note:
-We recommend that you work on VTL client if you programming scripts that's have GUI, Because you are already open the client terminal, So :
1- You can notice the difference of speed between them.
2- VTL client give you more features and flexibility.





Dim lbl as VTLGeneral.VTLControls. CChartObjectLabel
Dim lbl2 as VTLGeneral.VTLControls. CChartObjectLabel
Dim colvalues as System.Collections.Generic.List(Of VTLGeneral.VTLControls.ListViewcolumn)
Dim colvalue as VTLGeneral.VTLControls.ListViewcolumn
Dim _position as VTLGeneral.CPosition
Dim lst as VTLGeneral.VTLControls.VTLListView
Dim itemvalues as New System.Collections.Generic.List(Of VTLGeneral.VTLControls.ListViewItem)
Dim frm as VTLGeneral.VTLForm
Dim itemvalue as VTLGeneral.VTLControls.ListViewItem

Public Sub main()



colvalues = New System.Collections.Generic.List(Of VTLGeneral.VTLControls.ListViewcolumn)

Dim listOfcolumns as New VTLGeneral.VTLControls.ListViewcolumns
Dim _index as integer
lst= New VTLGeneral.VTLControls.VTLListView("lst1")
frm= New VTLGeneral.VTLForm("frm1")
frm.AddVTLControl(lst)
lst.Height="2000"
lst.Width ="10000"
lst.Top ="2000"
lst.left ="500"

colvalue= New VTLGeneral.VTLControls.ListViewcolumn
colvalue.Text="Symbol Name"
colvalue.Key ="SymbolName"
colvalue.Index=cstr(1)
colvalues.add(colvalue)


colvalue= New VTLGeneral.VTLControls.ListViewcolumn
colvalue.Text="Ticket"
colvalue.Key="Ticket"
colvalue.Index=cstr(2)
colvalues.add(colvalue)

colvalue= New VTLGeneral.VTLControls.ListViewcolumn
colvalue.Text="Type"
colvalue.Key="BuySell"
colvalue.Index=cstr(3)
colvalues.add(colvalue)

colvalue= New VTLGeneral.VTLControls.ListViewcolumn
colvalue.Text="Amount"
colvalue.Key="Amount"
colvalue.Index=cstr(4)
colvalues.add(colvalue)



colvalue= New VTLGeneral.VTLControls.ListViewcolumn
colvalue.Text="OpenPrice"
colvalue.Key ="OpenPrice"
colvalue.Index=cstr(5)
colvalues.add(colvalue)


colvalue= New VTLGeneral.VTLControls.ListViewcolumn
colvalue.Text="CurrentPrice"
colvalue.Key ="CurrentPrice"
colvalue.Index=cstr(6)
colvalues.add(colvalue)


colvalue= New VTLGeneral.VTLControls.ListViewcolumn
colvalue.Text="Commission"
colvalue.Key="Commission"
colvalue.Index=cstr(7)
colvalues.add(colvalue)


colvalue = New VTLGeneral.VTLControls.ListViewcolumn
colvalue.Text="Interest"
colvalue.Key="Interest"
colvalue.Index=cstr(8)
colvalues.add(colvalue)

lst.AddHeader(colvalues)
colvalues.clear()


lbl = New VTLGeneral.VTLControls.CChartObjectLabel("lbl1")
lbl2 = New VTLGeneral.VTLControls.CChartObjectLabel("lbl2")

Dim btn as VTLGeneral.VTLControls.CChartObjectButton
Dim btn2 as VTLGeneral.VTLControls.CChartObjectButton
Dim btn3 as VTLGeneral.VTLControls.CChartObjectButton
Dim btn4 as VTLGeneral.VTLControls.CChartObjectButton

btn = New VTLGeneral.VTLControls.CChartObjectButton("btn1")
btn2= New VTLGeneral.VTLControls.CChartObjectButton("btn2")
btn3= New VTLGeneral.VTLControls.CChartObjectButton("btn3")
btn4= New VTLGeneral.VTLControls.CChartObjectButton("btn4")




btn.Width ="700"
btn2.Width="700"
btn3.Width="700"
btn4.Width="700"

frm.AddVTLControl(btn)
frm.AddVTLControl(btn2)
frm.AddVTLControl(btn3)
frm.AddVTLControl(btn4)

frm.AddVTLControl(lbl)
frm.AddVTLControl(lbl2)

btn.Height ="300"
btn2.Height="300"
btn3.Height="300"
btn4.Height="300"

btn.Top = "500"
btn2.Top = "500"
btn3.Top = "500"
btn4.Top = "500"

btn.left = "500"
btn2.left = "2500"
btn3.left = "4500"
btn4.left = "6500"


lbl.top = "1000"
lbl2.Top = "1500"

lbl.left = "2000"
lbl2.left = "2000"

btn.caption = "Acc Balance"
btn2.caption = "Acc Summary"
btn3.caption = "All Open Positions"
btn4.caption = "Account Name"

frm.width = "12000"
frm.Height = "5000"
lbl.width = "5000"
lbl2.width = "10000"

frm.show()

End Sub

Public Sub frm1_btn1_click()

Dim property_id as VTLGeneral.ENUM_ACCOUNT_INFO_DOUBLE

property_id=VTLGeneral.ENUM_ACCOUNT_INFO_DOUBLE.AC COUNT_BALANCE

Dim x as integer

lbl.caption=("Balance is:" & ClientCode.AccountInfoDouble(x).ToString())


End Sub



Public Sub frm1_btn2_click()


Dim balance, FltPL, credite, equity, marginReq, marginLevel, EFFmargine As Double
Dim result as VTLGeneral.CallingResultsEnum

result=ClientCode.AccountSummaries(balance, FltPL, credite, equity, marginReq, marginLevel, EFFmargine )

If result=1 Then
lbl2.caption=("Balance : " & balance.Tostring & " , FltPL : " & FltPL.Tostring & " , Credite : " & credite.Tostring & " , Equity : " & equity.Tostring & " , MarginReq : " & marginReq.Tostring & " , MarginLevel : " & marginLevel.Tostring & " , EFFmargine" & EFFmargine.Tostring)
End If


End Sub

Public Sub frm1_btn3_click()


Dim type as string
Dim i as integer

For i = 1 To ClientCode.PositionsTotal()

itemvalue = New VTLGeneral.VTLControls.ListViewItem
_position=ClientCode.OpenPositionByIndex(i)

itemvalue.Text=_position.SymbolName


itemvalue.Key="S" & _position.Ticket
itemvalue.Index=CSTR(i)


itemvalue.AddSubItem(_position.Ticket)
IF _position.BuySell=1 Then

Type ="Buy"

ElseIF _position.BuySell=-1 Then

Type ="Sell"

ElseIF _position.BuySell=2 Then

Type ="BuyStop"

ElseIF _position.BuySell=-2 Then

Type ="SellStop"

End IF

itemvalue.AddSubItem(Type)
itemvalue.AddSubItem(_position.Lots)
itemvalue.AddSubItem(_position.Price)
itemvalue.AddSubItem(_position.ClosePrice)
itemvalue.AddSubItem(_position.Commission)
itemvalue.AddSubItem(_position.Interest)
itemvalues.add(itemvalue)

Next

lst.AddListItem(itemvalues)


End Sub

Public Sub frm1_btn4_click()

GUI.MsgDialog (Clientcode.AccountInfoString (2 ) )

End Sub

nhasan
07-01-2013, 09:11 AM
Thanks for your quick reply
Yes your code is error free now, I can compile and run it from my VTL editor
But the result is same - it can't show updated value from my demo account.
Did you see my screenshot given in first message?
It clearly shows that I have open positions with floating profit but the code says FltPL = 0
I have open positions but the code can't show them in list view
Now, I have account balance 49945 after closing a position with 4 profit, but your code still showing account balance 49941
260
Please check this attachment - this forum don't support 100K+ file, So I have to make it small

nhasan
07-01-2013, 09:49 AM
Here is my account information
Account ID: USER12255
Password: Standard
Please check this account - I think there may be some restriction in account settings to run server side code on it

Hassan-HS
07-01-2013, 09:57 AM
Dear Hasan,

Thank You for Contacting Us!
I just Opened a demo Account, then I test the script and its worked well.
Notice :

The update of FltPL handles with click on " Acc Summary " Button.
Please don't hesitate to contact me if you have any questions.

Regards.

nhasan
07-01-2013, 10:06 AM
Yes, My assumption is right
There was problem in that demo account
I open another demo account and now it's working
Thanks for your support

nhasan
07-01-2013, 10:16 AM
Now I have another problem it can't show pending orders in the list
I have four open order - 1. GPBUSD BUY 2. EURUSD SELL 3. GBPUSD BuyStop 4. GBPUSD SellStop
But it shows only first two order - buy and sell order
Function ClientCode.PositionsTotal() returns 2
Don't it include pending orders in total position count?

Salah-HS
07-01-2013, 11:20 AM
Dear nhasan,
It's just a sample to learn you how to use the VTL, and you can build your own code for whatever task you want.
Regards.

nhasan
07-01-2013, 02:48 PM
Dear nhasan,
It's just a sample to learn you how to use the VTL, and you can build your own code for whatever task you want.
Regards.

Yes I know it's a sample - but the code should work properly as it is published in the knowledge base for VTL programming reference.

However, can you read pending orders ( Buy Stop, Sell Stop etc ) from your code?
Do you use ClientCode.PositionsTotal() function in your script?

I am working in programming of a strategy where reading pending orders from code is very much important and so I am looking for the way to get them.

Thanks

Hassan-HS
07-01-2013, 09:40 PM
Dear Hasan

I will update you soon,Please standby.

Hassan-HS
07-02-2013, 03:48 PM
Dear Hasan,

we developed "OrdersTotal()", "GetOrderByIndex()" methods and its now under testing, We will release it soon as possible please standby.

nhasan
07-02-2013, 04:22 PM
Thanks for your wise decision
Please include an error free sample code in knowledge base using these two methods

nhasan
07-10-2013, 03:53 PM
Is there any update?
Did you fix the issue?

Hassan-HS
07-10-2013, 04:43 PM
Dear Hassan,

Of course we have developed our system to meet your needs :D

OrderByID (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/3664)

OrdersTotal (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/3665)

OrderByIndex (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/3663)

nhasan
07-11-2013, 03:43 PM
Thanks

But it's not my personal requirement
It's a basic feature for any trading platform.

Hassan-HS
07-11-2013, 04:07 PM
Sure,but In general we are ready to meeting the needs of the clients :)