• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Builder Multiple Time Values

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

    Strategy Builder Multiple Time Values

    Hello,

    I am building a strategy to use with the MACD indicator and am trying to have it turn on at specific times to place an order. For example, turn on the strategy from 1:30-2:00am and then reactivate at 3:00-3:30am etc. for multiple times throughout the day. I have built 5 separate strategies for the times I want, however I am concerned that if a trade is still active, when the next strategy tries to place a trade that it won’t work since the first strategy is still active. I would like to put all of the 5 separate times that I want it to place a trade between into one strategy.

    Would I use the ‘sets’ to accomplish this?

    thank you

    #2
    Multiple Time Frame and Instruments;
    EntryHandlingPerDirection =5;
    Last edited by Emma1; 07-30-2020, 08:28 PM.

    Comment


      #3
      Hello Polufson,

      Thanks for your post and welcome to the NinjaTrader forums!

      You can combine all of the time slots into a single Strategy Builder strategy which would make thing easier for you. However, as member Emma1 advised if you have an existing order from one time period that has not been closed, in order to enter a new order in the same direction, you would need to set your "Entries Per Direction" to be the maximum number of entries/positions you would have at any one time. Otherwise if for example you are set to entries per direction of 2 and you have 2 long entries and the strategy tries to place a 3rd, it would be ignored (not placed).
      Please see:
      https://ninjatrader.com/support/help...rdirection.htm
      https://ninjatrader.com/support/help...ryhandling.htm

      Another scenario would be if you are in a long position and the strategy places a shot entry, the long position will first be closed and a second order will be placed to leave you in the short direction. This means that all entry methods, when filled will automatically close positions in the opposite direction (order is called "Close Position") and will place another order to leave you in the direction of the last order.
      Reference: https://ninjatrader.com/support/help...d_approach.htm

      I've attached an example strategy builder strategy that demonstrates:

      1) How to create user inputs for setting time filters.
      2) How to create user inputs for selecting which time filters to use.
      3) Using a single bool variable based on the time filters.

      In the attached strategy, the sequence of sets 1 and 2 are critical, and set 1 must always be before set 2 in any strategy you create off of this example.
      Set 1 contains no conditions so on every bar, the bool variable "TimeFilter" is set false meaning the selected time is not true
      Set 2 contains all of the time filters and if the time matches a time filter, the bool "TimeFilter" is set true, overriding the previous setting to false and this is why the sequence of set 1 to set 2 is important.

      Set 3 is to demonstrate that the bar time matches the selected time filter by drawing the background of the chart. The bool TimeFilter must be true to draw the background.

      To use this in trading, one of your conditions for a trade entry would be to verify that the bool "TimeFilter" equals True.

      I've attached a reference screenshot that shows the strategy settings and a chart that is running the example strategy.

      Click image for larger version

Name:	TimeFilterExample.PNG
Views:	50
Size:	83.0 KB
ID:	1112293

      TimeFilterExample.zip
      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Hi Paul,

        I think I've figured out how to do it a different way, although it might be a little more tedious, it was easier for me to understand. I grouped all of the specific times under 'if any' and it seems to work that way. I will ONLY be going LONG, so I do not need to worry about conflicts of going short. However I have run into an issue of wanting to place more than one order per entry. I did set the entries per direction and it allows more than one at any given time (which helps) but I cannot figure out how to place an order for example 2 contracts at the same entry, (not multiple entries per direction). How would I go about this, thank you

        Comment


          #5
          Hello Polufson,

          Thanks for your reply.

          I think you are asking how to change the "Quantity" field of the order. There are a couple of ways to do this. Directly by clicking "set" then selecting Misc>numeric Value and entering a value or create a user input (int type) and select that user input when you click set. A user variable gives you the ability to change the number of contracts when you apply the strategy and avoids the need to change the strategy each time.

          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Awesome! Thank you, it worked

            Comment


              #7
              Hi Paul,

              Using the strategy builder, I am wondering how I would go about making sure all open orders will cancel at 1:30pm every day, since 1:45pm is supposedly the cut off for day trading. That being said, if I use DAY as my order type, will it automatically close my positions on its own at 1:45pm?

              Comment


                #8
                Hello Polufson,

                Thanks for your reply.

                You can configure the Exit On Session Close seconds so that all positions are closed at a specific time before the end of the session. This can be set within the strategy itself on the "Default properties screen" of the strategy builder 9under "More properties" or at the time you apply the strategy in the strategy parameters: https://ninjatrader.com/support/help...tegyProperties

                In addition, you could also create a time filter that checks the bar time against a range of time and the action is to simply use ExitLong() and ExitShort(). If there are no open positions then the methods would perform no action.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Thank you!

                  Just came across the Trend Lines indicator, and wanted to know how I could use it in my strategy so that when the price closes above the downward trend line it can place a trade. I can't seem to figure it out, thanks!

                  Comment


                    #10
                    Hello Polufson,

                    Below is a link to a forum post that has some details on calling the TrendLines indicator.
                    https://ninjatrader.com/support/foru...70#post1093970

                    As well as a link to the help guide.
                    https://ninjatrader.com/support/help...rend-lines.htm

                    A way to understand the behavior is to print the time and the value of the trendlines indicator to output window.
                    https://ninjatrader.com/support/foru...121#post791121
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by embreyw, Today, 05:56 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post embreyw
                    by embreyw
                     
                    Started by granitmaleaus, Today, 05:11 AM
                    0 responses
                    2 views
                    0 likes
                    Last Post granitmaleaus  
                    Started by julianc05, Today, 12:37 AM
                    1 response
                    9 views
                    0 likes
                    Last Post Emma1
                    by Emma1
                     
                    Started by fernlicht, Today, 01:02 AM
                    1 response
                    11 views
                    0 likes
                    Last Post Emma1
                    by Emma1
                     
                    Started by JellyRoll, Yesterday, 06:57 PM
                    1 response
                    23 views
                    0 likes
                    Last Post bltdavid  
                    Working...
                    X