How do you cancel an IOrderStopLimit?

Questions about MultiCharts .NET and user contributed studies.
kentc
Posts: 3
Joined: 08 Apr 2019

How do you cancel an IOrderStopLimit?

Postby kentc » 03 Jan 2020

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?
...
}

darob
Posts: 187
Joined: 20 Nov 2014
Has thanked: 50 times
Been thanked: 25 times

Re: How do you cancel an IOrderStopLimit?

Postby darob » 07 Jan 2020

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.

kentc
Posts: 3
Joined: 08 Apr 2019

Re: How do you cancel an IOrderStopLimit?

Postby kentc » 07 Jan 2020

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.
darob, thanks for your input!

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

darob
Posts: 187
Joined: 20 Nov 2014
Has thanked: 50 times
Been thanked: 25 times

Re: How do you cancel an IOrderStopLimit?

Postby darob » 08 Jan 2020

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.

kentc
Posts: 3
Joined: 08 Apr 2019

Re: How do you cancel an IOrderStopLimit?

Postby kentc » 09 Jan 2020

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.
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.

Thanks for your input.

Kent


Return to “MultiCharts .NET”