开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Please help - VB code --- SEE command4_click


multicen2002
 

Option Explicit
' contract description vars

Dim id As Long
Dim symbol As String
Dim secType As String
Dim expiry As String
Dim strike As Long
Dim right As String
Dim exchange As String
Dim curency As String
Dim port As Long


Private Sub Command1_Click()
Tws1.reqMktData id, symbol, secType, expiry, strike, right, exchange,
curency
Label23.ForeColor = vbGreen
Label23.Caption = "connected"
End Sub

Private Sub Command2_Click()
Tws1.cancelMktData id
Label23.ForeColor = vbRed
Label23.Caption = "disconnected"

End Sub

**
BAD CODE
**

Private Sub Command4_Click()
Call Tws1.placeOrder(3030, "BUY",
1, "ES", "FUT", "200209", "", "", "GLOBEX", "", "LMT", 0, 0)
End Sub









Private Sub Form_Load()

'Here I have set all of the values as static constants for
demonstration purposes

port = 7496 'this is the port number you wrote down
id = 1 '
symbol = "ES"
secType = "FUT"
expiry = "200209"
strike = 0
right = ""
exchange = "GLOBEX"
curency = ""
Tws1.Connect "", port 'This must be the very first thing that is
called


End Sub

'------------------------------------------------------
' PRICES
'------------------------------------------------------



Private Sub Tws1_tickPrice(ByVal id As Long, ByVal tickType As Long,
ByVal price As Single)

'Dim oldprice
'Dim lastprice

'If tickType = LastPriceID Then
'If price > oldprice Then
'Label26.BackColor = vbRed
'End If
'oldprice = price
'End If
'End Sub










'*
'PRICE -last transaction
'*
Dim LastPrice

If id = 1 Then 'reference the reqMktData call by its id number
If tickType = 4 Then
LastPrice = price
Label1.Caption = Format(LastPrice, "0.00")
End If
End If

'*
'PRICE - BID
'*

Dim BIDPrice
If id = 1 Then 'reference the reqMktData call by its id number
If tickType = 1 Then
BIDPrice = price
Label3.Caption = Format(BIDPrice, "0.00")
End If
End If


'*
'PRICE - ASK
'*
Dim ASKPrice
If id = 1 Then 'reference the reqMktData call by its id number
If tickType = 2 Then
ASKPrice = price
Label4.Caption = Format(ASKPrice, "0.00")
End If
End If


End Sub

'------------------------------------------------------
' SIZES
'------------------------------------------------------

'*
'SIZE - LAST
'*

Private Sub Tws1_tickSize(ByVal id As Long, ByVal tickType As Long,
ByVal size As Long)

If id = 1 Then 'reference MUST BE 1
If tickType = 5 Then
'Label2.Caption = Format(size, "000000")
Label2.Caption = size
End If
End If

'*
'SIZE - BID
'*

If id = 1 Then 'reference MUST BE 1
If tickType = 0 Then
Label5.Caption = size

If size > 10 Then
Label7.Visible = True
Else
Label7.Visible = False
End If

If size > 20 Then
Label8.Visible = True
Else
Label8.Visible = False
End If

If size > 30 Then
Label9.Visible = True
Else
Label9.Visible = False
End If

If size > 40 Then
Label10.Visible = True
Else
Label10.Visible = False
End If

If size > 60 Then
Label11.Visible = True
Else
Label11.Visible = False
End If

If size > 100 Then
Label12.Visible = True
Else
Label12.Visible = False
End If

If size > 140 Then
Label13.Visible = True
Else
Label13.Visible = False
End If

If size > 180 Then
Label14.Visible = True
Else
Label14.Visible = False
End If

If size > 240 Then
Label15.Visible = True
Else
Label15.Visible = False
End If

If size > 320 Then
Label16.Visible = True
Else
Label16.Visible = False
End If

If size > 440 Then
Label17.Visible = True
Else
Label17.Visible = False
End If

If size > 560 Then
Label18.Visible = True
Else
Label18.Visible = False
End If

If size > 680 Then
Label19.Visible = True
Else
Label19.Visible = False
End If

If size > 800 Then
Label20.Visible = True
Else
Label20.Visible = False
End If

If size > 1200 Then
Label21.Visible = True
Else
Label21.Visible = False
End If

If size > 2000 Then
Label22.Visible = True
Else
Label22.Visible = False
End If






End If
End If


'*
'SIZE - ASK
'*

If id = 1 Then 'reference MUST BE 1
If tickType = 3 Then
Label6.Caption = size
End If
End If
End Sub

Join [email protected] to automatically receive all group messages.