Best way to not open position after trading hours

Created at 06 Aug 2020, 11:02
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
AC

ac15x

Joined 22.07.2020

Best way to not open position after trading hours
06 Aug 2020, 11:02


 

  private bool IsTradingHours()
        {
            if (Server.Time.DayOfWeek == DayOfWeek.Friday && Server.TimeInUtc.TimeOfDay > new TimeSpan(20, 0, 0))
            {
                return false;
            }
            return true;
        }

Hi, 

I don't want my robot to trade near closing hours every friday both in live and backtesting. Is the code above the best way to deal with it where after 8PM Friday, no trade will be executed?

I find that when I'm back testing time is UTC +3. I trade with IC Markets.

Thanks,


@ac15x
Replies

PanagiotisCharalampous
06 Aug 2020, 11:06

Hi ac15x,

Seems fine to me. Did you run into any issues? 

The cBot timezone is defined in the Robot attribute

 [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous