Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
restrict trading to specific times of day
Collapse
X
-
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?Tags: None
-
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:- Using a time filter to limit trading hours - https://ninjatrader.com/support/help...to_limit_t.htm
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.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 }
Please let us know if we may be of further assistance.
- Likes 1
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
46 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
126 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
66 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
42 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment