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

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 helpwanted, Today, 03:06 AM
          0 responses
          3 views
          0 likes
          Last Post helpwanted  
          Started by Brevo, Today, 01:45 AM
          0 responses
          7 views
          0 likes
          Last Post Brevo
          by Brevo
           
          Started by aussugardefender, Today, 01:07 AM
          0 responses
          5 views
          0 likes
          Last Post aussugardefender  
          Started by pvincent, 06-23-2022, 12:53 PM
          14 responses
          242 views
          0 likes
          Last Post Nyman
          by Nyman
           
          Started by TraderG23, 12-08-2023, 07:56 AM
          9 responses
          384 views
          1 like
          Last Post Gavini
          by Gavini
           
          Working...
          X