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

indicator method overhead

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

    indicator method overhead

    Let's say I want to reference an indicator method's value for other calculation, e.g.,

    What're the pros and cons of of the following two possible solutions:

    1.

    // put it Indicator variable and init in the Initialize()

    value = Bollinger(14,2).Middle[0];

    and reference the 'value' inside OnBarUpdate() as

    Plot.Set(myFunction(value));


    2. or just do it inside OnBarUpdate() as

    Plot.Set(myFunction(Bollinger(14,2).Middle[0]));


    I would assume the (1) choice is better in that, the Bollinger object will not be created on EVERY OnBarUpdate call, a very expensive option particularly if the CalculateOnBarClose is false!

    Please correct me if I am wrong on this. Thanks.

    #2
    Originally posted by balancenv View Post
    Let's say I want to reference an indicator method's value for other calculation, e.g.,

    What're the pros and cons of of the following two possible solutions:

    1.

    // put it Indicator variable and init in the Initialize()

    value = Bollinger(14,2).Middle[0];

    and reference the 'value' inside OnBarUpdate() as

    Plot.Set(myFunction(value));


    2. or just do it inside OnBarUpdate() as

    Plot.Set(myFunction(Bollinger(14,2).Middle[0]));


    I would assume the (1) choice is better in that, the Bollinger object will not be created on EVERY OnBarUpdate call, a very expensive option particularly if the CalculateOnBarClose is false!

    Please correct me if I am wrong on this. Thanks.
    You are correct.

    Comment


      #3
      A few followup questions:

      1. Will NT be smart enough to 'cache' duplicate indicator methods in the same 'chart window'? In my case,
      if I already have the Bollinger band (14,2) as one of the indicators added to the chart, and in my code I will need to reference it's value(s) again, how many instances are in the chart? I suspect the 'NT generated code' at the end of each indicator CS file is for this purpose?
      What if the same Bollinger is needed but with different parameters? Will they be different objects?

      2. If the answer to the (1) question is yes then I don't need to ask this question. But if indicators are not cached, and if I want to references all three (upper, middle, and lower) values of the Bollinger band, how do I declare a variable to store the Bolinger indicator methods, instead of declaring three Dataseries for the three values?

      Thanks again!

      Comment


        #4
        Originally posted by balancenv View Post
        A few followup questions:

        1. Will NT be smart enough to 'cache' duplicate indicator methods in the same 'chart window'? In my case,
        if I already have the Bollinger band (14,2) as one of the indicators added to the chart, and in my code I will need to reference it's value(s) again, how many instances are in the chart? I suspect the 'NT generated code' at the end of each indicator CS file is for this purpose?
        What if the same Bollinger is needed but with different parameters? Will they be different objects?

        2. If the answer to the (1) question is yes then I don't need to ask this question. But if indicators are not cached, and if I want to references all three (upper, middle, and lower) values of the Bollinger band, how do I declare a variable to store the Bolinger indicator methods, instead of declaring three Dataseries for the three values?

        Thanks again!
        For both questions, that is the point of creating a named instance of the class. Caching is irrelevant: you are referring to a named instance, so it is the one that will be accessed. You can access all of its properties directly without necessarily having to store anything in separate DataSeries, unless you intend to process those DataSeries themselves in an otherwise independent manner.

        Comment


          #5
          Please advise how to create an indicator method with a reference, and without the overhead of actually drawing on the chart?

          Comment


            #6
            Originally posted by balancenv View Post
            Please advise how to create an indicator method with a reference, and without the overhead of actually drawing on the chart?
            Either of these of my posts demonstrate it.


            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by alifarahani, Today, 09:40 AM
            4 responses
            21 views
            0 likes
            Last Post alifarahani  
            Started by gentlebenthebear, Today, 01:30 AM
            3 responses
            16 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by PhillT, Today, 02:16 PM
            2 responses
            7 views
            0 likes
            Last Post PhillT
            by PhillT
             
            Started by Kaledus, Today, 01:29 PM
            3 responses
            11 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by frankthearm, Yesterday, 09:08 AM
            14 responses
            47 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Working...
            X