Market Half Days?

Questions about MultiCharts and user contributed studies.
JohnR
Posts: 26
Joined: 05 Sep 2012
Has thanked: 2 times
Been thanked: 2 times

Market Half Days?

Postby JohnR » 06 Nov 2012

Does anyone know if / where the code is to test for market half days? I thought I had seen such a thing floating around on these forums, but I can't find it now.

I'm looking for an easy way to determine when the market closes each day? (Or just when those half days occur)

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

Re: Market Half Days?

Postby TJ » 06 Nov 2012

Does anyone know if / where the code is to test for market half days? I thought I had seen such a thing floating around on these forums, but I can't find it now.

I'm looking for an easy way to determine when the market closes each day? (Or just when those half days occur)
You can use codes to do a lot of bar-by-bar analysis,
but bear in mind that anything you "detected" from the price bars, is in hindsight.


e.g. on a 5 min chart,
if a bar's time is at 9:35, you know a new day has begun.
If the previous bar time is 1330, you know you had a "short" day.

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Market Half Days?

Postby SP » 08 Nov 2012

There is a TS function to detect early closings for the US markets.
EarlyClose( Date ) then returns true.

Code: Select all

// Identify Market Scheduled Early Closing Days ( EarlyClose )
// ©JRG, 1 Jul 2005 -- Version 1g ©2003, 2004, 2005
// **************************************************************

{FUNCTION: Determines if the designated day is an early closing day
and provides a true/false flag.

v1a - move calling situation out of function and into
indicator/strategy.
v1b - make more universal by putting Eval_Date as an input.
v1c - early close on 26 Dec only if a Friday.
v1d - revise 4 Jul closings
v1e - revise day after Thanksgiving logic
v1f - avoid futures trade on Thanksgiving Day.
v1g - revise 4 Jul close on Friday before Monday 4th.}

// *************************************************************

INPUTS: Eval_Date ( numericsimple ) ;

VARIABLES: Month# ( 0 ),
Day# ( 0 ),
Weekday# ( 0 ),
Early_Close ( False ) ;

// ***** Find Early Closing Days *****
Early_CLose = False ; // always set early closing flag to false
Month# = Month( Eval_Date ) ;
Day# = DayofMonth( Eval_Date ) ;
Weekday# = DayofWeek( Eval_Date ) ;

if ( Month# = 7 and
Day# < 4 ) or // find Jul 4
( Month# = 11 and
( Day# >= 23 and
Day# <= 29 ) ) or // find Thanksgiving
( Month# = 12 and
( Day# >= 22 or
Day# <= 26 ) ) then // find Christmas
begin
if Month# = 7 and // find last trading day before 4 Jul
Day# = 3 or // any 3 Jul trading day
// ( Day# = 1 and
// Weekday# = 5 ) or // any Friday before 4 Jul on Monday
// ( Day# = 2 and
// Weekday# = 4 ) or // any Thursday before 4 Jul on Saturday
( Day# = 5 and
Weekday# = 5 ) then // any Friday after 4 Jul on Thursday
Early_Close = True ; // set early closing flag

if Month# = 11 and
Weekday# = 5 and // find Friday after Thanksgiving
Day# >= 23 and // Friday after 4th Thursday in Nov
Day# < 30 then
Early_Close = True ; // set early closing flag

if Month# = 11 and
Weekday# = 4 and // avoid Thanksgiving futures trade
Day# >21 and
Day# < 29 then
Early_Close = True ;

if Month# = 12 and // find trading day before/after Christmas
Day# = 24 or // any 24
{( Day# = 22 and
Weekday# = 5 ) or} // any Fri before Christmas on Mon
( Day# = 23 and
Weekday# = 4 ) or // any Thur before Christmas on Sat
( Day# = 26 and
Weekday# = 5 )then // day after Christmas only if a Friday
Early_Close = True ; // set early closing flag
end ; // end early closing module

EarlyClose = Early_Close ;




JohnR
Posts: 26
Joined: 05 Sep 2012
Has thanked: 2 times
Been thanked: 2 times

Re: Market Half Days?

Postby JohnR » 08 Nov 2012

Thanks, that function looks good! I'll give it a try.


Return to “MultiCharts”