Script
”’################################################################################################
”’#### Script Name: All Open Positions #####
”’#### Author: Salah Abu-Ghalyon #####
”’#### Website: www.Hybridsolutions.com #####
”’#### Date: 19/06/2013 09:53:44 #####
”’#### Description: This VTL Server Script will show you all open positions in a list view#####
”’################################################################################################
Sample
Dim lbl as VTLGeneral.VTLControls.CChartObjectLabelDim lbl2 as VTLGeneral.VTLControls. CChartObjectLabelDim colvalues as System.Collections.Generic.List(Of VTLGeneral.VTLControls.ListViewcolumn)Dim colvalue as VTLGeneral.VTLControls.ListViewcolumnDim _position as VTLGeneral.CPositionDim lst as VTLGeneral.VTLControls.VTLListViewDim itemvalues as New System.Collections.Generic.List(Of VTLGeneral.VTLControls.ListViewItem)Dim frm as VTLGeneral.VTLFormDim itemvalue as VTLGeneral.VTLControls.ListViewItemPublic 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.CChartObjectButtonbtn = 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 SubPublic Sub frm1_btn1_click() Dim property_id as VTLGeneral.ENUM_ACCOUNT_INFO_DOUBLE property_id=VTLGeneral.ENUM_ACCOUNT_INFO_DOUBLE.ACCOUNT_BALANCE Dim x as integer lbl.caption=("Balance is:" & ClientCode.AccountInfoDouble(x).ToString())End SubPublic 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 IfEnd SubPublic 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 SubPublic Sub frm1_btn4_click() GUI.MsgDialog (Clientcode.AccountInfoString(2))End Sub
See Also
Back to VTL Server Script Index