View Full Version : close trades vb examples
smyers
05-07-2006, 06:25 AM
Hi,
Can you provide examples in VB to close trades?
SM:)
ariva
06-14-2006, 02:37 PM
ok here ist my little code snipplet:
Public Function cmdClosePosition(TradeID As String, CurrencyPair As String, BuySell As String, Lots As Integer)
ERROR = 0
cmdClosePosition = ""
On Error Resume Next
Dim OrderNo, DealerInt
Dim QuoteID
Dim MarketRate As Double
Dim Ammounts
Dim Anzahl
Dim fractionSize
fractionSize = Int(Me.fncGetFractionSize())
Anzahl = Lots * fractionSize
If fractionSize > 1 Then
Ammounts = fractionSize / 1000
Else
If fncGetAccountType() = "10k" Then Ammounts = 10
If fncGetAccountType() = "100k" Then Ammounts = 100
End If
If (BuySell = "B") Then
MarketRate = Me.GetOfferBid(oTradeDesk1, CurrencyPair, QuoteID)
End If
If (BuySell = "S") Then
MarketRate = Me.GetOfferAsk(oTradeDesk1, CurrencyPair, QuoteID)
End If
oTradeDesk1.CloseTrade TradeID, Anzahl, MarketRate, QuoteID, 0, OrderNo, DealerInt
If Err.Number Then
ERROR = 1
cmdClosePosition = Err.Description
End If
If ERROR = 0 Then cmdClosePosition = CurrencyPair & " Amt(k): " & Ammounts & " at " & Format$(MarketRate, "0.0000")
End Function
FX42n
06-29-2006, 01:34 AM
I am not sure how to use this snippit, or how I can modify it to serve my needs, but regardless, I wish to thank you for your contribution. I hope as a beneficiary of your knowledge, I will be able to expand my understanding of vba and Excel through your contribution. Thank you.
vBulletin v3.5.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.