Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question about OnBarUpdate()

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

    Question about OnBarUpdate()

    Here's my code:
    Code:
    protected override void OnBarUpdate()
    {
        // Prints the current bar time stamp
        Print(Time[0].ToString());
    }
    Since CalculateOnBarClose is set to true as default, it's supposed to only print on the close of each bar. However, the output window continuously prints timestamps even the bar is not closed. Am i missing something?

    #2
    Hello misotrader,

    May we have a screenshot of the parameters for this indicator as its set on the chart?
    (So we can confirm that CalculateOnBarClose is set to True)

    Do you have a secondary series added to your script in Initialize()?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Sure

      Comment


        #4
        Hi misotrader,

        Thank you. This screenshot shows that a secondary data series has not been added to the script.

        May we have a screenshot of the parameters for this indicator as its set on the chart?
        Right-click the chart -> select Indicators... -> select the Indicator -> take a screenshot
        (So we can confirm that CalculateOnBarClose is set to True)

        Also, may we have the output from the output window?
        Right-click the Output window -> select Save As... -> give the file a name and save location
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Somehow the chart did not pick up the updated parameter even it's compiled and rerun.
          I explicitly set CalculateOnBarClose to true in chart -> Indicators, now it works!

          Comment


            #6
            Hi misotrader,

            The default values set in Initialize() are only used when adding a new instance of the indicator to the chart. (So that if you change these values, it does not undo your changes)
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            152 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            87 views
            1 like
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            131 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            127 views
            1 like
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            106 views
            0 likes
            Last Post CarlTrading  
            Working...
            X