Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Referencing a Realtime indicator from another non RT indicator

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

    Referencing a Realtime indicator from another non RT indicator

    Hi!
    I have written an indicator that references another indicator. This second indicator has to be calculated for each tick while the first indicator only would have to be Calculated On Bar Close. I intend to run my strategy with COBC = false, so I would prefer to only call the second indicator on FirstTickOfBar. I suppose that this means that the first indicator also only would be called on FirstTickOfBar. Is there a way to run the first indicator on each tick while I only call the second indicator on each bar? Would this be the case if I put the line "Add(FirstIndicator) in the Initialize method of the strategy?

    /Best Regards

    #2
    Hello poseidon_sthlm,

    Best practice here is only assigning the value of CalculateOnBarClose for the calling indicators. You would then assign as false and can combine this with COBC = true according to this sample. This sample uses the FirstTickOfBar technique you indicate.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Ok, Thanks!

      Comment


        #4
        I found this code in a custom indicator.
        Code:
                protected override void OnStartUp()
                {
                    if (CalculateOnBarClose == false && Bars.BarsType.IsIntraday)
                        CalculateOnBarClose = true;
                }
        Regarding the situation described in post #1 below, would this code be a good solution to the problem?

        Regards,
        poseidon_sthlm

        Comment


          #5
          poseidon_sthlm, you could give it a try for your use, but setting this property dynamically would not be supported.

          Comment


            #6
            Originally posted by poseidon_sthlm View Post
            I found this code in a custom indicator.
            That looks completely unnecessary to me. It looks more like the author wanted to override any user preferences if the bars happen to be intraday. I can't think of any reason why one would want to change it. It's better to write your code to accomodate either setting.

            Here's what I do:
            Code:
            protected void Initialize() {
                // ...
                CalculateOnBarClose = false; // should be the last line
            }
            
            protected void OnBarUpdate() {
                if (FirstTickOfBar) {
                    // do stuff that happens once per bar,
                    // be mindful that the current close is
                    // now 1 bar ago.
                }
                // ...
            }
            -A

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            582 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            338 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            552 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X