Trade FOREX with FXCM

  • Award-Winning Platform
  • 24/7 Customer Support
  • Trade Directly on Charts
  • Free $50K Practice Account
Register


Results 1 to 4 of 4

Thread: about open / close position

  1. #1
    foongshen is offline Member
    Join Date
    Apr 2012
    Posts
    29

    about open / close position

    hi,

    may i know ...

    1 ) how to close position by using Ticket ID ?
    2 ) how to open position together setting for "Stop Lost" and "Stop Gain" ?

    thanks ( many thanks for any sample code )

    NOTE : API Version : FX Connect 1.0.3 (Beta)
    Last edited by foongshen; 06-14-2012 at 10:31 PM.

  2. #2
    Natalya is offline Member
    Join Date
    Apr 2009
    Posts
    744
    Hi,

    Please see the samples ClosePosition and OpenPosition in the samples folder within the folder where ForexConnect is installed.
    For example, cpp samples are located in:
    ...\ForexConnectAPI\samples\cpp\SimpleSamples\ClosePosition
    ...\ForexConnectAPI\samples\cpp\SimpleSamples\OpenPosition

    To open a position with Stop and Limit, you should fill additional parameters in valuemap. For details, please see Attach Stop and/or Limit Orders to the Command.

  3. #3
    foongshen is offline Member
    Join Date
    Apr 2012
    Posts
    29
    ok .. thanks. but if i do open position by valueMap.setString(O2GRequestParamsEnum.ORDER_TYPE, "OM"); and i manage to set my stop lost by -50 pips. so what values do i need to specified to valueMap.setDouble(O2GRequestParamsEnum.RATE_STOP, ???); ?

    NOTE :
    Programming Platform : JAVA
    API Version : FX Connect 1.0.3 (Beta)

  4. #4
    Natalya is offline Member
    Join Date
    Apr 2009
    Posts
    744
    Hi,

    There are two ways to specify the Stop/Limit price:
    1) as a price level (for example, 1.2600)
    or
    2) as an offset (in pips) against the market price (for example, -50).

    If you want to specify stop as a price level, use the parameter RATE_STOP. For example:
    Code:
    valueMap.setDouble(O2GRequestParamsEnum.RATE_STOP, mRateStop);
    where mRateStop is the price level of the stop order, e.g. 1,2600.

    If you want to specify stop as an offset, use a pair of PEG_OFFSET_STOP and PEG_TYPE_STOP fields. For example:
    Code:
    valuemap.setString(O2GRequestParamsEnum.PEG_TYPE_STOP, Constants.Peg.FromClose); // The peg stop type
    valuemap.setDouble(O2GRequestParamsEnum.PEG_OFFSET_STOP, dPegStopOffset);
    where dPegStopOffset is an offset in pips. For sell orders, it should be positive (e.g. "50"), for buy orders, it should be negative (e.g. "-50").

    Please see also Attach Stop and/or Limit Orders to the Command

    I hope this helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Disclaimer: Trading foreign exchange on margin carries a high level of risk, and may not be suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to trade foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with foreign exchange trading, and seek advice from an independent financial advisor if you have any doubts. Any opinions, news, research, analyses, prices, or other information contained on this website is provided as general market commentary and does not constitute investment advice. Forex Capital Markets LLC. will not accept liability for any loss or damage, including without limitation to, any loss of profit, which may arise directly or indirectly from use of or reliance on such information.