Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

question about trading hours please

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

    question about trading hours please

    The functionality with trading hours in ninja trader 8 gives me the ability to choose the trading hours I wish to use. I have noticed that using these hours set would actually hold the chart until the trading hours is started again.
    I would want the chart to be continuously moving and I want my strategy to stop and start, so my trading hours would be in a continuously moving chart. If the chart stops and starts it takes a chunk of past information with it.

    I would imagine therefore that my trading hours for my strategy would have to be coded. Is there a snippet of code that would control this? I am not a Coder and therefore something I could understand, but I would like the times that I want to set for my strategy to be set for instance in the strategy builder, in the inputs and variables

    Any advice would be appreciated.

    #2
    Hello fredfred,

    Thanks for your post.

    With the strategy builder, you can create various time-based filters to limit your trading to times that you choose intraday. You can indeed set various start/stop times as input to the strategy builder. Examples of use would be limiting trading to certain days of the week, certain hours of the morning and certain hours of the afternoon or evening.

    Please see the examples in the help guide, "How to create time comparisons" and " How to create time filters" both in this link: https://ninjatrader.com/support/help...on_builder.htm

    I've attached a working example and screenshot of an example strategy that will color the bars during trading times that can be specified when you apply the strategy. I've also added a condition to prevent coloring the bars on Monday. The coloring of bars is only to demonstrate on the chart when the time conditions are true. The strategy does not place trades and is an example for educational purposes only. Hopefully, this will be helpful in understanding how to create and use time conditions for your strategy.


    Click image for larger version

Name:	FredFred-1.PNG
Views:	1144
Size:	35.6 KB
ID:	1042067

    [ATTACH]n1042068[/ATTACH]


    Paul H.NinjaTrader Customer Service

    Comment


      #3
      That is absolutely brilliant , thank you
      Last edited by fredfred; 12-07-2018, 07:42 AM.

      Comment


        #4
        Just one issue I have found is that although the script works beautifully when a trade is entered close to the end of the time period set it will not terminate the trade at the end of the time period.
        My strategy should terminate the trade but will not do so because it is outside the time period set. I imagine there would be an additional piece of code to terminate all trades at the time that the time period ends?
        If this is possible can it be implemented in the Strategy Builder?
        Many thanks


        Last edited by fredfred; 12-10-2018, 02:56 AM.

        Comment


          #5
          Hello fredfred,

          Thanks for your reply.

          While you can use the time filters to limit entering trades, you can also add a time to exit all trades.

          In the sets where you have a time filter, there is a begin and end time. For the exit set, you would only need to set an "after" time.

          In another set in the strategy builder, you would create an exit time that says if the bar series time is at or after a specific time to then ExitLong() and ExitShort(). These exit methods will not function unless there is a position to exit so they can be used with concern. To avoid conflict you would likely want to set the time to be after the okay to enter time filter.


          Paul H.NinjaTrader Customer Service

          Comment


            #6
            I created another set in the strategy builder and am trying the following logic in screen shot.
            Time / date series 0 bars ago Greater than the StopPM the error I am getting is Type of left expression and right expression do not match, please select similar expressions.
            On this data set I would put exit long and short ?

            set 4 has the user input start and stop that doesn't cancel a trade if the trade opened before the end time.
            The new set 5 was set up to try and cancel trades that have opened before the end time and didn't cancel at end time ?


            I am not understanding the syntax here " o
            n another set in the strategy builder, you would create an exit time that says if the bar series time is at or after a specific time to then ExitLong() and ExitShort()."

            Comment


              #7
              Hello fredfred,

              Thanks for your reply.

              In general, you would use a start and stop time as part of the Entry conditions, meaning that you do want to trade between this time and that time. In another set, you would create a condition that says if time is after the stop time to then exit any orders (if that is what you want to do).

              Set #4 looks like an entry set conditions but you have placed an exit order.

              The other condition set is in error because you have select Date series instead of Time series. You want to compare the time of the current bar against your stop time. It is in this set that as the action you could place ExitLong() and ExitShort() if that is what you want to do.
              Paul H.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by ghoul, Today, 06:02 PM
              0 responses
              3 views
              0 likes
              Last Post ghoul
              by ghoul
               
              Started by Barry Milan, Yesterday, 10:35 PM
              6 responses
              18 views
              0 likes
              Last Post Barry Milan  
              Started by DanielSanMartin, Yesterday, 02:37 PM
              2 responses
              13 views
              0 likes
              Last Post DanielSanMartin  
              Started by DJ888, 04-16-2024, 06:09 PM
              4 responses
              13 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by terofs, Today, 04:18 PM
              0 responses
              12 views
              0 likes
              Last Post terofs
              by terofs
               
              Working...
              X