Market Order if Bid
Posted by Yousef Ibrahim, Last modified by Abdullah Almasharfah on 14 December 2018 10:20 PM

'''########################################################
'''####Script Name: MarketOrder if Bid                                                                  ####
'''####Script Description: This Server Script will take an order based on Symbol's Bid ####
'''####Author: Yousef Najjar                                                                                ####
'''####Website: http://www.hybrid-solutions.com                                                  ####
'''####Date: 22 / March / 2012                                                                           ####
'''#######################################################

Dim _symbolInfo as VTLGeneral.CSymbol=ClientCode.GetSymbolByName("GOLD")

Dim _NewOrderRecieved as NewOrderInfo
Dim _lots as double = 1

Public Sub main()

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 ) 
gui.msgdialog (balance)
if balance < 100 Then
gui.msgdialog ("Unable to perform operation due to low balance")
Else

'If result=1 Then
'GUI.MsgDialog("balance : " & balance.Tostring & " , FltPL : " & FltPL.Tostring & " , credite : " & credite.Tostring & " , equity : " & equity.Tostring & " , marginReq : " & marginReq.Tostring & " , marginLevel : " & marginLevel.Tostring & " , EFFmargine" & EFFmargine.Tostring)


ClientCode.NewMarketOrder(1,_symbolInfo.ID,_lots)
GUI.MsgDialog("New Market Order has been done")

 End if

End Sub

Public Sub OnCloseOrderResultRecieved(ByRef Result As VTLServerApplication.NewOrderResultEnum, ByRef AtPrice As Double, ByRef PosOrOrder As Short, ByRef OrderId As Integer, ByRef BuySell As VTLServerApplication.OperationTypeEnum, ByRef Lots As Double, ByRef Symbol As VTLServerApplication.CSymbol, ByRef ServerTime As String, ByRef OpenTicket As Integer)

GUI.MsgDialog("order has been closed ")

End Sub

Public Sub OnNewOrderResultRecieved(ByRef Result As VTLServerApplication.NewOrderResultEnum, ByRef AtPrice As Double, ByRef PosOrOrder As Short, ByRef OrderId As Integer, ByRef BuySell As VTLServerApplication.OperationTypeEnum, ByRef Lots As Double, ByRef Symbol As VTLServerApplication.CSymbol, ByRef ServerTime As String)

_NewOrderRecieved= New NewOrderInfo
_NewOrderRecieved.Result=Result
_NewOrderRecieved.AtPrice=AtPrice
_NewOrderRecieved.PosOrOrder =PosOrOrder 
_NewOrderRecieved.OrderId =OrderId
_NewOrderRecieved.BuySell =BuySell
_NewOrderRecieved.Lots=Lots
_NewOrderRecieved.Symbol =Symbol 
_NewOrderRecieved.ServerTime =ServerTime

End Sub

Public Class NewOrderInfo

Private _Result As VTLServerApplication.NewOrderResultEnum
Private _AtPrice As Double
Private _PosOrOrder As Short
Private _OrderId As Integer
Private _BuySell As VTLServerApplication.OperationTypeEnum
Private _Lots As Double
Private _Symbol As VTLServerApplication.CSymbol
Private _ServerTime As String

Public Property Result() As VTLServerApplication.NewOrderResultEnum
Get
Return _Result
End Get
Set(ByVal value As VTLServerApplication.NewOrderResultEnum)
_Result = value
End Set
End Property
Public Property AtPrice() As Double
Get
Return _AtPrice
End Get
Set(ByVal value As Double)
_AtPrice = value
End Set
End Property

Public Property PosOrOrder() As Short
Get
Return _PosOrOrder
End Get
Set(ByVal value As Short)
_PosOrOrder = value
End Set
End Property

Public Property OrderId() As Integer
Get
Return _OrderId
End Get
Set(ByVal value As Integer)
_OrderId = value
End Set
End Property

Public Property BuySell() As VTLServerApplication.OperationTypeEnum
Get
Return _BuySell
End Get
Set(ByVal value As VTLServerApplication.OperationTypeEnum)
_BuySell = value
End Set
End Property

Public Property Lots() As Double
Get
Return _Lots
End Get
Set(ByVal value As Double)
_Lots = value
End Set
End Property

Public Property Symbol() As VTLServerApplication.CSymbol
Get
Return _Symbol
End Get
Set(ByVal value As VTLServerApplication.CSymbol)
_Symbol = value
End Set
End Property

Public Property ServerTime() As String
Get
Return _ServerTime
End Get
Set(ByVal value As String)
_ServerTime = value
End Set
End Property

End Class



See Also


Back to VTL Server Script Index

(1 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).

Help Desk Software by Hybrid Solutions