| || |
about open / close position
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.
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:
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.
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, ???); ?
Programming Platform : JAVA
API Version : FX Connect 1.0.3 (Beta)
There are two ways to specify the Stop/Limit price:
1) as a price level (for example, 1.2600)
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:
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:
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").
valuemap.setString(O2GRequestParamsEnum.PEG_TYPE_STOP, Constants.Peg.FromClose); // The peg stop type
Please see also Attach Stop and/or Limit Orders to the Command
I hope this helps.
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.