When a new bar opens, how can I check if it's the "market reset" time regardless of time zone?
When a new bar opens, how can I check if it's the "market reset" time regardless of time zone?
22 Nov 2021, 07:31
Hi All:
Typically all the markets "reset" after the close of the New York session - Forex spreads go crazy until things settle.
How can I tell in an OnBar (or other event) if it's the first bar _after_ the close of the New York session? Regardless of time frame and time zone?
For instance, in UTC +8 time, today (Monday), the EURGBP had an OnTick event at:
22/11/2021 06:01:00.540
and then an OnBar at:
22/11/2021 06:01:00.743
Basically, the first OnBar event across all the forex pairs might not happen when the forex markets resume after the close of the NY Session any day of the week. In the above example, a "Tick" event occurred before the "Bar" event.
So how can this check be coded?
Thank you.
Replies
firemyst
22 Nov 2021, 09:22
RE:
amusleh said:
Hi,
If you know what time zone your indicator/cBot is running on and on which time the New York session ends then you can check if the OnBar/OnTick event is triggered during that time.
To change the time zone of DateTime you can use .NET TimeZoneInfo: Converting times between time zones | Microsoft Docs
Thank you for your reply.
Because after the New York session close, the next OnTick/OnBar events for each forex pair happens at different times. So I can't just say, "check at x o'clock.
For example, if I was in New York, in an OnBar event within a bot, I'd have to check if it is occurring between 5:00pm - 5:05pm. And if I'm on a time frame that's less than 5 minutes, I'd have to have a flag to indicate that I've already checked for the first bar after the close of the session.
Is that how you would do it? Or do you have any other ideas?
Thanks again.
@firemyst
amusleh
23 Nov 2021, 09:57
RE: RE:
firemyst said:
amusleh said:
Hi,
If you know what time zone your indicator/cBot is running on and on which time the New York session ends then you can check if the OnBar/OnTick event is triggered during that time.
To change the time zone of DateTime you can use .NET TimeZoneInfo: Converting times between time zones | Microsoft Docs
Thank you for your reply.
Because after the New York session close, the next OnTick/OnBar events for each forex pair happens at different times. So I can't just say, "check at x o'clock.
For example, if I was in New York, in an OnBar event within a bot, I'd have to check if it is occurring between 5:00pm - 5:05pm. And if I'm on a time frame that's less than 5 minutes, I'd have to have a flag to indicate that I've already checked for the first bar after the close of the session.
Is that how you would do it? Or do you have any other ideas?
Thanks again.
Hi,
Yes, that's I think the only way you can do it.
Just check if the OnBar/OnTick is triggered on your specified time period by using the Server.Time.
@amusleh
amusleh
22 Nov 2021, 08:53
Hi,
If you know what time zone your indicator/cBot is running on and on which time the New York session ends then you can check if the OnBar/OnTick event is triggered during that time.
To change the time zone of DateTime you can use .NET TimeZoneInfo: Converting times between time zones | Microsoft Docs
@amusleh