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 argusthome, Yesterday, 10:06 AM
          0 responses
          22 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          19 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          14 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          10 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          41 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X