Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optimization for Time

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

    Optimization for Time

    Hi,

    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.
    Attached Files
    Last edited by ashmanz80; 02-07-2018, 09:18 AM.

    #2
    Hello ashmanz80,
    Thanks for your post.

    Is this a strategy that you made yourself, or did you download this from somewhere?

    What drop down menu or option are you setting to "True"?
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      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


        #4
        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


          #5
          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


            #6
            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#post1160389
            Brandon H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Christopher_R, Today, 12:29 AM
            0 responses
            6 views
            0 likes
            Last Post Christopher_R  
            Started by sidlercom80, 10-28-2023, 08:49 AM
            166 responses
            2,235 views
            0 likes
            Last Post sidlercom80  
            Started by thread, Yesterday, 11:58 PM
            0 responses
            3 views
            0 likes
            Last Post thread
            by thread
             
            Started by jclose, Yesterday, 09:37 PM
            0 responses
            7 views
            0 likes
            Last Post jclose
            by jclose
             
            Started by WeyldFalcon, 08-07-2020, 06:13 AM
            10 responses
            1,415 views
            0 likes
            Last Post Traderontheroad  
            Working...
            X