• 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.


No announcement yet.

Partner 728x90


Calling Calculate on Bar Close indicator in calculate on each tick indicator

  • Filter
  • Time
  • Show
Clear All
new posts

    Calling Calculate on Bar Close indicator in calculate on each tick indicator

    I am trying to convert one of the indicator from NT7 to NT8.

    The main indicator initiates multiple other indicates and they are based on different calculation modes. These indicators have multiple public properties for accessing in the main indicator.

    This indicator is working as expected in NT7 but not in NT8.
    Please check the below cases where it is failing. Also please check the attached sample code with SAM indicator.

    1) Load 10 minute chart with tick replay data on.
    2) Assign main indicator to 10 minute chant with calculate on each tick.
    3) SAM will not get calculated ,it is printing 0 ( if we assign main indicator with calculate on bar close, getting the expected output )

    I am trying to calculate SMA indicator values at calculate on bar close and use that values in another indicator which run on each tick.

    In NT7 I am using below sample to get expected results.

    Main indicator will be running on each tick. In main indicator I have below code to force sub indicator to run on bar close.
    private SMA sma;
    sma = SMA(14);
    sam.CalculateOnBarClose = true;
    How do I get same behavior of execution on NT8?

    i am using the 64-bit (Multi-Broker) - Release Candidate 2 version.
    Attached Files
    Last edited by gsreddy; 11-08-2016, 01:13 AM.

    Hello Gsreddy,

    Thank you for your note.

    You are setting your SMA indicator to only update on bar close, yet trying to print its value on each tick. sma[0] is unknown or zero until its bar closes with the setting sma.Calculate=Calculate.OnBarClose;

    It is not suggested to set the called indicators COBC from within the calling indicator, rather set COBC for the calling indicator. You should remove the sma.Calculate=Calculate.OnBarClose; under State.Historical. Since you have your print statements in (IsFirstTickOfBar), values are printed on the first tick of that bar.

    I’ve provided a reference example on separating logic to either calculate once on bar close or on every tick.

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service


      thanks for the quick reply. i have seen that example.
      in my main indicator, i have to call couple of indicators with COBC set to true. is it possible to set COBC by indicator in NT8 when initiating them in main indicator?

      do i need to combine all the code from two sub indicators into main indicator? these two indicators has lot of code (around 5000 lines in each ). i have converted them and tested in NT8.

      also tried to set this.Calculate= Calculate.OnBarClose; in called indicator and seening the same results.

      also i tried to place Print statment in called indicator under OnBarUpdate() with if(IsFirstTickOfBar). it is printing the current tick vales rather than completed bar values.

      any help will be appreciated.
      Last edited by gsreddy; 11-08-2016, 10:48 AM.


        Hello GSreddy,

        It is not recommended to set COBC by indicator from within the calling indicator.

        If you want to run the calling indicator on CBOC=Each Tick but have your called indicator COBC=True, printing sma[0] within IsFirstTickOfBar, will return a value just once, at the first tick of the bar. You would not need to individually set the called indicators COBC with this approach.

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service


        Latest Posts


        Topics Statistics Last Post
        Started by yrch1985, 11-03-2019, 11:49 AM
        8 responses
        Last Post aligator  
        Started by Dr3am, Today, 05:10 PM
        0 responses
        Last Post Dr3am
        by Dr3am
        Started by imalil, Today, 04:28 PM
        0 responses
        Last Post imalil
        by imalil
        Started by bboyle1234, Today, 03:47 PM
        0 responses
        1 view
        Last Post bboyle1234  
        Started by caveat_lector, Today, 03:46 PM
        0 responses
        Last Post caveat_lector