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 Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          603 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          349 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          104 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          560 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          560 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X