Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Force OnBarUpdate

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

  • WalterSkinner
    replied
    Originally posted by pjsmith View Post
    TriggerCustomEvent(o =>
    {
    OnBarUpdate();
    }, null);

    It runs but does not appear to have the desired effect, in that triggers/actions still seem to wait for an inbound tick. Will debug further when I get time.
    Note that if you're using multiple data series you would update the last line before the comma to include the BIP value/Data series index.

    Originally posted by pjsmith View Post
    I have to relocate all the evaluation code outside of OnBarUpdate, update OnBarUpdate to use those functions instead, and call those functions from the click event, ensuring things are also synced up.

    Exactly what I'm currently googling around to avoid.
    Last edited by WalterSkinner; 01-31-2023, 01:29 PM.

    Leave a comment:


  • pjsmith
    replied
    TriggerCustomEvent(o =>
    {
    OnBarUpdate();
    }, null);

    It runs but does not appear to have the desired effect, in that triggers/actions still seem to wait for an inbound tick. Will debug further when I get time.

    Leave a comment:


  • bltdavid
    replied
    Excellent.

    If you would, please report back to the forum how well it works.

    Good luck!

    Leave a comment:


  • pjsmith
    replied
    Yes, calling OnBarUpdate with triggercustomevent might be a solution if that will work. Thank you.

    No timer. A button on the chart generates an event, sets a flag, and conditions in OnBarUpdate respond to it. I'd prefer those conditions were checked on click of the button, rather than waiting for a tick to come in. I was just looking for a simple workaround (this may be it), rather than re-working a large chunk of code.

    Leave a comment:


  • bltdavid
    replied
    Originally posted by pjsmith View Post
    As I said in my original post, really. What I want to force is, OnBarUpdate. If that cannot be done, I have to relocate all the evaluation code outside of OnBarUpdate, update OnBarUpdate to use those functions instead, and call those functions from the click event, ensuring things are also synced up. Now, this is perfectly possible, but it's a lot of work and could all be avoided with a simple ForceOnBarUpdate() function (if one existed). Get it? I'm, just thinking there must have been a super simple and easy way to do this, but, I guess not.
    So, why can't you use TriggerCustomEvent?

    When the handler is called, just call OnBarUpdate() from the handler.
    Have you tried that?

    If needed, set a flag in your handler, 'IsFakeUpdate = true' so that any
    code in OnBarUpdate that needs to differentiate between your forced
    OnBarUpdate and a normal one can do so.

    But ...
    What I don't understand is, what outer controlling code is going to
    call the TriggerCustomEvent? Are you using a timer?
    Last edited by bltdavid; 01-31-2023, 11:03 PM.

    Leave a comment:


  • NinjaTrader_BrandonH
    replied
    Hello pjsmith,

    That is correct. OnBarUpdate() cannot be forced for ticks that are not there or to fake a tick.

    Let us know if we may assist further.

    Leave a comment:


  • pjsmith
    replied
    As I said in my original post, really. What I want to force is, OnBarUpdate. If that cannot be done, I have to relocate all the evaluation code outside of OnBarUpdate, update OnBarUpdate to use those functions instead, and call those functions from the click event, ensuring things are also synced up. Now, this is perfectly possible, but it's a lot of work and could all be avoided with a simple ForceOnBarUpdate() function (if one existed). Get it? I'm, just thinking there must have been a super simple and easy way to do this, but, I guess not.

    Leave a comment:


  • NinjaTrader_BrandonH
    replied
    Hello pjsmith,

    Thanks for writing in.

    Unfortunately, you cannot force OnBarUpdate() for ticks that are not there or to fake a tick.

    That said, what exactly are you wanting to trigger?

    Are you not able to trigger what you want with button events? If not, why is that?

    If you would like to force things to happen at a certain time without bar updates, you could consider using a timer.

    Note that when triggering things from other events that are not data processing events, (I.E. not OnBarUpdate() or OnMarketData()) you should use TriggerCustomEvent() to make sure BarsAgo references are correct.

    See this help guide page about using TriggerCustomEvent() and a timer: https://ninjatrader.com/support/help...ustomevent.htm

    Let us know if we may assist further.

    Leave a comment:


  • pjsmith
    started a topic Force OnBarUpdate

    Force OnBarUpdate

    Hi,

    So, a fairly common requirement I think, having googled it, but not sure I found my answer.

    Have a lot of Logic in OnBarUpdate and indicator set to OnEachTick (or OnPriceChange), which is normally fine. Tried it on some rather lethargic instruments of late and the updates are not fast enough because the indicator interacts with mouse clicks, etc. from the user. At the moment, it needs an inbound tick to kick things off.

    Now, I read about and tried 'Update()', which I hoped would do the trick, but it does not and it does clearly state in the docs it will be ignored if no bar updates are pending (shame). I could of course separate out all my logic into different functions, re-arrange OnBarUpdate, call things when a click is made, but, this is a large amount of work to overcome a very simple problem.

    So, the question is, how to 'fake' a tick (ala MT4/5!), or force OnBarUpdate to run without waiting for a tick and regardless of if there are bars to update? (praying for a simple function call )

    Thanks.

Latest Posts

Collapse

Topics Statistics Last Post
Started by Mindset, 04-21-2026, 06:46 AM
0 responses
57 views
0 likes
Last Post Mindset
by Mindset
 
Started by M4ndoo, 04-20-2026, 05:21 PM
0 responses
78 views
0 likes
Last Post M4ndoo
by M4ndoo
 
Started by M4ndoo, 04-19-2026, 05:54 PM
0 responses
41 views
0 likes
Last Post M4ndoo
by M4ndoo
 
Started by cmoran13, 04-16-2026, 01:02 PM
0 responses
101 views
0 likes
Last Post cmoran13  
Started by PaulMohn, 04-10-2026, 11:11 AM
0 responses
61 views
0 likes
Last Post PaulMohn  
Working...
X