Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CalculateOnBarClose behavior with nested indicators

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

    CalculateOnBarClose behavior with nested indicators

    "CalculateOnBarClose" property on a strategy will over-ride any settings on indicators the strategy calls.

    But what about when an indicator calls another indicator. ?
    For example ... blah = myJunkInd(123,456);

    What I've found is that the "called indicator" will return null IF "CalculateOnBarClose=true; is coded on the called indicator. Even if the "Calling indicator" has CalculteOnBarClose = false. Ie, it does not over-ride.
    Which makes for some pretty weird results !

    The test cases I did on the 'called indicator' were ...
    1 - CalculateOnBarClose not coded = Works as expected
    2 - CalculateOnBarClose =false coded = Works as expected
    3 - CalculateOnBarClose =true coded = Errors .. and did not 'inherit' the setting from it's caller.

    (in all cases the 'calling indicator' was set to barclose=false)
    This may be a NT bug.. If not, then it should be noted someplace in the help

    I've attached a simple pair of indicators to show the problem.

    "junk' is the primary indicator that would be added to a chart. "junk2" is the inner/called one. All it does is just return Input[0]

    Junk has CalculateOnBarClose =false
    Junk2 has CalculateOnBarClose =true

    If you apply 'junk' to a chart, you'll see the last value is mangled.
    Attached Files

    #2
    The problem it, that you hard coded the CalculateOnBarClose=true in the Initialize method of junk2. This takes precedence. Just remove it.

    Note: This is consistent regardless if a strategy or an indicator hosts junk2 (I just tested).

    Comment


      #3
      Thanks Dierk
      That's what I thought ..

      The problem is that I didn't code that line .. the wizard did.
      The Indicator Wizard always inserts CalculateOnBarClose = xxx statement.
      It defaults CalculateOnBarClose = true

      I suspect most user created indicators would have the problem I ran into.

      Comment


        #4
        Thanks for making us aware of that. We'll take this issue into considerations and see what could be done.

        Comment


          #5
          I second that!

          I agree with that comment. Took me 2 hours to figure out why my indicator ran into overflow (divide by zero) because I was nesting my indicators (in this case - it's a ZeroLagEMA I added from someone).

          The issue is that it's not intuitive that the "parent" indicator CalculateOnBarClose=true does not "cascade" to the "child" indicator.

          Originally posted by zoltran View Post
          Thanks Dierk
          That's what I thought ..

          The problem is that I didn't code that line .. the wizard did.
          The Indicator Wizard always inserts CalculateOnBarClose = xxx statement.
          It defaults CalculateOnBarClose = true

          I suspect most user created indicators would have the problem I ran into.

          Comment

          Latest Posts

          Collapse

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