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 inanazsocial, Today, 01:15 AM
        0 responses
        2 views
        0 likes
        Last Post inanazsocial  
        Started by trilliantrader, 04-18-2024, 08:16 AM
        5 responses
        22 views
        0 likes
        Last Post trilliantrader  
        Started by Davidtowleii, Today, 12:15 AM
        0 responses
        3 views
        0 likes
        Last Post Davidtowleii  
        Started by guillembm, Yesterday, 11:25 AM
        2 responses
        9 views
        0 likes
        Last Post guillembm  
        Started by junkone, 04-21-2024, 07:17 AM
        9 responses
        71 views
        0 likes
        Last Post jeronymite  
        Working...
        X