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

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 maybeimnotrader, Yesterday, 05:46 PM
                3 responses
                23 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by adeelshahzad, Today, 03:54 AM
                5 responses
                32 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by stafe, 04-15-2024, 08:34 PM
                7 responses
                32 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by merzo, 06-25-2023, 02:19 AM
                10 responses
                823 views
                1 like
                Last Post NinjaTrader_ChristopherJ  
                Started by frankthearm, Today, 09:08 AM
                5 responses
                22 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Working...
                X