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

Setting CalculateOnBarClose

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

    Setting CalculateOnBarClose

    Hi,

    In my Initialize() function I set CalculateOnBarClose = true;

    I can print its value and it is correct as I set it, regardless of what value is set in the input parameters.

    However, when I test and print its value in OnBarUpdate() it has changed to the value set in the input parameters.

    What am I doing wrong?

    Thanks,
    Will.

    #2
    Would expect that outcome Will, you're not doing anything incorrect. Initialize() is called for all scripts and before you would see any dynamic input then applied from the UI - OBU is the first place this would be seen.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      You have a couple of choices, in the OnBarUpdate you can do a logic check and reset COBC = true, or you can add the bool FirstTickOfBar to simulate the COBC=true functionality (assuming user has set COBC=false).

      Hope that helps.

      Comment


        #4
        Hi,

        I don't quite understand your reply. Are you saying that I cannot set CalculateOnBarClose programmatically?

        Will.

        Comment


          #5
          Ok, I will try your first solution. This is a forms based indicator and I am not actually using OBU, so my question then would be is the input parameter setting for CalculateOnBarClose set only once, or do I need to check the setting repeatedly?

          Will.

          Comment


            #6
            Originally posted by dontpanic View Post
            Ok, I will try your first solution. This is a forms based indicator and I am not actually using OBU, so my question then would be is the input parameter setting for CalculateOnBarClose set only once, or do I need to check the setting repeatedly?

            Will.
            Not sure I understand your application but what i was trying to communicate was that I believe (as in not 100% certain...) if COBC is set in initialize it would be overridden by the COBC setting in the indicator parameter field as set by the user.

            You should only need to check it once.

            Sorry for any confusion.

            Comment


              #7
              Ok thanks, my indicator uses a windows form and the events are triggered by button pushes not by OBU, but I can work with that.

              The main reason I need to ensure the value of CalcOnBarUpdate is that it seems to affect the returned value of LastBarIndexPainted, which I use for backtesting in the indicator. I will check/set the value of CalcOnBarUpdate before I get the value of LastBarIndexPainted and make sure that its consistent.

              Comment


                #8
                Also note that the NT help file says that CalcOnBarClose should be set in Initialize(), and there is no mention of what happens in OBU to its value.

                Comment


                  #9
                  Originally posted by dontpanic View Post
                  Ok thanks, my indicator uses a windows form and the events are triggered by button pushes not by OBU, but I can work with that.

                  The main reason I need to ensure the value of CalcOnBarUpdate is that it seems to affect the returned value of LastBarIndexPainted, which I use for backtesting in the indicator. I will check/set the value of CalcOnBarUpdate before I get the value of LastBarIndexPainted and make sure that its consistent.
                  I just looked at Initialize in the reference section and since you mentioned that you are using forms, you may want to rethink using the initialize section based on their warning.

                  Initialize()

                  Definition:
                  The Initialize() method is called once when starting a strategy. This method can be used to configure indicator and strategy properties.

                  For example:
                  · Strategies - Call the Add() method to add indicators to charts and to add additional Bars objects to the strategy
                  · Indicators - Set configuration properties such as Overlay and PaintPriceMarkers

                  · Although this method is called once on the start of an indicator or strategy, there are times that this method is also called (Opening an indicator dialog) when you may not expect it to. FOR ADVANCED PROGRAMMERS, DO NOT USE THIS METHOD TO RUN CUSTOM ROUTINES SUCH AS OPENING FORMS, MAKING EXTERNAL CALLS SUCH AS A LICENSE CHECK. PLEASE USE OnStartUp() FOR THOSE PURPOSES.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by jaybedreamin, Today, 05:56 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post jaybedreamin  
                  Started by DJ888, 04-16-2024, 06:09 PM
                  6 responses
                  18 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by Jon17, Today, 04:33 PM
                  0 responses
                  1 view
                  0 likes
                  Last Post Jon17
                  by Jon17
                   
                  Started by Javierw.ok, Today, 04:12 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post Javierw.ok  
                  Started by timmbbo, Today, 08:59 AM
                  2 responses
                  10 views
                  0 likes
                  Last Post bltdavid  
                  Working...
                  X