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 cmoran13, 04-16-2026, 01:02 PM
            0 responses
            51 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            31 views
            0 likes
            Last Post PaulMohn  
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            165 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            100 views
            1 like
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            160 views
            2 likes
            Last Post CaptainJack  
            Working...
            X