I'm trying to run this through a Strategy w/o broker connection. I can create and place an order but unable to cancel the order if market conditions change. How do I cancel a pending StopLimit or Limit order. Also, can you change the entry or stop limit price once the order has been placed?
Thanks!
private IOrderStopLimit m_longeo;
protected override void Create()
{
...
m_longeo = OrderCreator.StopLimit(new SOrderParameters(Contracts.Default, "longEO", EOrderAction.Buy));
...
}
protected override void StartCalc()
{
...
// place stoplimit order
m_longeo.Send(stop_price, limit_price);
...
// order waiting to be filled. several bars may go by
...
// now market conditions change. order no longer required
m_longeo.Cancel()??????
// how do i cancel an order that was never filled or change its price?
...
}
How do you cancel an IOrderStopLimit?
Re: How do you cancel an IOrderStopLimit?
Hi kentc, when the conditions that send the orders in your script are no longer met the order cancels. As far as changing price goes I think the old order is canceled when no longer valid and once conditions are met a new one is submitted. This is just my basic DIY approach, an advanced coder will have more info.
Re: How do you cancel an IOrderStopLimit?
darob, thanks for your input!Hi kentc, when the conditions that send the orders in your script are no longer met the order cancels. As far as changing price goes I think the old order is canceled when no longer valid and once conditions are met a new one is submitted. This is just my basic DIY approach, an advanced coder will have more info.
The conditions that determine order placement are made by the strategy (my code). One would assume if the strategy determines an order should be placed then the strategy may determine an unfilled order may be removed if unfilled at some time in the future. Seems pretty basic to me unless I'm missing something or need a better understanding how MC strategies work.
MC strategies appear to be designed more for market entry/exit orders, not limit/stoplimit orders. My manual trading involves a combination of stoplimit orders for entry, market and limit orders for exit. Seems a strategy should be able to handle this programmatically with ease.
Thanks,
Kent
Re: How do you cancel an IOrderStopLimit?
Hi kentc, Have you considered controlling it with an integer? ex. orderPersist must equal 1 for the order to be valid and when your conditions change it equals 2. You could also script a counter that works with the integer that cancels the order after x bars.
Re: How do you cancel an IOrderStopLimit?
That's what I do - use internal flags to determine order status, but MC does not provide a function to pull, delete, change, or cancel an order. You can only "Send" them. Doesn't make any sense.Hi kentc, Have you considered controlling it with an integer? ex. orderPersist must equal 1 for the order to be valid and when your conditions change it equals 2. You could also script a counter that works with the integer that cancels the order after x bars.
Thanks for your input.
Kent