Closing Auction Session/ Hong Kong Stock Exchange / Market-on-Close and Limit-on-Close order types to IB  [SOLVED]

Questions about MultiCharts and user contributed studies.
LMC1
Posts: 50
Joined: 28 Apr 2013
Has thanked: 29 times
Been thanked: 1 time

Closing Auction Session/ Hong Kong Stock Exchange / Market-on-Close and Limit-on-Close order types to IB

Postby LMC1 » 21 Mar 2017

Hi,

The regular trading session of Hong Kong Stocks Exchange ends at 4:00 p.m. Then between 4:00 p.m. and 4:10 p.m. is the Closing Auction Session. Market participants can place auction orders to buy or sell stocks from 4:00 p.m. . On random basis, the market will close at any time between 4:08 and 4:10 p.m., with all matchable orders filled.

I trade Daily bars, I want to know how to place Market-on-Close and Limit-on-Close order after 4:00 p.m., say at 4:06 p.m., in order to participate into the Closing Auction Session.

Thanks,
LMC1

Xyzzy
Posts: 162
Joined: 19 Mar 2011
Has thanked: 43 times
Been thanked: 79 times

Re: Closing Auction Session/ Hong Kong Stock Exchange / Market-on-Close and Limit-on-Close order types to IB

Postby Xyzzy » 21 Mar 2017

Unfortunately, MultiCharts doesn't support custom order types like MoC or LoC. You can use SetExitOnClose() to simulate a market order at the closing price, but it doesn't work in live trading.

viewtopic.php?f=16&t=10811

The problem is that MultiCharts doesn't know that the session is ending until after it has actually ended, when it's too late to submit an order. (I.e., after it's received the closing tick of the bar.)

One workaround is to place a market or limit order just before the end of the day. E.g., if you have a one-minute chart, you can test whether the time is X number of minutes prior to the session close and then generate a market or limit order. However, that will only be traded during the live session. An example (using MultiCharts.net):

https://www.tradingcode.net/multicharts ... ior-close/

If you absolutely need to place a true MoC or LoC order with your broker, you can roll up your sleeves and write a custom DLL plugin that transmits the order manually using your broker's API. However, lots of things could go wrong, since you're bypassing MultiChart's built-in order manager. I wouldn't recommend it.

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Closing Auction Session/ Hong Kong Stock Exchange / Market-on-Close and Limit-on-Close order types to IB  [SOLVED]

Postby TJ » 21 Mar 2017

Hi,

The regular trading session of Hong Kong Stocks Exchange ends at 4:00 p.m. Then between 4:00 p.m. and 4:10 p.m. is the Closing Auction Session. Market participants can place auction orders to buy or sell stocks from 4:00 p.m. . On random basis, the market will close at any time between 4:08 and 4:10 p.m., with all matchable orders filled.

I trade Daily bars, I want to know how to place Market-on-Close and Limit-on-Close order after 4:00 p.m., say at 4:06 p.m., in order to participate into the Closing Auction Session.

Thanks,
LMC1

Here's what you can do:

1. Create your daily chart with data "Build From Minutes".
2. Set up a custom session that extends to 4:10 pm.

3. in your strategy... code this:

Code: Select all


If Time = 1606 then
BEGIN
// put your trading logic here
END;
You can experiment with using TIME or CURRENTTIME. One of them might work better for you.

Xyzzy
Posts: 162
Joined: 19 Mar 2011
Has thanked: 43 times
Been thanked: 79 times

Re: Closing Auction Session/ Hong Kong Stock Exchange / Market-on-Close and Limit-on-Close order types to IB

Postby Xyzzy » 21 Mar 2017

Will the broker accept a "sell" order placed after 4:00 (but before 4:10) as a MoC/LoC order? That would be necessary for the second solution to work. It's certainly worth trying.

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Closing Auction Session/ Hong Kong Stock Exchange / Market-on-Close and Limit-on-Close order types to IB

Postby TJ » 21 Mar 2017

Will the broker accept a "sell" order placed after 4:00 (but before 4:10) as a MoC/LoC order? That would be necessary for the second solution to work. It's certainly worth trying.
MoC/LoC order?

You have already answered your own question in your previous post.


Return to “MultiCharts”