Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

When to use TriggerCustomEvent

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

    When to use TriggerCustomEvent

    I'm raising a number of my own events from inside the OnBarUpdate handler. I can't hook into the bar update event directly as it makes my suite of 200 unit tests unusable for reasons I've described in a previous post about unit testing. So I'm raising my own events and EventArgs to allow me to keep true separation.

    My question is. If I am raising a custom event from inside an NT Event Handler, do I need to use the RaiseCustomEvent method to synchronise pointers etc? My guess is that all this would be done already prior to the BarUpdateEvent being raised and thefore its not necessary for me to use TriggerCustomEvent - is this a correct assumption?

    Thank you

    #2
    Hello reach4thelasers,

    In C# you don't really have to worry about pointers.

    Also, there is not a RaiseCustomEvent() method available to NinjaScripts.

    Attached is an example of calling a custom method from a timer. You may find this helpful.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hey Chelsea... Sorry I meant TriggerCustomEvent:



      I realise that C# being memory managed doesn't utilise pointers like C or C++ : I presume the docs for TriggerCustomEvent which refer to " internal NinjaScript indexes and pointers" is actually meaning references as opposed to low-level address pointers...

      I have seen some peculiar behavior when triggering chart click events which did not produce expected bar data. Running TriggerCustomEvent prior to processing the handler resolved this.

      As part of resolving the previous issue I made a Generic version of the TriggerCustomEvent and shared it on the post: http://ninjatrader.com/support/forum...ad.php?t=78078 I'm just not entirely sure exactly where and when this is required. Clearly from previous experience its required on mouse/keyboard input events, and obviously timer events.

      I'm working on a pretty complex strategy. Its got 4 parallel data processing pipelines that processes HLOCV data for multiple time-frames and three orthogonal pipelines that serve the main data processors which analyse curve, trend, risk and profit. I'm using an event aggregator built using Structuremap - so that I can take new data from OnBarUpdate and call eventAggregator.Dispatch(new IntermediateTimeFrameBarData(...)) and it sends it to the correct pipeline for processing - it all works great.

      I'd just like to know.... if I am triggering an event of my own making from within OnBarUpdate, do I still need to run TriggerCustomEvent? Or are all the "Internal Ninjascript Indexes and Pointers" already set up for me at that stage? I think they are but would like to seek clarification.

      Comment


        #4
        Hello reach4thelasers,

        This depends on whether you want your method synced to a bar series.

        In my example, I'm not using TriggerCustomEvent() because I have no need to sync this with a bar series.

        In other words, if you plan on calling bar information from the method, it is best to use TriggerCustomEvent().
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X