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

Macd with fast MA offset ?

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

    Macd with fast MA offset ?

    Just wondering if something like this will work . So far these 2 lines don't
    work . thx

    fastEma.Set(LinReg(Input, Fast)[2]);

    slowEma.Set(SMA(Input, Slow)[0]);

    #2
    Hi there, are there any errors in the logs (right-most tab of Control Center)? Those two lines should work.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Error :

      8/13/2009 8:17:17 AM Default Error on calling the 'OnBarUpdate' method for indicator 'MyMacdLregSMA2' on bar 0: Index was out of range. Must be non-negative and less than the size of the collection.
      Parameter name: index

      Not quite sure what that means ... Was trying on range chart .

      Comment


        #4
        On the first bar (bar 0), when you set this: fastEma.Set(LinReg(Input, Fast)[2]), the error you posted will occur because there is not enough data in the LinReg DataSeries. This tip applies here as well.

        A solution would be to place this at the very beginning of OnBarUpdate():
        Code:
        protected override void OnBarUpdate()
        {
        // this NEEDS to be first
        if (CurrentBar < 3)
            return;
        }
        The above code will not process any code inside OnBarUpdate() if there are less than 3 bars on the chart, thus making sure you have enough data.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Still problems . Maybe this will help ?
          Attached Files

          Comment


            #6
            These are now different problems. The highlighted portions of the attached picture are not necessary.
            Attached Files
            AustinNinjaTrader Customer Service

            Comment


              #7
              Seems to be getting more complicated . ?
              Attached Files

              Comment


                #8
                T2020, every bracket needs to have a "buddy" bracket. By that, I mean every { needs a }. In your attached picture, OnBarUpdate() has an opening bracket and two closing brackets. Thus, there is an imbalance and you will get compile errors.

                If you remove the bracket below the Diff.Set line, you should be fine.
                AustinNinjaTrader Customer Service

                Comment


                  #9
                  I just noticed that .
                  Thanks again .

                  Comment


                    #10
                    Here's the same indicator with an offset added to the slow line . It doesn't
                    plot ,so maybe this isn't going to work ???
                    Attached Files

                    Comment


                      #11
                      Those brackets you are highlighting should not be there.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_Josh View Post
                        Those brackets you are highlighting should not be there.
                        Still doesn't plot ???

                        Comment


                          #13
                          You need to remove the brackets and then check your Control Center logs for errors.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            Originally posted by NinjaTrader_Josh View Post
                            You need to remove the brackets and then check your Control Center logs for errors.
                            8/21/2009 10:22:40 AM Default Error on calling the 'OnBarUpdate' method for indicator 'AZBLRMacd' on bar 3: Index was out of range. Must be non-negative and less than the size of the collection.
                            Parameter name: index

                            what exactly does this mean ?

                            Comment


                              #15
                              Please change if (CurrentBar < 3) to be less than 4.

                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by GussJ, 03-04-2020, 03:11 PM
                              15 responses
                              3,271 views
                              0 likes
                              Last Post xiinteractive  
                              Started by Tim-c, Today, 02:10 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by Taddypole, Today, 02:47 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post Taddypole  
                              Started by chbruno, 04-24-2024, 04:10 PM
                              4 responses
                              51 views
                              0 likes
                              Last Post chbruno
                              by chbruno
                               
                              Started by TraderG23, 12-08-2023, 07:56 AM
                              10 responses
                              403 views
                              1 like
                              Last Post beobast
                              by beobast
                               
                              Working...
                              X