I was wondering if its possible to optimize entry and close times (clock time) on NT8. When I used the drop down menu to optimize I usually get the same results as selecting True.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Optimization for Time
Collapse
X
-
Its actually something I made myself with the help of a programmer. I'm setting the time schedule which allows signals in a 24hrs market to run. For example if I limit the strategy for US open 9:30AM and end time to 4:00PM with a close of all open positions by 4:30PM EST. I was wondering if time can be optimized as to when the strategy should ideally run.
Comment
-
Hello ashmanz80,
Thanks for your note.
One thing you could do to optimize time in the Strategy Analyzer, without modifying your code, is set 'Optimize Data Series' to 'true'. This will effectively offer to run through a range of timeframes, and the period would offer you to set the ranges to run through. Then you could apply a session template to limit your trading hours.
If you wanted to actually modify your code to optimize a particular time of day, what you would need to do is use a switch statement or a bunch of if statements and have a parameter for time that would optimize as a range of integers. For example, if you divide the day up into 6 parts and assign an integer to each of those parts you would be able to discern which of those 6 segments provided the best results. Something similar to the following snippet would accomplish this.
Code:if( TimeFrame == 1 ) { [COLOR="SeaGreen"]// 12:00 AM and 4:00 AM time frame[/COLOR] if( ToTime(Time[0]) >= 000000 && ToTime(Time[0]) <= 040000) { [COLOR="SeaGreen"]//your strategy logic here[/COLOR] } } if( TimeFrame== 2 ) { [COLOR="seagreen"]// 4:00 AM and 8:00 AM time frame[/COLOR] if( ToTime(Time[0]) >= 040000 && ToTime(Time[0]) <= 080000 ) { [COLOR="seagreen"]//your strategy logic here[/COLOR] } }
The above code would be for just two segments of the day so you would need to create a condition for the other 4 segments, assuming your day was broken into 6 segments.
I am including a link to our help guide documentation for ToTime(), for your convenience. I am also including a link to a forum post you should find helpful that discusses how to limit trading hours with a time filter.
ToTime()
https://ninjatrader.com/support/help...us/?totime.htm
Using a time filter to limit trading hours
https://ninjatrader.com/support/foru...ead.php?t=3226
Please let me know if you have any further questions.Josh G.NinjaTrader Customer Service
Comment
-
Hi,
The sample strategy doesn't work if I try to set a time envelope that crosses 000000, for instance I want one of the time envelopes to be from 11pm and 3am. Please advise?
thanks,
David
Comment
-
Hello David,
Thanks for your notes.
The idea to optimize time is to use int inputs (public integer variables using the NinjaScriptProperty attribute) and use ToTime(Time[0]) to check the bar is between the optimized hour and minute values.
See the example scripts shared by my colleague Chelsea on the forum threads linked below.
Hi guys, how can I optimize a time period? I know how to optimize Stop and Take Profit sizes in the Strategy Analyzer Optimization (Variables), but I want to have the time period (it doesn't matter which Data Series or symbol I use) which is the most profitable with entry time and exit time. Example: I want to make an entry
https://forum.ninjatrader.com/forum/ninjatrader-8/platform-technical-support-aa/1067014-optimizing-on-time?p=1160389#post1160389Brandon H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by samish18, 04-17-2024, 08:57 AM
|
16 responses
55 views
0 likes
|
Last Post
by samish18
Today, 03:30 PM
|
||
Started by arvidvanstaey, Today, 02:19 PM
|
3 responses
9 views
0 likes
|
Last Post Today, 03:23 PM | ||
Started by jordanq2, Today, 03:10 PM
|
2 responses
8 views
0 likes
|
Last Post
by jordanq2
Today, 03:23 PM
|
||
Started by traderqz, Today, 12:06 AM
|
10 responses
18 views
0 likes
|
Last Post
by traderqz
Today, 02:49 PM
|
||
Started by algospoke, 04-17-2024, 06:40 PM
|
5 responses
47 views
0 likes
|
Last Post Today, 02:36 PM |
Comment