Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Best Practice for Referencing an Indicator on bar close in a Real Time Strategy?

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

    #16
    As I explained below, the provided code example doesn't return any output in real time without the Update() method in the getter of the output series of the called indicator. And I want to make sure that the called indicator isn't called more than once on FirstTickOfBar. Is there a way to check if an indicator is updated or not on the current bar so that one could enter a conditional statment for Update(); in the getter of the called indicator?

    Code:
            [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
            [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
            public DataSeries MyOutput
            {
                get {
                        [COLOR=Red]if ( ???) [/COLOR]Update();
                        return myOutput;
                    }
            }

    Comment


      #17
      poseidon_sthlm, I believe you could check with ContainsValue if your series returned would have a value for the bar or not, if yes then don't Update().

      Comment


        #18
        Thanks! The "if ( !myOutput().ContainsValue(x)) Update();" did the trick. It seems as if the check with "myOutput().ContainsValue(x)" in itself is sufficient to make the called indicator update on FirstTickOfBar. The Update() method was never called during my tests in Market Replay.

        Regarding the Update() method, what does it actually update? Is it just the OnBarUpdate() method of the called script that is executed, or does Update() execute an entire OnBarUpdate() of a "compiled assembly" of the strategy and all its referenced indicators?

        /Best Regards
        Poseidon_STHLM

        Comment


          #19
          Glad to hear it Poseidon, the Update() is basically a forced OnBarUpdate() call to ensure up to date property values are returned.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          43 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          27 views
          0 likes
          Last Post PaulMohn  
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          163 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          98 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          158 views
          2 likes
          Last Post CaptainJack  
          Working...
          X