- Home
- Forum
- cTrader Automate
- Is there a way to have bots use cTrader's current "user time" programmatically without parameters?
Is there a way to have bots use cTrader's current "user time" programmatically without parameters?
Is there a way to have bots use cTrader's current "user time" programmatically without parameters?
Hi everyone:
Is there a way in bots and indicators to use cTrader's specified timezone that's set at the bottom of the application?
I have code based on specific times that people around the world use.
I don't want to have to keep setting the TimeZone directive in bots. Eg:
[Robot(TimeZone = TimeZones.xxx
and I don't want to have to implement a TimeZone or UTC offset parameter, and was hoping for something easy like:
Time.UserTime
that would return what the user has the chart set to:
Any ideas?
Thank you.
RE:
PanagiotisChar said:
Hi firemyst,
Unfortunately this info is not available through the API.
Thank you for the confirmation @PanagiotisChar . That's a bummer, but oh well... at least I didn't overlook something that's stupidly simple :-)
I don't believe you can set the default for the indicator, but you can access the users current offset:
protected override void Initialize()
{
TimeSpan t = this.Application.UserTimeOffset;
Print("User time offset = " + t.TotalHours);
this.Application.UserTimeOffsetChanged += Application_UserTimeOffsetChanged;
}
private void Application_UserTimeOffsetChanged(UserTimeOffsetChangedEventArgs obj)
{
TimeSpan t = this.Application.UserTimeOffset;
Print("User time offset changed = " + t.TotalHours);
}
From there, it's easy to just combine the utc time with the offset for user time.
RE:
pick said:
I don't believe you can set the default for the indicator, but you can access the users current offset:
protected override void Initialize() { TimeSpan t = this.Application.UserTimeOffset; Print("User time offset = " + t.TotalHours); this.Application.UserTimeOffsetChanged += Application_UserTimeOffsetChanged; } private void Application_UserTimeOffsetChanged(UserTimeOffsetChangedEventArgs obj) { TimeSpan t = this.Application.UserTimeOffset; Print("User time offset changed = " + t.TotalHours); }
From there, it's easy to just combine the utc time with the offset for user time.
Thank you for this. Appreciate your time! I'll give it a try. :-)