Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Strategy Builder/Wizard: How-to wait x bars before next entry

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

    Strategy Builder/Wizard: How-to wait x bars before next entry

    Hi,

    Is there a way to build logic from the Strategy Builder to wait x bars before executing next entry on fulfilled strategy conditions?

    If not, could anyone be so kind and post example code for a simple working strategy where the strategy waits x bars / time before it is allowed to execute next entry.

    Many thanks in advance!

    br,
    Chris

    #2
    Hi Chris,

    Thanks for your post.

    In the condition builder, under Misc>Bars since exit as one of the conditions.

    Reference: http://ninjatrader.com/support/helpG...texecution.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank You! I tried bars since entry but of course..! :-D

      Thanks once again!

      br,
      Chris

      Comment


        #4
        Hi again,

        This is partially working, if I had the strategy to only place one entry per trade.

        However, what I'm trying to accomplish is the following:

        1) The long strategy is allowed to place 3 entries upon fulfilled conditions
        2) The strategy has to wait 20 bars before it is allowed to place next long entry based on criteria in #1

        I guess I have to use "Bars since entry" after all. The problem is, that if I add condition "BarsSinceEntryExecution(0,"",0)>=20" it can not place the first long entry, am I right?

        br,
        Chris

        Comment


          #5
          Hereby replying to my own post, after RTFM (Read The Fcking Manual) and dedicated 5minutes to meditating and allowing some blood to run through my small brain..

          This is how I think it should be done:

          1) In the Strategy Builder, Conditions and Actions; add a new group and call it e.g. "BarsSinceEntry"
          2) Set condition set to "If Any" in the drop down
          3) Add "BarsSinceEntryExecution(0,""0)=-1 [this will check if there has been placed any orders before this one]
          4) Add ""BarsSinceEntryExecution(0,""0)>=20 [20 is the amount of bars before the condition set is triggering next entry. E.g. if you have a daily time frame strategy, 20 bars is equal to 20 days before it takes another entry]

          Br,
          Chris

          Comment


            #6
            Quick Question

            Thank you for your post. I do have one quick question- Can this be accomplished by using only the strategy builder? The only way I can get an "and" statements with an "if" statements is by unlocking the code and manually entering the arguments.

            Thanks for your reply.


            rg

            Comment


              #7
              Hello rgreenberg,

              Thanks for your post and welcome to the NinjaTrader forums.

              Background: By default, the conditions windows are set to "If all" meaning that all statements that are in the same condition window are automatically "anded" together. In other words all of the conditions listed have to be true for the action to be executed. The conditions window can be set to "If any" which an "OR" condition meaning that if any of the listed conditions are true, the action will be executed.

              In using the BarsSinceExit() method, there are two condition where the method returns a -1 if there is no previous exit or it returns a positive value of the number of bars since the last exit. Member suroot used the "if any" in a group so that the group would be true if there was no prior exit OR there was an exit meeting his bars requirement. The group he created was then "anded" with the other conditions in his set.
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                Paul,

                Thank you for your reply. As with so many others on the Forum, the answer comes quickly to ones self quickly after the post (!)

                Are you saying that there are 2 different scenarios in which the "Bars Since Exit (or Entry for that matter)" returns a -1, or were you just writing that their are 2 scenarios, either a -1 or a positive numeric value.

                Thank you again.

                rg

                rg

                Comment


                  #9
                  Hello rgreenberg,

                  Thanks for your reply.

                  A typical use of the BarsSinceExit() is to wait x bars before making a new entry. So it is used as an entry condition, usually to delay from entering too quickly after a previous order exit.

                  However, if there is no prior entry then simply checking BarsSinceExit() for x number of bars will not work as an entry condition. This is why the method will return a -1 when there is no previous exit so that your code can test for X number of bars since exit OR a -1 value. Once the very first exit occurs, BarsSinceExit() will then return the number of bars since the last exit.
                  Paul H.NinjaTrader Customer Service

                  Comment


                    #10
                    Thank you Paul.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by wzgy0920, 04-20-2024, 06:09 PM
                    2 responses
                    27 views
                    0 likes
                    Last Post wzgy0920  
                    Started by wzgy0920, 02-22-2024, 01:11 AM
                    5 responses
                    32 views
                    0 likes
                    Last Post wzgy0920  
                    Started by wzgy0920, 04-23-2024, 09:53 PM
                    2 responses
                    49 views
                    0 likes
                    Last Post wzgy0920  
                    Started by Kensonprib, 04-28-2021, 10:11 AM
                    5 responses
                    193 views
                    0 likes
                    Last Post Hasadafa  
                    Started by GussJ, 03-04-2020, 03:11 PM
                    11 responses
                    3,235 views
                    0 likes
                    Last Post xiinteractive  
                    Working...
                    X