CancelOrder  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
tradetree
Posts: 81
Joined: 29 Apr 2013
Location: www.threefoldmarkets.com
Has thanked: 12 times
Been thanked: 16 times
Contact:

CancelOrder

Postby tradetree » 22 Nov 2013

I am creating a Stop order and need to be able to cancel it at my own decision point in Signals code. Here is my entry setup in "Create":

Code: Select all

m_EnterLongStop = OrderCreator.Stop( new SOrderParameters(Contracts.Default, "LongStop", EOrderAction.Buy ));
And my entry in CalcBars:

Code: Select all

m_EnterLongStop.Send( entryPrice );
If I do not hit the stop under the conditions I have set I want to cancel the m_EnterLongStop. I have searched and found some references to CancelOrder, but no code example for how to invoke it. Can you share an example for my simple situation? And please note that I don't want to do something else, like wait for the conditions and enter a market order. I want the stop order at my price and then cancel the stop order if I no longer need it.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: CancelOrder

Postby JoshM » 24 Nov 2013

If I do not hit the stop under the conditions I have set I want to cancel the m_EnterLongStop. I have searched and found some references to CancelOrder, but no code example for how to invoke it. Can you share an example for my simple situation? And please note that I don't want to do something else, like wait for the conditions and enter a market order. I want the stop order at my price and then cancel the stop order if I no longer need it.
FYI, if you change your mind at a later point and want to use something else than CancelOrder, you can also cancel pending orders by not resubmitting then.

From the general MultiCharts manual (source; see also here):
An order is executed at the point specified by the parameters; if the order is not filled within the specified bar, the order is cancelled.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: CancelOrder  [SOLVED]

Postby Henry MultiСharts » 25 Nov 2013

In MultiCharts .Net there are two approaches for order generation: managed and umanaged orders.

Managed orders are monitored by the strategy. Strategy can be trading only one instrument that is the main data series of your chart. The orders are valid at broker while they are sent by the strategy. That means the conditions for order generation should be met in your code on each bar close or each tick (if IOG=ON) calculation while you need to keep your orders active. If you want to cancel the order-you need to stop sending it from the code (make the conditions for order generation invalid). There is no direct "cancel order" command for this approach.

With unmanaged orders you can manage the Generate and Cancel order commands directly from the code. With this approach you can trade on multiple symbols through different broker plugins directly from one script. The symbols don't need to be on the chart, but you are responsible for managing your orders. Here is an example of how to use the TradeManager. Another example - Trading from MultiCharts Realtime Market Scanner.
For more information please refer to .Net programming guide: Extended Trading Possibilities. TradeManager:1, 2, 3, 4.

We are also working on a new auto trading and backtesting engine that will provide a more user-friendly way to control how long orders should stay active until cancelled. You can vote for it here.


Return to “MultiCharts .NET”