fh: OnBarUpdate meaning any time during bar life or only at close of bar ?
07.06.2020 13.16

Algorithmic Trading with NinjaTrader


 protected override void OnBarUpdate()

any price change during the lifetime of a bar ?

or only at the end of the bar lifetime ?

  • Yuri Zolotarev
    07.06.2020 17:12

    Please read asking questions guidelines carefully before asking the questions. If you take your time and explain yourself good enough someone on this forum might pay you back by taking their time trying to help you. One of the most important guidelines is:

    "Let us know what your problem is in the most possible detail. This is not a chat, neither a support line, neither a friendly phone call! This is a community, please spend your time researching the question and trying to make the question clear to the public so people can help you.  Let us know what you have done to find out for yourself before asking, what problems did you face, where did you look, what did you find out, why didn't that work for you"

    Thank you for understanding! Let's keep the place healthy and initiative from all sides!

  • Frank
    07.06.2020 17:54

    thx for all answers, solves questions for me I coldn't resolve with the research results I found in Ninja help and MS CSharp, VS sites etc. Google / YouTube. Sometimes, especially when new to it, its great to get an answer in the given context of specific code.

    for the question about the OnBarUpdate(), I wanted to figure if it is triggered also during the lifetime of a bar.

    4exmpl if i have a 1 minute bar, and the price is moving within that minute, is that each an update of the bar per price change ? 

    Or is a bar update only periodically after the bar duration, here 1 minute ?

  • Yuri Zolotarev
    07.06.2020 18:09

    Aha!!! Much better NinjaCoding friend!!!) Once you explain stuff it becomes possible to give you a better answer! By the way, you can fill in your profile and give us a name) anyways, the OnBarUpdate method is called by ninja trader correct on every bar close but only in case if the execution is set to OnBarClose. If execution is set to OnEachTick then the OnBarUpdate method will get called on every single tick that arrives into NinjaTrader. Now, if the execution is set to OnPriceChange then the OnBarUpdate method will get called on every single tick with a NEW price that comes in.

    Hope this helps! 

  • Frank
    07.06.2020 21:30

    aaah now makes click ... its of course about the calc method !

    gotit :))


  • Yuri Zolotarev
    08.06.2020 09:43

    Yes, it is set inside the OnSetDefaults or manually using NinjaTrader UI.