• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.

            http://www.ninjatrader.com/support/f...tch#post221406
            http://www.ninjatrader.com/support/f...97907#poststop

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by tonynt, Today, 11:21 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by kabott, Today, 10:47 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by bc24fl, Today, 10:00 AM
            3 responses
            10 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by TonyParisi, Today, 07:38 AM
            2 responses
            13 views
            0 likes
            Last Post TonyParisi  
            Started by fx.practic, Today, 10:03 AM
            2 responses
            9 views
            0 likes
            Last Post fx.practic  
            Working...
            X