Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
          BertrandNinjaTrader Customer Service

          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 GussJ, 03-04-2020, 03:11 PM
            16 responses
            3,279 views
            0 likes
            Last Post Leafcutter  
            Started by WHICKED, Today, 12:45 PM
            2 responses
            19 views
            0 likes
            Last Post WHICKED
            by WHICKED
             
            Started by Tim-c, Today, 02:10 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by Taddypole, Today, 02:47 PM
            0 responses
            5 views
            0 likes
            Last Post Taddypole  
            Started by chbruno, 04-24-2024, 04:10 PM
            4 responses
            51 views
            0 likes
            Last Post chbruno
            by chbruno
             
            Working...
            X