Avoid Placing orders out of my trading session

Questions about MultiCharts and user contributed studies.
Sallymeow
Posts: 10
Joined: 28 Nov 2018
Has thanked: 2 times

Avoid Placing orders out of my trading session

Postby Sallymeow » 01 Aug 2020

Hi,

I trade MHI. This instrument has T session and T+1 Session. T session: 0915~1630, T+1 session: 1715~0300. I trade the T session only so I set custom session in QM. The bar display is OK. The bar stop plotting after 1630. However, when I keep the auto-trading turn on, orders were still placed at the T+1 session. My sellshort signal were triggered and sent at around 2130 and it was filled!!! However, on the chart, no such signal is shown, it still showing that I am having a long position!!! I checked the log and confirmed that it was not an order sent during the T session and left. The order is sent out of my trading session.

Any suggestions to avoid this. Do I have to turn off auto-trading after 1630 so I can do something else?

User avatar
Vlada MultiCharts
Posts: 293
Joined: 22 Apr 2020
Has thanked: 8 times
Been thanked: 76 times

Re: Avoid Placing orders out of my trading session

Postby Vlada MultiCharts » 11 Aug 2020

Hello,

You can reduce session time in your session template settings (QuoteManager -> Tools -> Session Template) so that the session ended earlier than real session in 1-2 bars of the basic resolution. Session settings are used to regulate the data series (chart).

Unfortunately, at the moment there is no parameter that can control sessions in the auto trading engine directly.

Sallymeow
Posts: 10
Joined: 28 Nov 2018
Has thanked: 2 times

Re: Avoid Placing orders out of my trading session

Postby Sallymeow » 11 Aug 2020

Hello Vlada,

I wonder whether the method you mentioned work. If I use say 10 min bar and code like buy next bar at highest(high,36) stop, even my session is ended, the market data is still coming, it is still possible that the target price is hit and the order is triggered.

I think controlling sessions will be an important improvement in Multicharts.

Sally

User avatar
Vlada MultiCharts
Posts: 293
Joined: 22 Apr 2020
Has thanked: 8 times
Been thanked: 76 times

Re: Avoid Placing orders out of my trading session

Postby Vlada MultiCharts » 25 Aug 2020

Hello Sallymeow,

Could you please give more details on what you mean by "session ended, the market data is still coming"? There are several situations possible (session at the broker ended/ session ended according to MultiCharts session settings).

1) The session at the broker has ended but the data is still coming. In this case, the order can be generated, although it will be probably rejected by the broker.

2) MultiCharts session has ended, but the broker's session is active. The chart is not updating. In this situation, the order will not be generated.

For the order to be generated, a new tick opening a new bar should be received on the chart.
If the data is not updating, the script will not be calculated and accordingly, the order will not be generated on the next bar.

Sallymeow
Posts: 10
Joined: 28 Nov 2018
Has thanked: 2 times

Re: Avoid Placing orders out of my trading session

Postby Sallymeow » 26 Aug 2020

My case is situation 2) MultiCharts session has ended, but the broker's session is active. The chart is not updating.

However, the order was still generated.

I set my session (T session) in QM and the chart is not updating after the T session is ended. At the time of T+1 session, I can see that the market data is still coming. On the top of the chart, the bid, ask and last price keep updating even the bar is not updating and no new bar appear.

"For the order to be generated, a new tick opening a new bar should be received on the chart."
This is my original thought and it gave me a shock when I received an email notice that my order was filled at night.
Attachments
Market data is still coming.png
Market data can be received after custom session ended
(206.69 KiB) Not downloaded yet

Gaempi
Posts: 60
Joined: 27 Jul 2010
Location: Switzerland
Has thanked: 3 times
Been thanked: 8 times

Re: Avoid Placing orders out of my trading session

Postby Gaempi » 09 Sep 2020

Hello

1. You have the trading session to set in the session template. So you see on your chart only the bars of this session.
2. If you have an automated trading system, the trades (you see) are made in the trading session on the chart.
3. You can limit the trading signals (new long or new short position) by the TIME limits: trade if time < 1700. A trading signal is sent ot the broker only, if time is lower than 1700 (5 p.m.)
4. BUT despite this settings you get filled orders from your broker. WHY?

The BIG PROBLEM is and MC should solve this problem: If you send a limit or stop order to the broker during the trading session, the not filled orders are pending at the broker after the trading session (set by you). The most markets have after session trading (or pre session trading). If an order is pending at the broker and filled in the after market trading, you get a not wanted order after your trading session.

The SOLUTION is: Multicharts should give us trader a command in Easy Language to cancel all pending orders at the broker after a specific time.

PLEASE: Give us this command to kill all open orders (or orders from a specific trading system or orders in a specific market instrument) after the official trading session.

Thanks!

dvdkite
Posts: 65
Joined: 16 May 2018
Has thanked: 10 times
Been thanked: 1 time

Re: Avoid Placing orders out of my trading session

Postby dvdkite » 09 Sep 2020

Hello,

why don't you simply use a time based condition where you're actually triggering the order?
I have a boolean condition that I put in the code that generate the order like this:

Code: Select all

//Time frame of the day where entries are allowed isTheRightTime = ( time >= Time_MorningStart_at and time <= Time_MorningStop_at) or ( time >= Time_AfternoonStart_at and time <= Time_AfternoonStop_at); // then with if isTheRightTime then begin.... // ---put here your buy sell code
With my strategies it works perfectly....

Gaempi
Posts: 60
Joined: 27 Jul 2010
Location: Switzerland
Has thanked: 3 times
Been thanked: 8 times

Re: Avoid Placing orders out of my trading session

Postby Gaempi » 10 Sep 2020

To dvdkite:

Time based condition do not work, if you send orders (limit, stop) in the normal session time to broker, you have an after session market and there are pending orders (limit, stop orders) at the broker. Then you get orders you not want.

Sallymeow
Posts: 10
Joined: 28 Nov 2018
Has thanked: 2 times

Re: Avoid Placing orders out of my trading session

Postby Sallymeow » 10 Sep 2020

It seems that I have a misunderstanding that stop orders are pending at Multicharts and will be sent to broker upon price trigger. I found that MC send out all the stop orders to the brokers even though the stop price is very far away.

One of the suggestion: Multicharts should give us options to select: 1) stop orders to be pended in Multicharts and sent upon price get close to the stop price within the custom trading session or 2) all stop orders sent to broker

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Avoid Placing orders out of my trading session

Postby ABC » 10 Sep 2020

Sallymeow,

take a look at the "Price Order Emulation" feature as it might do what you have in mind:

https://www.multicharts.com/trading-sof ... _Emulation

Regards,

ABC
It seems that I have a misunderstanding that stop orders are pending at Multicharts and will be sent to broker upon price trigger. I found that MC send out all the stop orders to the brokers even though the stop price is very far away.

One of the suggestion: Multicharts should give us options to select: 1) stop orders to be pended in Multicharts and sent upon price get close to the stop price within the custom trading session or 2) all stop orders sent to broker

dvdkite
Posts: 65
Joined: 16 May 2018
Has thanked: 10 times
Been thanked: 1 time

Re: Avoid Placing orders out of my trading session

Postby dvdkite » 10 Sep 2020

To dvdkite:

Time based condition do not work, if you send orders (limit, stop) in the normal session time to broker, you have an after session market and there are pending orders (limit, stop orders) at the broker. Then you get orders you not want.
Ok but the order stay alive till the conditions that generates it are met... if one of the conditions ( in this case the time related condition ) became False then the order will automatically be deleted from MC.

Gaempi
Posts: 60
Joined: 27 Jul 2010
Location: Switzerland
Has thanked: 3 times
Been thanked: 8 times

Re: Avoid Placing orders out of my trading session

Postby Gaempi » 11 Sep 2020

To dvdkite and Multicharts:

1. if condition1 and time < 1600 then sell 1 contract at 12538 stop.

--> This order ist sent to the broker during the session before 1600.
--> The condition1 is true and the stop is not filled to the end of the session (1600). So the order is activ (pending) at the broker at 1600 AND after 1600 (4 p.m.)

2. After 1600 MC can't test the condition1 is true or false, but the stop is still active at the broker. MC can't test the condition1 after 1600, because
---> the bar chart ends at 1600 (if set in the session template) and
---> MC so can't calculate the condition1 after 1600 and
---> you have MC give the command only to test condition1 till 1600 ("time related condition").
By the way MC has no new inputs from the chart and from chart based calculation (indicators, ...) to test condition1. After 1600 MC is doing nothing.

3. For example the stop is filled in the after session market WITHOUT testing condition1:
---> If the condition1 is still true, the filled stop is ok.
---> But if the condition1 is false and the stop is filled at the broker, YOU DO NOT WANT THIS STOP after 1600.

4. What MC is NOT doing: After 1600 MC don't send a massage to the broker to kill the pending order.

5. What MC should do and what we traders should have in Easy Language: After 1600 (at the end of the official session and the beginning of the after session market ) MC should send an order to the broker to kill the stop order at 12538. MC should give us a command in Easy Language to kill the specific stop order after 1600.

What you have to to: You have to go every day after 1600 to the broker and have to kill all open pending orders MANUALLY to avoid not wanted and untested orders in the after session market. If you have 15 trading systems, you can have up to 30 pending orders (or more) in the after market session. Yo have all to stop them manually, but this should go AUTOMATICALLY by a command sent by Multicharts.

To dvdkite: You have no problems like this only if you have no after market session. So no pending oders can be filled. And all pending orders at the broker are stopped at the end of day (day orders). And at the open of the next session condition1 is tested new.

Thanks!

My broker is IB.

biffhero
Posts: 47
Joined: 22 Sep 2020
Has thanked: 29 times
Been thanked: 7 times

Re: Avoid Placing orders out of my trading session

Postby biffhero » 22 Sep 2020

I totally agree with you that this is an issue.

I have two solutions that I use right now, to partial success. I will explain them both and then also what I intend to do to get closer to what I need.

1. There is a signal called "Close at End of Day". The code looks like this :

Code: Select all

[IntrabarOrderGeneration = false] SetExitOnClose ;
2. I found a tutorial online that talked about using filters in the code to prevent things from happening. Here is how I am testing that.

Code: Select all

Inputs: timeMorningStart( 930 ), timeMorningStop( 1200 ), timeAfternoonStart( 1200 ), timeAfternoonStop( 1545 ), Variables: LongFilter1( TRUE ), LongFilter2( TRUE ), LongFilter3( TRUE ), timeMorning ( FALSE ), timeAfternoon ( FALSE ), timeAllDay ( FALSE ), timeFilter1 ( FALSE ), // We need the final comparison so that the optimizer doesn't get crazy. timeMorning = ( ( time >= timeMorningStart ) and ( time <= timeMorningStop ) and ( timeMorningStart < timeMorningStop ) ); // We need the final comparison so that the optimizer doesn't get crazy. timeAfternoon = ( ( time >= timeAfternoonStart ) and ( time <= timeAfternoonStop ) and ( timeAfternoonStart < timeAfternoonStop ) ); timeAllDay = ( timeMorning or timeAfternoon ); timeFilter1 = ( timeAllDay ); // Channel Breakout LE if LongFilter1 and LongFilter2 and LongFilter3 and timeFilter1 then Buy ( "ChBrkLE" ) next bar at HighestFC( chanBreakoutPrice, chanBreakoutLELength ) + 1 point stop ;
I thought that was all that I needed, and I was close, but ... here's the problem.

I have my sessions set for all stocks to be "US Stocks with Pre & Post Market". So the "close at end" signal closes at 8pm. Heh.

I intend to code up something like this. Warning, this is pseudocode from my head, not from the editor.

Code: Select all

variable : cleanUpTime( 1550 ); if ( ( time >= ( cleanUpTime - 1 ) ) and ( openPositions > 0 ) ) then closeAllOpenPositions() end
That's today's task, figure out how to close anything that is open when we get to the cutoff time.


Return to “MultiCharts”