Closed AVISHAY123 closed 3 years ago
here is example ho to change a waiting order price or amount, you may need to pass to this function the order_id for the stop or limit attached to open position.
Sub editOrder(sOrderID As String, sAccountID As String, iAmount As Integer, dRate As Double) Dim factory As IRequestFactory Set factory = mSession.getRequestFactory() If factory Is Nothing Then Exit Sub End If Dim valuemapChangeOrder As IValueMap Set valuemapChangeOrder = factory.createValueMap() Call valuemapChangeOrder.setString(RequestParamsEnum_Command, fxconst.Commands.editOrder) Call valuemapChangeOrder.setString(RequestParamsEnum_OrderID, sOrderID) Call valuemapChangeOrder.setString(RequestParamsEnum_AccountID, sAccountID) Call valuemapChangeOrder.setDouble(RequestParamsEnum_Rate, dRate) Call valuemapChangeOrder.setInt(RequestParamsEnum_Amount, iAmount) Call valuemapChangeOrder.setString(RequestParamsEnum_CustomID, "EditOrderTest")
'create request from valueMap
Dim request As IRequest
Set request = factory.createOrderRequest(valuemapChangeOrder)
If request Is Nothing Then
MsgBox "Order's request can not be created: " + factory.getLastError()
Exit Sub
End If
Call mSession.sendRequest(valuemapChangeOrder)
End Sub
for more information please see online help, you may need to convert the C# to VBA, it uses same logic. https://fxcodebase.com/bin/forexconnect/1.4.1/help/DotNet/web-content.html#NetTradingCommandsEditOrder.html
Thank you but this is for a waiting order I need for running trade
when you have open position with stop an limit attached, the stop and limit are waiting orders and each has its own order_id, to change it you need to use order_id for stop or limit.
Thank you it works Which command can I add to configure trailstep?
the trailing stop can be changed from same function with same "editOrder" command, for example
Call valuemapChangeOrder.setInt(RequestParamsEnum_TrailStep, 15)
I get an error "object required" there is no valuemapChangeOrder object
the Call valuemapChangeOrder.setInt(RequestParamsEnum_TrailStep, 15) should be part of editOrder() function above.
There is no error now, but it does nothing
does the attached stop have already trailing stop? this function is to change existing order with trailing stop
no How can I add trailing stop?
when you create the new order add the trailing stop with the attached stop, using same Call valuemapChangeOrder.setInt(RequestParamsEnum_TrailStep, 15) just add it to the CreateOrder command.
I created a new order and add that line But, there is no trailstep
what are the valuemap fields
Set valueMap = requestFactory.createValueMap()
Call valueMap.setString(RequestParamsEnum_Command, constants.Commands.createOrder)
Call valueMap.setString(RequestParamsEnum_OrderType, constants.orders.TrueMarketOpen)
Call valueMap.setInt(RequestParamsEnum_Amount, amount)
Call valueMap.setString(RequestParamsEnum_BuySell, buysell)
Call valueMap.setString(RequestParamsEnum_AccountID, MyAcc)
Call valueMap.setString(RequestParamsEnum_OfferID, offer.OfferID)
Call valueMap.setDouble(RequestParamsEnum_RateLimit, Up)
Call valueMap.setDouble(RequestParamsEnum_RateStop, Dn)
Call valueMap.setInt(RequestParamsEnum_TrailStep, 50)
Please replace TrailStep with TrailStepStop so the trailing stop will be for the attached stop not for the main order
Now, the order not created
Example ELS order with Trailing Stop
O2GRequest request = null; O2GRequestFactory requestFactory = session.getRequestFactory();
O2GValueMap valuemap = requestFactory.createValueMap(); valuemap.setString(O2GRequestParamsEnum.Command, Constants.Commands.CreateOrder); valuemap.setString(O2GRequestParamsEnum.OrderType, "OM"); valuemap.setString(O2GRequestParamsEnum.AccountID, sAccountID); valuemap.setString(O2GRequestParamsEnum.OfferID, sOfferID); valuemap.setString(O2GRequestParamsEnum.BuySell, sBuySell); valuemap.setInt(O2GRequestParamsEnum.Amount, iAmount); valuemap.setDouble(O2GRequestParamsEnum.Rate, dRate); valuemap.setDouble(O2GRequestParamsEnum.RateLimit, dRateLimit); valuemap.setDouble(O2GRequestParamsEnum.RateStop, dRateStop); valuemap.setString(O2GRequestParamsEnum.CustomID, "EntryOrderWithStopLimit"); valuemap.setString(O2GRequestParamsEnum.TimeInForce, Constants.TIF.GTC); valuemap.setInt(O2GRequestParamsEnum.TrailStepStop, dTrailStepStop); <---- Trailing Stop
Thank you but trade not created If I omit the last line, it created
which version of FC API you using?
1.4.1
the fixed trailing stop should be 10 or above, dynamic trailing stop should be 1, just tested and it seems ok
Call valueMap.setInt(RequestParamsEnum_TrailStepStop, 10)
still not created with that line
can you please email the related snip code and parameters values to api@fxcm.com
I just did
How to change trade Stop Limit via vba / excel? thank you