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 sjsj2732, 03-23-2026, 04:31 AM
          0 responses
          70 views
          0 likes
          Last Post sjsj2732  
          Started by NullPointStrategies, 03-13-2026, 05:17 AM
          0 responses
          312 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          306 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          147 views
          1 like
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          111 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Working...
          X