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

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 SantoshXX, Today, 03:09 AM
        0 responses
        6 views
        0 likes
        Last Post SantoshXX  
        Started by DanielTynera, Today, 01:14 AM
        0 responses
        2 views
        0 likes
        Last Post DanielTynera  
        Started by yertle, 04-18-2024, 08:38 AM
        9 responses
        41 views
        0 likes
        Last Post yertle
        by yertle
         
        Started by techgetgame, Yesterday, 11:42 PM
        0 responses
        12 views
        0 likes
        Last Post techgetgame  
        Started by sephichapdson, Yesterday, 11:36 PM
        0 responses
        2 views
        0 likes
        Last Post sephichapdson  
        Working...
        X