Real Market Hours free

by lec0456 in category Other at 21/03/2013

Half the secret to being successful in the ForEx markets is timing.  I haven't seen a reliable market hours indicator posted here, so here is my verison.  Opening and closing times for the New York and London markets are based on 8 to 5 business hours.  Opening and closing times for Sydney and Japan are based on 9 to 5 business hours.  Some people use 6pm close time for Tokyo and some use a 4pm close time for Sydney.  However, did you know that ForEx trading hours are not based on corresponding stock markets close times?  They are based on investment banking business hours.  You can set the hours as you like within the indicator.  Many beginers think once you convert the business hours to local time that you will have the market hours all figured out, but its not that simple.  Did you know that Daylight savings starts on different days in London and New York.  So there is a period in March where  opening time in New York is at 12pm instead of 1pm.  Did you know Daylight savings in Austrailia is reverse that of New York so that opening times shift 2 hours instead of one between the winter and summer months, leaving a 2 hour gap between the New York close and the Sydney open?  Do you know which timezone your broker is using and how it affects the conversion?  Well all that is taken care of with my handy dandy market hours indicator! WooHoo!

The markets are color coded and I assigned the market hour value to the result so you could better visually see as markets are coming to a close and execute trades based on specific hours.  Make sure you comment out the LocalTime zone which does not apply to you.  cTrader brokers seem to be using either Cyprus time or UTC Local Time Zones.  Hope it helps!

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
using System;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
    [Levels(800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600)]
    [Indicator(IsOverlay = false, ScalePrecision = 0, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class MarketHours : Indicator
        public double TokyoOpen = 900;
        public double TokyoClose = 1700;
        //Some use a 6pm close for Tokyo.  I am using 5pm for all closings.
        public double SydneyOpen = 900;
        public double SydneyClose = 1700;
        //Some use a 4pm close for Sydney
        public double LondonOpen = 800;
        public double LondonClose = 1700;
        public double NYOpen = 800;
        public double NYClose = 1700;
        public TimeZoneInfo BrokerTimeZone;

        [Output("London", Color = Colors.Yellow, PlotType = PlotType.Points, Thickness = 3)]
        public IndicatorDataSeries London { get; set; }
        [Output("New York", Color = Colors.Blue, PlotType = PlotType.Points, Thickness = 3)]
        public IndicatorDataSeries NewYork { get; set; }
        [Output("Sydney", Color = Colors.Green, PlotType = PlotType.Points, Thickness = 3)]
        public IndicatorDataSeries Sydney { get; set; }
        [Output("Tokyo", Color = Colors.Red, PlotType = PlotType.Points, Thickness = 3)]
        public IndicatorDataSeries Tokyo { get; set; }

        protected override void Initialize()
            var attribute = (IndicatorAttribute)typeof(MarketHours).GetCustomAttributes(typeof(IndicatorAttribute), false)[0];
            BrokerTimeZone = TimeZoneInfo.FindSystemTimeZoneById(attribute.TimeZone);

        public override void Calculate(int index)
            DateTime BrokerTime = MarketSeries.OpenTime[index];

            //Used to verify local time zone settings
            Print("Broker Time Zone Name:{0} Offset:{1} DST:{2} Kind:{3}", BrokerTimeZone.DisplayName, BrokerTimeZone.BaseUtcOffset, BrokerTimeZone.SupportsDaylightSavingTime, BrokerTime.Kind);

            TimeZoneInfo TokyoTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time");
            TimeZoneInfo NYTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
            TimeZoneInfo LondonTimeZone = TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time");
            TimeZoneInfo SydneyTimeZone = TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time");

            DateTime SydneyTime = TimeZoneInfo.ConvertTime(BrokerTime, BrokerTimeZone, SydneyTimeZone);
            DateTime LondonTime = TimeZoneInfo.ConvertTime(BrokerTime, BrokerTimeZone, LondonTimeZone);
            DateTime TokyoTime = TimeZoneInfo.ConvertTime(BrokerTime, BrokerTimeZone, TokyoTimeZone);
            DateTime NYTime = TimeZoneInfo.ConvertTime(BrokerTime, BrokerTimeZone, NYTimeZone);

            double LondonValue = (LondonTime.Hour * 100) + LondonTime.Minute;
            double NYValue = (NYTime.Hour * 100) + NYTime.Minute;
            double SydneyValue = (SydneyTime.Hour * 100) + SydneyTime.Minute;
            double TokyoValue = (TokyoTime.Hour * 100) + TokyoTime.Minute;

            if (LondonValue >= LondonOpen && LondonValue < LondonClose)
                London[index] = LondonValue;

            if (NYValue >= NYOpen && NYValue < NYClose)
                NewYork[index] = NYValue;

            if (SydneyValue >= SydneyOpen && SydneyValue < SydneyClose)
                Sydney[index] = SydneyValue;

            if (TokyoValue >= TokyoOpen && TokyoValue < TokyoClose)
                Tokyo[index] = TokyoValue;

    /* Same as above except displayed on a straight line
       	if(LondonTime.Hour>=LondonOpen & LondonTime.Hour<LondonClose)London[index]=3;
       	if(NYTime.Hour>=NYOpen & NYTime.Hour<NYClose)NewYork[index]=2;
       	if(SydneyTime.Hour>=SydneyOpen & SydneyTime.Hour<SydneyClose)Sydney[index]=1;        
       	if(TokyoTime.Hour>=TokyoOpen & TokyoTime.Hour<TokyoClose)Tokyo[index]=0;

lec0456 - April 15, 2013 @ 06:09

Ok, had to update the code. Sorry. It turns out that IC markets uses UTC Time not London time(GMT Standard Time) as originally coded. You might think they are the same but London used daylight savings and UTC does not, so you would be off by an hour during the summer. I couldn't really verify that until March 30th when it kicked in for London. Also, I verified that Divisa Capitol uses UTC as well, same as IC Markets and Lqd Markets uses Cyprus Time same as FX Pro and Trader's Way. So, now the indicator should be accurate for all platforms. I also added a levels statement to display the times consistently and a print statement to verify time zone info if necessary. Hope it helps!

lec0456 - April 15, 2013 @ 06:44

I added the following lines: TimeZoneInfo LocalTimeZone = TimeZoneInfo.FindSystemTimeZoneById("UTC"); //GMT Time w/ no daylight savings For Divisa Capitol and IC Markets //Print("Local Time Zone Name:{0} Offset:{1} DST:{2} ",LocalTimeZone.DisplayName,LocalTimeZone.BaseUtcOffset,LocalTimeZone.SupportsDaylightSavingTime); [Levels(8,9,10,11,12,13,14,15,16)]

lec0456 - April 18, 2013 @ 01:54

Robo Forex and Fibo Group are also using Cyprus time. Actually, I think its best because it divides the day properly. Once New York closes on a particular day, the Australian Session begins on the following day. For example, if the NY session closes on the 15th at 4:59pm EST at 5pm EST the Australian Session begins and it is the 16th in Australia. Cyprus time is 12am. During the summer months when there is a gap between the NY and Australian Sessions, Cyprus time still falls in between, nicely dividing the trading day data. I guess that's why Cyprus is the center of the Forex Universe:)

lec0456 - September 09, 2013 @ 19:52

So, just uploaded a big update to this indicator related to all the recent platform changes in handling the Time.  So now the robot uses the timezone set by the new timezone attribute of the indicator.  Before, there would have been issues if you set the indicator timezone to something different from the broker timezone, but now they are one and the same. Good Luck! 

Arpad - March 19, 2014 @ 07:55

Thanks, this is superior, awesome!

deejbee - April 10, 2014 @ 16:58

Hi All,

This looks like a great indicator lec0456 so I've tried to use it in a bot I'm writing but can't seem to get it working.

Say I want to create a position after London has opened, I thought this would suffice:

protected override void OnTick()

    if (_realMarketHours.London.LastValue > 0) {

        Print("_realMarketHours.London.LastValue: {0}", _realMarketHours.London.LastValue);

         //create position




However running this on a backtest produces different results in the log every time.

Can I use it this way?

Many thanks


lec0456 - April 17, 2015 @ 09:15

if you are live it will give you a different value depending on when you run it.  but it works for me.just the way you mention.  As far as daylight saving, the system time functions take care of that when you convert.  so, all is good.

lec0456 - April 17, 2015 @ 09:15

if you are live it will give you a different value depending on when you run it.  but it works for me.just the way you mention.  As far as daylight saving, the system time functions take care of that when you convert.  so, all is good.

jakubdonovan - July 15, 2016 @ 13:27

Hi, is it possible to make the sessions appear as very light colour boxes on the chart rather than dots under the chart? 

anton.kovalchuk - September 20, 2020 @ 19:40

Tnak you a lot! 

mattykolej - September 26, 2022 @ 14:39

I didn't even know that, it's actually useful, thanks! Even though forex is not a source of income, I'm just an entrepreneur, but it's still important for me.

polinazinkk - September 26, 2022 @ 16:18

I'd say that nowadays, it's more beneficial for entrepreneurs to learn how to promote their business because for some reason, most of them don't put enough mind to it. But I don't understand what's the problem with checking various articles like to understand the basic and how to develop a good link building strategy, it's not hard at all.