Print the Robot TimeZone
25 Aug 2013, 23:45
How can I use a print statement to printout the TimeZone setting being used by the robot?
Replies
cAlgo_Development
02 Sep 2013, 12:52
You can use FindSystemTimeZoneById() method:
[Robot(TimeZone = TimeZones.CentralAmericaStandardTime)]
public class TimeZonesRobot : Robot
{
protected override void OnStart()
{
TimeZoneInfo myTimeZone = TimeZoneInfo.FindSystemTimeZoneById(TimeZones.CentralAmericaStandardTime);
Print("Time Zone: {0}, UTC Offset: {1}", myTimeZone.Id, myTimeZone.BaseUtcOffset);
}
}
If you want to grab timezone id directly from the attribute, you can use code from my previous post.
@cAlgo_Development

cAlgo_Development
26 Aug 2013, 16:42
You can read timezone directly from the attribute:
using System; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Requests; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.EasternStandardTime)] public class MyBot : Robot { protected override void OnStart() { var attribute = (RobotAttribute)typeof(MyBot).GetCustomAttributes(typeof(RobotAttribute), false)[0]; Print("My timezone: {0}", attribute.TimeZone); } } }But this will not work if you want to do it from a nested indicator.
@cAlgo_Development