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:



      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:	1033
Size:	83.0 KB
ID:	1112293

      [ATTACH]n1112292[/ATTACH]
      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.
                    Hi, I'm looking to add a simple price break above or below the TrendLine indicator to my strategy. Is there a simple way to use the TrendLine indicator in a strategy to determine when the current price breaks above a down trend line and breaks below an up trend line? I have tried using the strategy builder, but keep getting a


                    As well as a link to the help guide.


                    A way to understand the behavior is to print the time and the value of the trendlines indicator to output window.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Greetings!

                      I know this is an old thread, but I'm going crazy trying to create multiple time filters on Strategy Builder. NT_PaulH wrote an explanation and attached a sample of how to set up in Strategy Builder, but it looks like his attachment is no longer able to be downloaded. Can anyone help? Much appreciated!

                      Comment


                        #12
                        Hi Finley, thanks for posting. The example in post number 3 is still available to download. Just click the "TimeFilterExample.zip" link at the bottom. If you can not download this please let me know.
                        Last edited by NinjaTrader_ChrisL; 03-14-2023, 10:07 AM.
                        Chris L.NinjaTrader Customer Service

                        Comment


                          #13
                          Hi Chris,

                          Thanks for your response. I clicked on the blog link provided and it shows no content found. Any suggestions?
                          Attached Files

                          Comment


                            #14
                            Hi Finley, sorry the forum converted my text. I corrected the post.
                            Chris L.NinjaTrader Customer Service

                            Comment


                              #15
                              Click image for larger version

Name:	Screenshot_17.png
Views:	299
Size:	97.4 KB
ID:	1240244Click image for larger version

Name:	Screenshot_17.png
Views:	332
Size:	97.4 KB
ID:	1240243

                              Chris. See that is the problem. I don't see a zip file but rather just text. [ATTACH]n1112292[/ATTACH]

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by pkefal, 04-11-2024, 07:39 AM
                              11 responses
                              36 views
                              0 likes
                              Last Post jeronymite  
                              Started by bill2023, Yesterday, 08:51 AM
                              8 responses
                              44 views
                              0 likes
                              Last Post bill2023  
                              Started by yertle, Today, 08:38 AM
                              6 responses
                              25 views
                              0 likes
                              Last Post ryjoga
                              by ryjoga
                               
                              Started by algospoke, Yesterday, 06:40 PM
                              2 responses
                              24 views
                              0 likes
                              Last Post algospoke  
                              Started by ghoul, Today, 06:02 PM
                              3 responses
                              16 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Working...
                              X