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 Wizard N consecutive bars

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

    Strategy Wizard N consecutive bars

    Hello,
    I am trying to develop a simple strategy in the wizard: Not so simple once I'm in the wizard. If N consecutive bars up (bar close higher than bar open), go long. If N consecutive bars down (bar close lower than bar open), go short. Only if market position = flat. I get the market position entry. I also get entering a stop loss and profit target per the Youtube video. However, I don't know how to get 3, 4, 5, N number of "consecutive" bars up or down. I would like to use this information in the Optimizer. So I assume I need to create a User Input. Please help. Thanks.

    Todd

    #2
    Hi Todd,

    Thank you for your post.

    Yes, you will need to create an user input. You will then use this input to check the bars ago for NBarsUp.

    I have attached a screenshot of the Strategy Wizard setup for this.

    The MyInput0 will be definable when you go to run the Strategy in the Optimizer.

    Let me know if I can be of further assistance.
    Attached Files
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      What goes on the right side of the ==?

      Comment


        #4
        I'm confused on the "Bar count" and "Bars ago". Can you explain? Thanks.

        Comment


          #5
          Todd,

          You will choose true for the right side from the MISC section.

          The bars ago is the number of bars back the indicator will use in its calculations.
          Cal H.NinjaTrader Customer Service

          Comment


            #6
            OK, Thanks. Is Bars ago the number of bars that I am looking to be consecutive up or down? Is that the same as Nbars up or down?

            Comment


              #7
              Todd,
              Correct, that bars ago number tells the NBarUp or Down that tells the indicator to check that many bars back and that each one it true.
              Cal H.NinjaTrader Customer Service

              Comment


                #8
                That would necessitate that my MyInput0 be bool not int.??

                Comment


                  #9
                  Todd,
                  No, user defined input that I outlined in the screenshot will need to be a INT in order to pass it through the indicator and I apologize, that line is Bar Count, not Bars Ago.
                  The Bar Count would be how many you want to be true while the Bars Ago would be the number of bars to look back

                  Let's say that you inputted 3 for the Bar Count and 5 for the Bars Ago.
                  The indicator will check that last 5 bars and if any 3 meet the criteria.
                  Cal H.NinjaTrader Customer Service

                  Comment


                    #10
                    It's not allowing me to set the right side to "True". It gives me an error. . . 'NBarsup' and right expression 'Boolean' do not match."

                    Comment


                      #11
                      Todd,
                      Sorry, the statement will return a 1 if true or 0 if false.

                      Try using a Numeric value instead of True or False.
                      Cal H.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks so much for your help. Sorry I'm so dense. But I want "consecutive" bars up or down. I want it to look back 4 bars and if all 4 bars are up or down then enter the trade. Or, I want to optimize and see if 3 consecutive bars, or 5 consecutive bars increase potential profit. Thanks!

                        Comment


                          #13
                          Don't I want Bar count and Bars ago to be the same. Can't I use the MyInput0 for both?

                          Comment


                            #14
                            Todd,

                            That was meant as an example. You can use the MyInput0 for both Bar Count and Bars Ago
                            Cal H.NinjaTrader Customer Service

                            Comment


                              #15
                              Thanks. Can you define "NBarsUp" and "NBarsDown"? It doesn't seem to be working like I anticipated. Basically, I use Japanese Candlesticks. If there are 4 consecutive green candlesticks, I want to enter Long. Same the other direction.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Waxavi, Today, 02:10 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post Waxavi
                              by Waxavi
                               
                              Started by TradeForge, Today, 02:09 AM
                              0 responses
                              8 views
                              0 likes
                              Last Post TradeForge  
                              Started by Waxavi, Today, 02:00 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post Waxavi
                              by Waxavi
                               
                              Started by elirion, Today, 01:36 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post elirion
                              by elirion
                               
                              Started by gentlebenthebear, Today, 01:30 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post gentlebenthebear  
                              Working...
                              X