Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Programmatically dealing with Calculate

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

    Programmatically dealing with Calculate

    I know I have seen this info somewhere, but I cannot seem to locate it...so I will just ask if anyone has the answer, or knows where it was answered.

    I need to ensure a user cannot set the Calculate to OnBarClose. I read something to the effect that it is bad to code this anywhere else except in the State.SetDefaults. What I read is something about checking what Calculate is set to, and if it is set to OnBarClose, then trigger a Log alert, and terminating the indicator. I found how to do the alert, but have not been able to find how to terminate the indicator.
    This is what I have so far--
    Code:
    if(Calculate == Calculate.OnBarClose) 
    {
    Log("Calculate may NOT be set to OnBarClose",LogLevel.Alert);
    //terminate indicator code goes here
    }
    And, I had put this in State.DataLoaded.

    #2
    Hello Antny,
    Thanks for your post.

    Setting the Calculate property in State.Historical is the recommended way of approaching this situation. This will not only prevent the property from being changed by the user, but will also ensure that any parent scripts also inherit this properties setting.
    Code:
    else if (State == State.Historical)
    {	
    	Calculate = Calculate.OnEachTick;
    }
    Please let me know if you have any questions.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Awesome! That is exactly the info I needed. I am guessing I saw the other info in response to a NT7 post instead of NT8. Since the two are so different, what would the process to do this same thing be for NT7?

      Comment


        #4
        Hello Antny,

        The equivalent in NT7 would be setting CalculateOnBarClose = false inside OnStartUp().
        Code:
        protected override void OnStartUp()
        {
        	CalculateOnBarClose = false;
        }
        OnStartUp()
        https://ninjatrader.com/support/help...?onstartup.htm

        Please let me know if you have any questions.
        Josh G.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

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