how Cancel un-filled limit/stop orders at end custom session

Questions about MultiCharts and user contributed studies.
faraz
Posts: 141
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 56 times

how Cancel un-filled limit/stop orders at end custom session

Postby faraz » 02 Aug 2014

Hi,

How to Cancel un-filled limit/stop orders at end of custom session?

Symbol: ESU4
Data Feed: Rithmic
Time in force: Day
Custom session time: 8:30 to 15:15
Time: Exchange
Strategy Auto trading was running using SA settings.

Limit Order was generated at 15:00
My custom session closed at 15:15
My order stayed active and filled out side custom session time at 15:33 this is a bad.

Issue is MC is not canceling un-filled orders at Custom Session Close. I found no settings or any code to cancel un-filled orders after custom session close.

Awaiting

User avatar
JoshM
Posts: 2100
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1526 times
Been thanked: 1507 times
Contact:

Re: how Cancel un-filled limit/stop orders at end custom ses

Postby JoshM » 03 Aug 2014

In a recent thread this was also discussed, perhaps it might help you too:

Command to close all limit orders at broker?

faraz
Posts: 141
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 56 times

Re: how Cancel un-filled limit/stop orders at end custom ses

Postby faraz » 03 Aug 2014

In a recent thread this was also discussed, perhaps it might help you too:

Command to close all limit orders at broker?
Thank you.

So its look like for the time being there is no solution.

User avatar
JoshM
Posts: 2100
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1526 times
Been thanked: 1507 times
Contact:

Re: how Cancel un-filled limit/stop orders at end custom ses

Postby JoshM » 10 Aug 2014

So its look like for the time being there is no solution.
I'm not sure, because to me it seems like there is. For example, this code cancels the limit order when the time is 15:10 or later:

Code: Select all

if (Time < 1510) then
Sell ("XL") 1 contract next bar at myPrice limit;
Wouldn't that cancel your pending limit orders prior to the market close?

faraz
Posts: 141
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 56 times

Re: how Cancel un-filled limit/stop orders at end custom ses

Postby faraz » 10 Aug 2014

So its look like for the time being there is no solution.
I'm not sure, because to me it seems like there is. For example, this code cancels the limit order when the time is 15:10 or later:

Code: Select all

if (Time < 1510) then
Sell ("XL") 1 contract next bar at myPrice limit;
Wouldn't that cancel your pending limit orders prior to the market close?

This code will do nothing for Pending orders. Because to send SELL order MC must have Marketposition staus equal to 1. For unfilled / Pending orders there is no in MC to check status. Only way is to cancel orders manually.

Currently I am using 3rd party software Macro Recorder to cancel all pending orders automatically at 1515, untill v9.1 is released, which is suggested to have a solution for this scenario.

Thanks

User avatar
JoshM
Posts: 2100
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1526 times
Been thanked: 1507 times
Contact:

Re: how Cancel un-filled limit/stop orders at end custom ses

Postby JoshM » 10 Aug 2014

This code will do nothing for Pending orders. Because to send SELL order MC must have Marketposition staus equal to 1.
I don't see the problem. I suppose we're both talking about something different. Since why wouldn't you be able to stop sending a sell order when there is an open market position?

In code, the following always worked for me:

Code: Select all

// Manage long position
if (MarketPosition(0) > 0) then begin

// Keep submitting sell order till 15:00
if (CurrentTime < 1500) then
Sell ("XL") all contracts next bar at myPrice limit;

end;

faraz
Posts: 141
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 56 times

Re: how Cancel un-filled limit/stop orders at end custom ses

Postby faraz » 11 Aug 2014

I don't see the problem. [/code]

a) Place a buy limit order - 5 points below price. To make sure it won't get filled and stay status as Pending/Unfilled/Submitted.

b) Then try to cancel that order from PowerLanguage Script.


Thanks

User avatar
ABC
Posts: 636
Joined: 16 Dec 2006
Has thanked: 120 times
Been thanked: 360 times
Contact:

Re: how Cancel un-filled limit/stop orders at end custom ses

Postby ABC » 11 Aug 2014

faraz,

in my opinion JoshM was just pointing this out as an example. You would need to add the time condition to your order under a). Then it would get cancelled once the time condition is not fulfilled anymore.

Regards,
ABC
I don't see the problem. [/code]

a) Place a buy limit order - 5 points below price. To make sure it won't get filled and stay status as Pending/Unfilled/Submitted.

b) Then try to cancel that order from PowerLanguage Script.


Thanks

faraz
Posts: 141
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 56 times

Re: how Cancel un-filled limit/stop orders at end custom ses

Postby faraz » 11 Aug 2014

faraz,

in my opinion JoshM was just pointing this out as an example. You would need to add the time condition to your order under a). Then it would get cancelled once the time condition is not fulfilled anymore.

Regards,
ABC
Correct, But I tested it before, It does not work on my strategy. My strategy is not day trading and it some time hold position over night + submit limit orders.

MC support team confirmed my solution would be in v9.1 release. I would like to wait for it, which is expected by the end of this year.

Thanks

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

Re: how Cancel un-filled limit/stop orders at end custom ses

Postby Henry MultiСharts » 12 Aug 2014

MC support team confirmed my solution would be in v9.1 release. I would like to wait for it, which is expected by the end of this year.
Apparently there has been some misunderstanding. That is correct that MultiCharts 9.1 will have new backtesting/auto trading engine with direct order control from the code. But as we and the other users have stated before - that is already possible to cancel pending orders prior to session close. You can also leave a position overnight if your broker allows that.

faraz
Posts: 141
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 56 times

Re: how Cancel un-filled limit/stop orders at end custom ses

Postby faraz » 12 Aug 2014

Apparently there has been some misunderstanding. That is correct that MultiCharts 9.1 will have new backtesting/auto trading engine with direct order control from the code. But as we and the other users have stated before - that is already possible to cancel pending orders prior to session close. You can also leave a position overnight if your broker allows that.

May be if I convert my strategy to lower time frame like 1 minute or convert it to IOG. Then I would be able to do some thing at the closest Session End time. I tried to bring my strategy to lower time frame but that was taking a lot of time as I have more than 1 strategy which is facing this issue. So I used an alternative way around to handle all strategies from one solution and so far it is working fine for me.

Thanks

Gaempi
Posts: 50
Joined: 27 Jul 2010
Location: Switzerland
Has thanked: 3 times
Been thanked: 4 times

Re: how Cancel un-filled limit/stop orders at end custom ses

Postby Gaempi » 19 Aug 2014

MC support team confirmed my solution would be in v9.1 release. I would like to wait for it, which is expected by the end of this year.
Apparently there has been some misunderstanding. That is correct that MultiCharts 9.1 will have new backtesting/auto trading engine with direct order control from the code. But as we and the other users have stated before - that is already possible to cancel pending orders prior to session close. You can also leave a position overnight if your broker allows that.
Hello Henry

How is it possible to cancel pending orders at broker prior to session close ?

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

Re: how Cancel un-filled limit/stop orders at end custom ses

Postby Henry MultiСharts » 19 Aug 2014

Hello Henry

How is it possible to cancel pending orders at broker prior to session close ?
Hello Gaempi,

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-stop sending it from the code (make the conditions for order generation invalid). Examples were already provided by JoshM above:
For example, this code cancels the limit order when the time is 15:10 or later:

Code: Select all

if (Time < 1510) then
Sell ("XL") 1 contract next bar at myPrice limit;
In code, the following always worked for me:

Code: Select all

// Manage long position
if (MarketPosition(0) > 0) then begin

// Keep submitting sell order till 15:00
if (CurrentTime < 1500) then
Sell ("XL") all contracts next bar at myPrice limit;

end;


Return to “MultiCharts”