Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator in MA and updates

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

    Indicator in MA and updates

    Hello

    1. I have an indicator that is based on three other indicators. The output of this particular indicator is 1 or 0. When placed on a chart, it behaves as expected. However in MA, it shows all zeros where in some cases it should be 1. On the chart and in MA, CalculateBarOnClose is set to false. Furthermore, the indicators that this indicator depends on, all had their CalculateBarOnClose flag set to this indicator's CalculateBarOnClose in the Initialize method. The only difference is that in MA, the number of bars loaded is 100 where on the chart it is 300 or so. However I don't believe this difference is significant. All other indicators that do not depend on other indicators, work as expected in MA.

    2. Using IB, data in the grid was updating normally. However at the end of the day I noticed that some indicators had values of zero for all symbols. Once the F5 key was pressed, the grid was refreshed and data for the indicators were updated. CalculateBarOnClose flags for all indicators were set to false.

    Can any hint or help be offered as to why these two abnormalities occurred?

    Thanks in advance.

    #2
    I suggest debugging your indicator as per here: http://www.ninjatrader-support.com/v...ead.php?t=3418

    Comment


      #3
      Dierk, unfortunately it is not the indicator. As I stated, it works fine on a chart. As always, thanks for the reply.

      Comment


        #4
        Not sure I follow: Values rendered on MA are calculated by the indicator no? This implies that the issue is with the indicator code.

        Comment


          #5
          Well, the same indicator works fine on a chart. The only thing that I can think of is that perhaps referencing other indicators is causing a problem. I will investigate further. Thanks again.

          Comment


            #6
            Dierk

            As I check the logs, I see many "Object reference not set to...." errors. As I stated previously, this particular indicator references three other indicators. It works perfectly well when placed on a chart.

            As far as I can tell, in MA, when these other indicators that are referenced in this indicator make calls to Close[Barsago], Open[Barsago], etc. these errors occur. At first I thought these errors were due to an index out of range error. So I palced an 'if (Close.Count == 0)' check. The errors still persist and System.Exception shows the following:

            System.NullReferenceException: Object reference not set to an instance of an object.
            at NinjaTrader.Data.DataSeries.get_Count()
            at NinjaTrader.Indicator.DataSeriesHelper.get_Count()

            I then checked for if (Close == null). It did not help.

            Is this a bug in the MA? If the the bug was with the indicator surely these errors would have been logged when it was placed on a chart.

            Why would references to Close, High, Open, etc. be null only when the indicator is on a MA grid?

            Please advise.

            Comment


              #7
              Please debug your code to get rid of the "Object reference not set to...." errors. This is not a MA issue.

              Comment


                #8
                Dierk

                With all due respect, you are not reading or misconstruting what I'm writing. I did not assert that MA has an issue. I merely asked a question which is based on a previously documented problem:



                To reduce this issue to its simplest form, can you offer any hints as to why an indicator that works perfectly on a chart would have such problems on MA? I have debugged the problem as fas as I can and I can't find an explanation.

                If you are not able to and feel this is an indicator coding issue, then I will make this the last post on this problem.

                Thanks very much in advance.

                Comment


                  #9
                  Don't know off the top of my head. It could be possibe that underlying objects are initialized differently between a chart or an MA.

                  However, accessing Close or Open in the context of OnBarUpdate() should NOT throw an exception. Are you accessing these values elsewhere?
                  RayNinjaTrader Customer Service

                  Comment


                    #10
                    Thank you Ray for the prompt reply. Yes, the Open, Close, etc are being referenced by the other indicators. The indicator in question has the following logic:


                    protected override void OnBarUpdate()
                    {
                    if ((MyIndicator1().IndicatorValue[0] == 1) && (MyIndicator2().IndicatorValue[0] == 1)
                    && (MyIndicator3().IndicatorValue[0] == 0) )
                    {
                    //
                    }
                    else
                    {

                    }

                    }

                    Open, High, Low, Close and Volume are being referenced by MyIndicator1, MyIndicator2 and MyIndicator3. As I stated, this code works without any problems on a chart. No exceptions or errors are logged. The same can not be said when it is placed in MA.

                    The only other option that I can think of is to combine all indicators into one giant indicator.

                    Thanks again.

                    Comment


                      #11
                      What I suggest creating new indicators, each that calls only one of the other custom indicators. See which one is giving the problem. Once this is identified, try to drill down on this specific indicator, then we can see where the source is.
                      RayNinjaTrader Customer Service

                      Comment


                        #12
                        Thanks, Ray. However I just combined all the indicators into one script. It seems that MA has problems with indicators spread over several scripts.

                        This techniqnue seems to have solved the problem but I have to wait until Monday to make sure that it works in realtime.

                        Thanks again.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by argusthome, 03-08-2026, 10:06 AM
                        0 responses
                        89 views
                        0 likes
                        Last Post argusthome  
                        Started by NabilKhattabi, 03-06-2026, 11:18 AM
                        0 responses
                        48 views
                        0 likes
                        Last Post NabilKhattabi  
                        Started by Deep42, 03-06-2026, 12:28 AM
                        0 responses
                        31 views
                        0 likes
                        Last Post Deep42
                        by Deep42
                         
                        Started by TheRealMorford, 03-05-2026, 06:15 PM
                        0 responses
                        34 views
                        0 likes
                        Last Post TheRealMorford  
                        Started by Mindset, 02-28-2026, 06:16 AM
                        0 responses
                        69 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Working...
                        X