• 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 Guru73, Today, 02:47 AM
        1 response
        6 views
        0 likes
        Last Post Guru73
        by Guru73
         
        Started by pjsmith, Today, 02:44 AM
        0 responses
        5 views
        0 likes
        Last Post pjsmith
        by pjsmith
         
        Started by dalebru, Today, 01:51 AM
        1 response
        8 views
        0 likes
        Last Post bltdavid  
        Started by Austiner87, Yesterday, 09:33 PM
        0 responses
        12 views
        0 likes
        Last Post Austiner87  
        Started by HiddenPhilosopher, Yesterday, 07:24 PM
        0 responses
        13 views
        0 likes
        Last Post HiddenPhilosopher  
        Working...
        X