Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CalculateOnBarClose Question

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

    CalculateOnBarClose Question

    Suppose I have the following in my code:

    Code:
    CalculateOnBarClose = true;
    but let's say the user changes this to False in the Properties window. Which setting takes precedence? The code or the user property?

    #2
    Hi scottreynolds,

    The selection made in the user interface will take precedence. Setting in Initialize() serves only as the initial default setting for the property.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Is it possible to have my strategy disable the setting in the user interface to prevent the user from changing this?

      Comment


        #4
        There's no way to disable the setting, but you can read the property value in your code. You can basically disable any processing if it's not set as the script design requires.

        Code:
        if(CalculateOnBarClose)
        DrawTextFixed("errorHandling", "This indicator is designed only for CalculateOnBarClose = false", TextPosition.TopRight);
        			
        else
        {
        RemoveDrawObject("errorHandling");
        		
        //do the rest of your strategy logic here
        	
        }
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by scottreynolds View Post
          Is it possible to have my strategy disable the setting in the user interface to prevent the user from changing this?
          You cannot disable it in the user interface, but COBC is a property of the indicator/strategy, so you can override it.

          I usually do it on OnStartUp(), as that is more efficient; it is done once at the start. It can also be done in OnBarUpdate(), but then of course, you pay the (admittedly piddling) penalty of running that instruction on every tick. A small penalty to be sure, but I prefer to incur no penalties, unless I cannot help it. Just my coding style.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          65 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          149 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          99 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          286 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X