Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

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

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

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

    Hi,
    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 8.0.0.14 64-bit (Multi-Broker) - Release Candidate 2 version.
    Thanks,
    Attached Files
    Last edited by gsreddy; 11-08-2016, 02:13 AM.

    #2
    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

    Comment


      #3
      Hi,
      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.
      thanks
      Last edited by gsreddy; 11-08-2016, 11:48 AM.

      Comment


        #4
        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

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by andrewtrades, Today, 04:57 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        6 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        9 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        20 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X