Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
The "Exit on close" time
Collapse
X
-
The "Exit on close" time
In NT, Is there a setting for "Exit on close" for each commodity. I was experiementing with backtesting and the times set happened to be 12 to 12. And i saw that the "exit on close" trades were being placed at 12, instead of the market closing time. Do you set the closing time for each commodity in NT? How?Tags: None
-
Hi ju1234,
This cannot be set individually for each symbol.
Please look into this link http://www.ninjatrader-support.com/H...itOnClose.html
and use the 'ExitOnClose = True' command in your Initialize section, this will allow to use the session endling times then to flatten your positions.
Please also review this link here - http://www.ninjatrader-support2.com/...ead.php?t=3226BertrandNinjaTrader Customer Service
Comment
-
Hi ju1234,
Have you reviewed my second link? It details how TimeFilters can be used to limit trading hours of a strategy - http://www.ninjatrader-support2.com/...ead.php?t=3226
You could add this snippet to your strategy to close out positions at 15:59 for example -
Code:[FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][SIZE=2][SIZE=2] ((ToTime(Time[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]]) >= [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]155900[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2])) { ExitLong(); ExitShort(); } [/SIZE][/SIZE]
You can also use one chart for your strategy and use another for your charting (this would then include 24hr data if you like)
BertrandNinjaTrader Customer Service
Comment
-
Hi guys,
Seemingly I am not the only one with ExitOnClose-related problems. My problem;
I want to close all open positions 60 seconds before the end of trading. I have the following settings:
ExitOnClose = true;
ExitOnCloseSeconds = 60;
I am paper trading 6E (Sim account). My computer is in the Finnish time (= CST + 8 hours) so when trading stops at 16 CST on Globex, it's midnight in Finland.
Everything seems to work fine when backtesting ('Exit on closes' plotted on charts), but when I run my strategies with real-time data, open positions remain open after midnight. What's the problem and what's the recommended way of fixing it? Can I use 'ExitOnClose' (how?) or should I resort to 'ToTime(Time[0]) >= 235900'? Cheers...
Comment
-
Hi jp_kettunen, first please try to sync your PC clock up with the 'Internet Time' function in Windows.
Next, please add TraceOrders = true to your strategy and see if the order is being generated properly.
You can also use the code I posted below to exit at your desired time setting.BertrandNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Bertrand View PostHi ju1234,
Have you reviewed my second link? It details how TimeFilters can be used to limit trading hours of a strategy - http://www.ninjatrader-support2.com/...ead.php?t=3226
You could add this snippet to your strategy to close out positions at 15:59 for example -
Code:[FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][SIZE=2][SIZE=2] ((ToTime(Time[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]]) >= [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]155900[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2])) { ExitLong(); ExitShort(); } [/SIZE][/SIZE]
You can also use one chart for your strategy and use another for your charting (this would then include 24hr data if you like)
Comment
-
Thanks,
My PC clock is in time - cannot figure out how sync with Internet time could help. But that 'ToTime' thing appears to work as expected, so I'll use it.
Comment
-
Exit On Close problem.
In my strategy I have session start time 0:02 and end 0:00
I am using multi time frame strategy. And its closes my session 8:02pm.
I don't have any ExitonCLose settings.
I want to close end of session. But it closes ealier.
Thanks
I also tried to use your example. ExitOnClose=false;
and then add manual exit, still its exits 8:02 pm.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by claxxical, 05-30-2017, 12:30 PM
|
37 responses
4,452 views
0 likes
|
Last Post
by Padan
Today, 02:23 AM
|
||
Started by SugarDefwebsite, Today, 02:18 AM
|
0 responses
3 views
0 likes
|
Last Post Today, 02:18 AM | ||
Started by usglucofreeze, Today, 01:19 AM
|
0 responses
7 views
0 likes
|
Last Post Today, 01:19 AM | ||
Started by f.saeidi, Today, 01:12 AM
|
0 responses
10 views
0 likes
|
Last Post
by f.saeidi
Today, 01:12 AM
|
||
Started by NinjaTrader_ChelseaB, 03-14-2017, 10:17 AM
|
227 responses
34,319 views
7 likes
|
Last Post
by rare312
Today, 12:51 AM
|
Comment