Author |
Topic: simple C# Code snipped for executing order (5 messages, Page 1 of 1) |
||||
---|---|---|---|---|---|
Moderators: VPfau | |||||
eo707 Posts: 68 Joined: Nov 08, 2011 |
I will describe in a short way what I am looking for..
To order one order (short or long) with trailing stop. Describe the contract, the quantity, action at market price, and delta (in points) for trailing stop. Will appreciate your response. I can see on the advance API sample application a draft order.. But, I still don't get the structure of the objects (fully). Thank you. I Edited by eo707 on Dec 9, 2011 at 00:27:51 |
||||
VictorV Posts: 746 Joined: May 08, 2007 |
Hello,
you can find out structure of objects here: http://www.openecry.com/api/api/index.html Victor Vins Lead Software Developer |
||||
eo707 Posts: 68 Joined: Nov 08, 2011 |
I am trying to get to create an order with stop loss.
Will I have to make two orders, one market and one stop? Or you have order type OrderType.TrailingStopLoss, then How I bind it to a specific order? I got this: var draft = oec.CreateDraft(); draft.Account = oec.Accounts.First; draft.Side = OrderSide.Buy; draft.Quantity = 1; draft.Contract = oec.Contracts["RLM-MZ1"]; draft.Type = OrderType.TrailingStopLoss; //or market??? draft.Price = 720; //if I buy and price is 720.5 (mean I wish to have 0.5 stop loss) oec.SendOrder(draft); This order is rejected "Wrong stop price of trailing stop order". If I make two orders, with the first one I will buy market, then another with this trailing stop loss (so Buy market, and sell Trailing stop loss???) How do I bind the second order to the first (to trail what?). Can I get a specific help instead of sending me to the general documentation? Thank you. |
||||
VictorV Posts: 746 Joined: May 08, 2007 |
No sure, what do you mean under "stop loss" order. In my opinion "stop loss" is a just Stop order. TrailingStopLoss has another function than just stop loss. Could you please clarify what you are trying to accomplish? A reference to OEC Trader functionality will be helpful.
Victor Vins Lead Software Developer |
||||
eo707 Posts: 68 Joined: Nov 08, 2011 |
Thank you victor,
let me put an example. I will ignore the contract and the points and consider one number as the minimum move of the prospect contract (or any other). I intent to explain the meaning of what I am trying to achieve (trailing stop loss - limit my possible loss in case I am wrong with my direction (long / short) and movement of the prices). Let's say the market is on 6. I anticipate that the market will go up, so I wish to buy for long. But I wish to say that the market will go against me up to 2 points. So my stop loss (can be a stop order or the trailing stop loss) will be set to 4 or delta of 2 points below. Now let's say the market went up in a point, so my stop order should go up in a point, and will rise to 5, so by now my possible loss it 1 point, then the market went down to 5 and the stop loss order will stay on 4. then the market jump to 7, my stop loss (trailing stop) will move up to 5. At this point, I can't lose... and if the market will go up to 8, then the stop loss will rise to 6 and I will have definite profit of one point. (of course there are many other possibilities that it won't be a profit). This example is to explain the trailing stop loss order. Can I have the option to set an order to buy at market price (at 6) with 2 points stop loss (delta), or will I have to set two orders, buy at market and sell stop two point below. But you have the OrderType.TrailingStopLoss. http://www.openecry.com/api/api/OEC.Data.OrderType.html So according to the example above, I have tried to setup this order. var draft = oec.CreateDraft(); draft.Account = oec.Accounts.First; draft.Quantity = 1; draft.Contract = oec.Contracts["MyContract"]; draft.Side = OrderSide.Sell; draft.Type = OrderType.TrailingStopLoss; draft.Price = 4; oec.SendOrder(draft); And I do that after buying one contract at 4. But the order get rejected: "Rejected: Invalid absolute offset" I am adding this image to show how the Global Zen has this option with delta. http://i44.tinypic.com/v74hf6.jpg My best result will be to send one order with trailing stop "buy at 6, allow lost of 2 points". Thank you for your support |
||||