I have a problem with overnight positions. Actually I created constrain for that problem like "to time > 3pm & to time < 10pm". But I still got overnight positions.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Overnight
Collapse
X
-
Hi,
our problem is, that we want to close our positions in a stock future before the stock market is actually closing. For example, we want to close all our positions in a YM-Future, before the NYSE is closing - 4p.m.
Therefore we added the following condition to our strategies:
Since we are UTC/GMT+1 (Berlin, Central European Time), this should be 3:45 p.m. EST. So, this condition should be true when it is 3:45 p.m. EST or later and therefore prevent overnight positions, but it doesn't. Why?Code:if (ToTime(Time[0]) >= ToTime(21, 45, 0)) { ExitLong("", ""); ExitShort("", ""); }
Or ist there another automated way, to flatten all positions at a specific time?
Comment
-
Hi GerTrader,
You could use ExitOnClose and set the ExitOnCloseSeconds to match your desired exit time -> http://www.ninjatrader-support.com/H...itOnClose.html
NinjaTrader will use your set local time zone, maybe you want to check into this to make sure your code gets executed properly.
Comment
-
Yes, we know that NinjaTrader uses local time and therefore we used 21:45 for example, when we want the strategy to close all positions 3:45 p.m. EST.
But when we use for example the S&P 500 Future ES, Close is 3:15 p.m. CST (http://www.cme.com/clearing/clr/spec...tml?product=ES) respectively 4:15 p.m. EST. This means when we want to close our positions at 3:45 p.m. EST, we should set ExitOnClose = true; and ExitOnCloseSeconds = 1800; !?
But i'm wondering, why the condition set we used is not working !? Also, it does work while backtesting.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
95 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
50 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
31 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
36 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
72 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment