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

How can I use 'rising' in strategy builder

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

    How can I use 'rising' in strategy builder

    I am trying to find a way to use 'rising' and 'falling' in the Strategy Builder (Conditions and Actions) without going into the code. I cannot find any description on how to use these (listed in the Misc section) and have not managed to without getting error messages.
    Can you show an example of their use.
    Thanks

    #2
    Hello ErikU,

    Thanks for your post and welcome to the forums!

    The result of the Rising or Falling methods is a logical true or false. In the strategy builder, you select the Misc>Rising (or falling). You can then change the default input (which would be the close price bars) to for example a moving average. In the center, you can select "Equals" and then on the right select Misc>true. I've attached an example using an EMA(14) as the input to the Rising method.

    In the example, if the condition of a rising EMA(14) is true, then the actions section would be executed
    Attached Files
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi

      I have added the rising DoubleStochastic(10)=true for longs and the falling (DoubleStochastic(10)=true for shorts, but my strategy now does not start up. I click on the checkbox to start it and then it immediately stops again.

      Just a note, I am using two data series. The 987 tick for entries and the 2584 tick as anchor. I am using the 2584 tick as input series for the Double Stochastic condition and the 987 tick for my other conditions.

      What am I doing wrong?

      I think it might have something to do with the fact that I added another series in the strategy?
      Last edited by Induna; 02-27-2020, 05:18 AM.

      Comment


        #4
        Hello Induna,

        Thanks for your post.

        When you have a script that is not performing as expected, the first thing to check is the "Log" tab of the NinjaTrader control center as this will list when the strategy was enabled and when it was disabled and any error messages that may have caused it to be disabled. These would be "Run time" type errors that cannot be detected during the compilation process.

        When you add a data series, you have to ensure that you are checking for enough bars in each data series have been loaded by the script before being accessed as otherwise you will get a bars indexing error. Please see the help guide on CurrentBars[]: https://ninjatrader.com/support/help...urrentbars.htm

        When you add a data series you are creating a multi time frame or multi series script and your script coding references do change. We highly recommend a review of this section of the help guide section here: https://ninjatrader.com/support/help...nstruments.htm
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thanks Paul. That is the error I get. My script is set to 10 bars. How do I get this fixed? I run NT on a server so it was running the whole day. There should be more than enough bars loaded?
          Last edited by Induna; 02-27-2020, 08:18 AM.

          Comment


            #6
            Hello Induna,

            Thanks for your reply.

            When a script is started, it will begin processing on the first bar of the data, so if you have 5 days of data, the first bar will be 5 days ago. If your code tries to access a previous bar, such as High[1] then on the first bar the previous bar[1] does not exist and will cause the bar index error. In the case of a multi series or time frame script you have to perform a check on both series to ensure that neither of them is being accessed until enough bars have been processed by the script. The way to do this is by checking CurrentBars[0] (chart bars) and CurrentBars[1] (first added data series) as shown in the help guide.

            "When you add a data series, you have to ensure that you are checking for enough bars in each data series have been loaded by the script before being accessed as otherwise you will get a bars indexing error. Please see the help guide on CurrentBars[]: https://ninjatrader.com/support/help...urrentbars.htm"
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              I am using a 987 tick chart and 2584 tick chart. On my charts I have selected 60 days of history. How do I see how much is required? Should I maybe make the chart history longer?

              Comment


                #8
                Hello Induna,

                Thanks for your reply.

                Can you provide the specific error message you are seeing?
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Error on calling 'OnBarUpdate' method on bar 2: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

                  Comment


                    #10
                    Hello Induna,

                    Thanks for your reply.

                    The error is stating that on the 2nd bar of one of the data series, your code tried to access a bar that was farther back than the 2nd bar of that series, for example High[4] would try to access 4 bars ago but if only two bars are loaded by the script then that would generate a similar error. As you have added a second data series it may be that the error is when trying to access the other data series when it has not processed any bars. Please note that each data series will call the OnBarUpdate() method and this will shift any references to that data series. I highly recommend that you review the complete section of the help guide section here: https://ninjatrader.com/support/help...nstruments.htm

                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      Thank you. I have done the strategy through the strategy builder. I don't understand how there can be errors. I am stuck now as I am still learning and have limited knowledge about these aspects of the code.

                      Comment


                        #12
                        Hello Induna,

                        Thanks for your reply and clarification about the strategy builder.

                        Please post your strategy. The easiest way to do this is to go to Documents>NinjaTrader8>bin>Custom>Strategies and attach the file that has the strategy name.

                        If you do not want to post your strategy in a public forum you are welcome to write into PlatformSupport[at]NinjaTrader[dot]Com. Market the e-mail subject Atten:Paul and Ticket# 234732. Please attach the file to your e-mail and in the body of the e-mail include a link to this thread.
                        Paul H.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by alifarahani, Today, 09:40 AM
                        6 responses
                        36 views
                        0 likes
                        Last Post alifarahani  
                        Started by Waxavi, Today, 02:10 AM
                        1 response
                        17 views
                        0 likes
                        Last Post NinjaTrader_LuisH  
                        Started by Kaledus, Today, 01:29 PM
                        5 responses
                        14 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by Waxavi, Today, 02:00 AM
                        1 response
                        12 views
                        0 likes
                        Last Post NinjaTrader_LuisH  
                        Started by gentlebenthebear, Today, 01:30 AM
                        3 responses
                        17 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Working...
                        X