Jump to content
Sign in to follow this  
OldWiseAndExperienced

Cleanest Method to Close an Fx Position

Recommended Posts

Hi,

So far, in order to close a position, in the Trade-NewTradeOrderRequestDTO function, I have to specify the current BID/ASK price, order direction, the orderID, Price Tolerance and Quantity. That's a lot of stuff creating a potentially fragile request condition that might fail.

However, I have to create a "sweep" function to close an position regardless of some of the above parameters.  This would be used when there has been some "breakage" or "disconnect
" that has been detected and I may not know at that moment some of the above extra parameters over and above the MarketID.

1 - Is there a way to create a very simple, minimalistic set of request parameters that would "just do it" (close the position) with just a MarketID.

As always, thanks for your answers.

Share this post


Link to post

Hello,

The absolute bare minimum you can send to close a trade successfully is:

  • MarketID
  • TradingAccountID
  • Direction
  • Quantity
  • BidPrice
  • OfferPrice
  • Close

The API is not designed or setup to close trades with just MarketID unfortunately. 

Kind Regards, PM

Share this post


Link to post

I see you didn't mention the PriceTolerance and the PositionMethodID parameters, presumably because you answered my question directly.

1 - Is that because the PriceTolerance default on your end is  +/- 2pips?
2 - I am currently specifying 50 pips as a "wide" tolerance allowing for a fair degree of slip, is that an allowable size? (I don't want to get caught by this potential order rejection)
3 - Are there any side effects to my approach to item 2 above?
4 - What is the maximum value for PriceTolerance that can be used?
5 - Is PriceTolerance always a positive number?

6 - Is the PositionMethodID parameter required/optional for submitting a market order AND/OR closing one?

As always, thanks for your answers.

Share this post


Link to post

I came across an unexpected result condition trying to close a trade today that I haven't encountered yet.  Could you please let me know what the below means and what are the implications (specifically related to the OrderStatusReason).

1 - Usually when I close a trade, at the very top of the result block I get something like the following which I observe as normal...

{
  "Status": 1,
  "StatusReason": 1,
  "OrderId": 672952211,
  "Orders": [
    {
      "OrderId": 672952211,
      "StatusReason": 1,
      "Status": 9,
      "OrderTypeId": 1,

2 - However today I received two of these (why am I seeing an OrderStatus of 3 instead of the usual 9).

{
  "Status": 1,
  "StatusReason": 1,
  "OrderId": 672952964,
  "Orders": [
    {
      "OrderId": 672952964,
      "StatusReason": 1,
      "Status": 3,
      "OrderTypeId": 1,

Could you please comment on this...

As always, thanks for your answers.

Share this post


Link to post

Hi,

In answer to your first post, PriceTolerance and PositionMethodId are not strictly mandatory parameters, although for example if you had an account that supported both long and short positions you would want to use PositionMethodId to avoid having off-setting position sin the same market. 

1) PriceTolerance uses a default value of 2, (unless you have already overridden the default for a market) so if you are happy to use 2 then you don't need to include that in your call. 

2) PriceTolerance values are in the range 0 - 1000. 

3) If you are using 50, it is possible in fast moving markets during high volatility (such as major new events) that could result in slippage of 50 points. But those events are rare.

4) 1000 is the maximum.

5) Yes, the range is 0 - 1000.

6) PositionMethodId would be necessary for account that support both long and short positions in the same market. Since that is not possible with FOREX.com accounts (which you have I believe), then you can leave it out if you'd prefer not to include it in your calls. 

Kind Regards, PM

Share this post


Link to post

Hi,

In answer to your 2nd post.

Order Status 3 indicates your positions is still OPEN. Did you accidentally partial close your open position rather than full close?

If you still have a (reduced size) position open, then 3 is returned to indicate OPEN - since you still have a position.

Kind Regards, PM

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×