Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnBar update and maximizing processor

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

    OnBar update and maximizing processor

    I dont want to run my indicators on bar close as I want to see the effect in real time,

    As some are volume based.

    Questions

    1) OnBarupdate is triggered every new trade?

    2) if I have 3 indicators per chart and 5 charts, I will be updateing alot

    3) Which of the 2 codes I use to stall the OnbarUpdates works best, most efficient.

    Has anybody any code design to make NT run better if you dont want calc on bar close.



    Code:
            protected override void OnBarUpdate()
            {
                if (Historical == true)
                {    
                 // Data and code here       
                }    
            
            
            
                if (Historical == false && runonce==false)    
                {
    // Initiate our Timer object with an interval of 1000ms (1 second)
                    myTimer.Tick += new EventHandler(TimerEventProcessor);
                    myTimer.Interval = 500;
                    myTimer.Start();
                    runonce=true;                
                }
            }    
    // Timer's tick event handler. Called at every tick of 1000ms.
            private void TimerEventProcessor(Object myObject, EventArgs myEventArgs)
            {
                TriggerCustomEvent(MyCustomHandler, 0, myTimer.Interval);
            }
            
            private void MyCustomHandler(object state)
            {

    // simpler timing code
    Code:
           
     if (DateTime.Now.TimeOfDay.TotalMilliseconds>=timerdelay &&(Historical)==false)    
                {                
            timerdelay=(DateTime.Now.AddMilliseconds(500).TimeOfDay.TotalMilliseconds);      
    }
    else if((Historical)==true)
    {
    //code here
    }

    #2
    Hello,

    Thank you for your note.

    NinjaTrader is event driven and requires ticks to drive those events. OnBarEvent occurs on the close of the bar and not every tick. If you want an indicator to run on every tick this would be COBC = False.

    However, you can have the best of both worlds. Here would be the supported way to do this:

    FirstTickOfBar



    You would run your indicator in COBC = false mode and then the indicator logic you want to calculate only on the bar close you would put inside of this if(FirstTickOfBar) check.

    Then run other code you want to update on every tick outside of this.

    The best fo both worlds if you will.
    BrettNinjaTrader Product Management

    Comment


      #3
      Understand that, but I think there is a place for a timer update, lets say update on bar close, and then every 500ms, inline with screen update, processing every tick on many charts even just to say "no not yet" is problematic.

      Comment


        #4
        Hello,

        NinjaTrader is not timer based it is only event driven from ticks. Using timers in your indicators unfortunately would be unsupported.

        Let me know if I can be of further assistance.
        BrettNinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        629 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        364 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        564 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X