Signal - generate orders during Regular Trading Hours

Questions about MultiCharts .NET and user contributed studies.
jarym
Posts: 58
Joined: 16 Feb 2015
Has thanked: 14 times
Been thanked: 6 times

Signal - generate orders during Regular Trading Hours

Postby jarym » 28 Mar 2015

Hi,

I am using MC.NET and would like some information on what the easiest way is to determine if the current bar occurs 10 minutes after the regular session start and 30 minutes before the end of the regular session.

The reason is, if the signal is generated outside of regular hours I wish my strategy to generate an order for fewer contracts and have a larger stop.
int tradingDay = Math.Max( 0, (int)Bars.TimeValue.DayOfWeek - 1);
TimeSpan morning = new TimeSpan(11,0,0);
SessionObject session = Bars.Sessions[tradingDay];
TimeSpan enterTradesAfter = session.StartTime.Add(new TimeSpan(0,10,0));
TimeSpan enterTradesBefore = session.EndTime.Subtract(new TimeSpan(0,30,0));
//Bars.Request.SessionName
if ( Bars.TimeValue.DayOfWeek != DayOfWeek.Sunday // No trade in Sunday overnight session
&& session.StartTime.CompareTo(morning) < 0 // Start time must be before 11am
&& Bars.TimeValue.TimeOfDay.CompareTo(enterTradesAfter) > 0
&& enterTradesBefore.CompareTo(Bars.TimeValue.TimeOfDay) > 0
) {
// We're in regular trading hours?
}
However, I've noticed that the historic start/end times are a bit unusual (maybe its a data issue?). For example, for a continuous ES contract created as a Custom Futures symbol from a CQG datafeed, I see that for some reason Friday 22 March 2013 has a session start time of 15:30 and end-time of 08:00 yet the bar times are well after the end-time.

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

Re: Signal - generate orders during Regular Trading Hours

Postby Henry MultiСharts » 31 Mar 2015

Hello jarym,

I'm not sure I am following. Are you using a custom session template? Is Friday 22 March 2013 the only case when the data is unusual? Please attach full sized screenshot demonstrating the issue you have.


Return to “MultiCharts .NET”