• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Referencing an MTF indicator in another indicator

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

    Referencing an MTF indicator in another indicator

    Hello,
    I'm referencing a MTF indicator which has this:

    Code:
    if (CurrentBar < BarsRequired || CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired || CurrentBars[2] < BarsRequired)
    It's being called into an indicator which only has this:
    Code:
    if (CurrentBar <  BarsRequired)
    I'm using try/catch blocks to see where it stops working.
    I'm getting the effor "Object reference not set to an instance of an object" and since I've tried nearly everything else I can think of, I'm wondering if the BarsRequired is maybe not set correctly or something related to the differing sets of CurrentBars[].

    #2
    Hello zeller4,

    I've made a quick example to show adding a secondary series to a target script and then calling this script should work without issue.

    Please import this package and try running the MTFCallerExample script on a chart. This will print to the output window.

    Are you finding any issues with this example?
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea,
      Here's my quick files of a similar nature, showing what I'm trying to accomplish.
      Not sure if there needs to be something else besides
      Code:
      if (CurrentBar < BarsRequired)
      in the Caller code.

      Anything else that stands out that could cause the problems from Post#1?
      Attached Files

      Comment


        #4
        Hello zeller4,

        Is the code sample I gave you giving you errors?

        Is the code sample you just posted giving you errors?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          No and no, I was trying to make the sample closer to the reality of what I'm trying to fix...

          Comment


            #6
            Hello zeller4,

            You are likely running into a logic issue.

            If this file is not causing any issues, then I wouldn't imagine anything needs to be recoded.

            The example is just to show that as long as you are checking that there are enough bars for as far back as you are calling then there shouldn't be an error.

            If you are calling an object that doesn't exist, such as too many bars back, or trying to call an object that is null, then you are going to get an error.


            My suggestion would be to reduce your code until the error stops. Then add the code back line by line until the error returns. This should let you know what line has the object that is being called that doesn't exist.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Does this line in your code
              Code:
              Value.Set(CurrentBar);
              have something to do with exposing a variable like other samples I've seen?

              Comment


                #8
                Hello zeller4,

                Are you referring to line 47 in the MTFCallieExample that I have provided you?

                Is this line causing an error on your machine? (Currently, with this line in my code I am not getting any errors on my end)


                (edit)
                To clarify this line is setting a value for the default plot

                This is not a custom exposed series, but I could easily make this an exposed series.
                Last edited by NinjaTrader_ChelseaB; 09-10-2015, 09:29 AM.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by reedstickets, Today, 07:53 PM
                0 responses
                7 views
                0 likes
                Last Post reedstickets  
                Started by Atilla, Today, 04:05 PM
                0 responses
                19 views
                0 likes
                Last Post Atilla
                by Atilla
                 
                Started by Displacer, Today, 02:57 PM
                2 responses
                13 views
                0 likes
                Last Post Displacer  
                Started by SAILIKITY, 05-22-2019, 05:41 PM
                1 response
                10 views
                0 likes
                Last Post NinjaTrader_PaulH  
                Started by rmillar, 01-09-2019, 06:02 PM
                6 responses
                80 views
                1 like
                Last Post eDanny
                by eDanny
                 
                Working...
                X