• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom Event in Indicator does not work?

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

    Custom Event in Indicator does not work?

    Hi,

    i tried to create a custom event in my indicator, that should handle buy or sell trigger. I want to use that event in my custom strategy to enter a trade. so that's what i want to do.

    but the problem is, that the custom event handler is always null (not initialized), and i don't know why. i've read several c# tutorials with event handler examples and i did it 1:1 but it does not work.

    is it not possible to create own events in indicators?

    here my short example code:

    Event Handler:
    Code:
            protected virtual void OnEventMessage(EventArgs e)
            {
    	    Print("OnEventMessage ...");
    	    EventHandler handler = EventMessage;
                if (handler != null)
                {				
                    handler(this, e);
    		Print("Handler sent EventMessage ...");
                }
    	    else
    	    {
    		Print("Handler is null @ EventMessage ...");
    	    }
            }
    	
            public event EventHandler EventMessage;
    And the call:
    Code:
    OnEventMessage(EventArgs.Empty);
    The Handler is always null and i don't know how to get it work ...


    Best Regards,
    Tom

    #2
    Hello Tom,

    Thank you for your post.

    You would use the TriggerCustomEvent(): http://ninjatrader.com/support/helpG...ustomevent.htm
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      Thank you Patrick for the link,

      but i don't understand how that should work. how can i register my strategy to the indicators event? the example in the link is working only in the same class i think. or i don't understand the example.

      do you have a short code snippet how to use this TriggerCustomEvent with the use of 2 classes?

      Comment


        #4
        Hello Tom299,

        Attached is an example.
        Attached Files
        Patrick H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by TraderCAD, Today, 04:27 PM
        1 response
        3 views
        0 likes
        Last Post TraderCAD  
        Started by DavidHP, Today, 04:11 PM
        0 responses
        1 view
        0 likes
        Last Post DavidHP
        by DavidHP
         
        Started by alexstox, 03-24-2019, 01:07 PM
        6 responses
        54 views
        0 likes
        Last Post NinjaTrader_PatrickG  
        Started by fredfred, Today, 11:29 AM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_JoshG  
        Started by swcooke, Today, 10:38 AM
        3 responses
        12 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X