Re: Define Your Trading Session Windows in Advance
Posted: Thu Sep 03, 2026 3:35 pm
Key Differences from MQL:
Native Time Math: C#'s TimeSpan naturally understands hours, minutes, and seconds. A simple >= operator evaluates the entire time structure instantly without needing custom minute-conversion logic.
Initialization Parsing: We take a clean string input from the user ("08:00") and parse it once inside OnStart(). On every tick, the EA only compares pre-compiled objects, keeping latency near zero.
Time Zone Pinning: Notice the [Robot(TimeZone = TimeZones.UTC)] header? That guarantees your Server.Time reference remains constant. Backtesting in cTrader defaults to UTC, so locking your bot to UTC ensures your historical tests align perfectly with forward execution.
Native Time Math: C#'s TimeSpan naturally understands hours, minutes, and seconds. A simple >= operator evaluates the entire time structure instantly without needing custom minute-conversion logic.
Initialization Parsing: We take a clean string input from the user ("08:00") and parse it once inside OnStart(). On every tick, the EA only compares pre-compiled objects, keeping latency near zero.
Time Zone Pinning: Notice the [Robot(TimeZone = TimeZones.UTC)] header? That guarantees your Server.Time reference remains constant. Backtesting in cTrader defaults to UTC, so locking your bot to UTC ensures your historical tests align perfectly with forward execution.