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

Problematic Differences:Calculate [NT8] -- vs -- CalculateOnBarClose [NT7]

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

    Problematic Differences:Calculate [NT8] -- vs -- CalculateOnBarClose [NT7]

    After testing a while, i observed the differences in behavior of NT8 compared to NT7. I don't know if this turns out just a sharing of experience or it's a bug, that needs to be addressed (at least, in DOCS page to be explained)

    NT 7 Behavior:

    1) i.e. you have indicator X (NT7), and in Initialize it's set to CalculateOnBarClose=true;

    2) if you call X indicator in Y indicator, it doesnt matter to if Y is set to COBC or not, and X will still show CalculateOnBarClose=true

    3) if the X doesnt have the CalculateOnBarClose=... lineinside Initialize (so, not setting it to anything), then X will always get the same COBC as parent Y

    4) even, in parent class, you can override the called indicator's COBC from OnStartUp:

    var instance= X(..);
    instance.CalculateOnBarClose = true/false ; // will set to whatever you choose



    However, NT 8 Behavior seemed to be different, and i think you have to address that, or at least, note that on DOCS page.
    in NT8, it doesnt matter. X will always get same Calculate as the caller (parent) Y indicator has. EVEN DOESN'T MATTER IF YOU SET IT IN PARENT, LIKE:

    ( State==State.DataLoaded ) // or any state you want
    var instance= X(..);
    instance.Calculate = Calculate.OnBarClose/OnEachTick ; // doesnt matter... it will still work with PARENT's Calculate .




    To avoid that, I used a "trick". in X indi, i have to set:

    Code:
            Calculate _calculate; // stand up parent inclusions, to imitate to NT7
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    .....
                }
                else if (State == State.Configure)
                {
                    _calculate = Calculate;
                }
                else if (State == State.DataLoaded)
                {
                    Calculate = _calculate;
                }
            }
    it's might seems strange - if a stranger looks on this code, he would surely not understand why these lines are needed and would have just removed these codes from NT8 ported indicators. But i think it's the only way I see.

    the other "workaround" (but the above workaround is better) seemed to be changing the caller Y indicator's property temporarily:

    Code:
    _temp = Calculate;
    Calculate = C..OnEachTick/OnBarClose; //set any desired value for [B]X[/B] indi
    var instance = X(...);
    Calcualte = _temp; //re-set back

    #2
    Hello TazoTodua,

    Thanks for your post.

    We should keep in mind that NinjaTrader 8 uses a State system rather than the using Initialize and OnStartUp methods. Forcing a child indicator to use a different calculate mode would be handled differently.

    We document in NT8 that the child indicator will inherit Calculate from the parent and that forcing the Calculate mode can be done in State.Historical. I have attached a parent and child indicator that can demonstrate forcing the child indicator's Calculate mode.

    Calculate - https://ninjatrader.com/support/help.../calculate.htm

    As we use a State system in NT8 and this would be handled differently, we should be focusing more on what you need to accomplish for your conversion. If the information provided here does not help you move towards a resolution, please let me know what specific hang up you are having with your conversion so we can focus on that.

    I look forward to being of further assistance.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      ah, i didnt thought of state-historical.
      thanks

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by giulyko00, Yesterday, 12:03 PM
      3 responses
      12 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by habeebft, Today, 07:27 AM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_ChristopherS  
      Started by AveryFlynn, Today, 04:57 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by Max238, Today, 01:28 AM
      4 responses
      39 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by r68cervera, Today, 05:29 AM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X