Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

restrict trading to specific times of day

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    restrict trading to specific times of day

    i am new to NT and i want to restrict my code to only trade at certain times. my instance of NT8 runs on the east coast an is therefore local EST. is the timeseries (Time[0]) returning time based of CST at the exchange or is it being converted to my time zone? so for example, i only want to exclude trading between 8:30am - 8:35am CST and 3:30pm - 4:00pm but i dont know if the values being returned are in EST or CST which is defined in the trading hours template for CME Index Futures RTH. any help is appreciated, thanks! also, can i achieve this by leveraging trading hours templates?

    #2
    Hello im_an_algo_trader,

    Thank you for your post and welcome to the NinjaTrader forum community!

    Time[0] will return the timestamp of the bar which will follow the time zone set up in your platform settings at Control Center > Tools > Options > Time Zone.

    You could follow the example demonstrated in the reference sample here:The sample uses the ToTime() method to get an integer value representing the time from the Time series and compares that to a desired start time and end time. If you want to exclude trading from 8:30am-8:35am CST and 3:30pm-4:00pm CST for example, you would convert that to EST for your time zone settings in the platform and set a filter that checks the following:

    Code:
    // only place trades if it is before 8:30am CST/9:30am EST OR after 8:35am CST/9:35am EST AND before 3:30pm CST/4:30pm EST OR after 4pm CST/5pmEST
    if (ToTime(Time[0]) < 83000 || (ToTime(Time[0]) > 93500 && ToTime(Time[0]) < 163000) || ToTime(Time[0]) > 170000)
    {
    // logic here
    }
    You could achieve time restrictions with Trading Hours templates, as the strategy will only place trades during trading session hours for the template selected in the data series settings. That said, some developers like to set up the Start Time and End Time as input parameters for the strategy so they can be easily modified as well as able to backtest different results easily. Then, the logic will have order logic based on the selected Start Time and End Time. This would potentially be more complex to change if you were using Trading Hours templates and changing the template used.

    Please let us know if we may be of further assistance.

    Comment


      #3
      Good reading here.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      46 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      126 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      66 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      42 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      46 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X