Right, so I’ve been struggling with creating a (new) Stop and/or Limit for an existing Trade. I’m not sure why, since I can easily create Market- and Limit Entry Orders. I tried every combination, checked the values over and over again, included some optional values and even hardcoded the value-map entries, but when it comes to assigning an O2GRequest variable to the Request Factory’s “CreateOrderRequest”-method with the value-map, the variable simply remains null. Here’s the simplest form of the code I’m using:
- Code: Select all
Using factory As O2GRequestFactory = mSession.getRequestFactory
Using newValueMap As O2GValueMap = factory.createValueMap
With newValueMap
.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder)
.setString(O2GRequestParamsEnum.OrderType, Constants.Order.Stop)
.setString(O2GRequestParamsEnum.OfferID, "1")
.setString(O2GRequestParamsEnum.AccountID, myAccount.AccountID)
.setString(O2GRequestParamsEnum.TradeID, myOpenTrade.TradeID)
.setString(O2GRequestParamsEnum.BuySell, Constants.Sell) 'Since original Trade was a "Buy"
.setString(O2GRequestParamsEnum.Amount, myOpenTrade.Amount)
.setString(O2GRequestParamsEnum.Rate, myOpenTrade.OpenRate - 0.005)
Using theRequest As O2GRequest = factory.createOrderRequest(newValueMap)
Call mSession.sendRequest(theRequest)
End Using
End With
End Using
End Using
Hopefully I’m just missing something simple.