• 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

Event handling in My Code

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

    Event handling in My Code

    Hello,

    I created a class with a list of properties to store values in my indicator. I created an instance of the class, and started assigning values to these properties. I decided it would be very useful to employ a property changed event in my class, so that when any of the properties are changed in my instance I can have my instance subscribe the the event and handle the event. I subscribed to the event (added the handler method to the event delegate using +=) in the initialize method. I put my event handler just before the OnBarUpdate method. Is this the correct place for these elements to go in my indicator, or would you recommend a different location for these? I'm having issues getting my event to fire, and I'm thinking I just don't have things in the right place.

    #2
    Hello CaptainAmericaXX, and thank you for your question.

    C# is a near superset of C. This means that your code is location independent. You can verify this by moving your OnBarUpdate method physically above your Initialize routine. When you compile, you will notice that your indicator's function has not been changed. Physical position is only important within a method. You do not have control over when OnBarUpdate is being added to Ninja's internal event dispatchers.

    If you would like to implement a PropertyChanged handler, I would recommend the approach taken in this publicly available MSDN reference,

    https://msdn.microsoft.com/en-us/library/ms743695.aspx

    You can do this in NinjaTrader by modifying your property's set method to hook into your handler with whatever message you would like to pass to it.

    Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by TazoTodua, Today, 01:26 AM
    0 responses
    1 view
    0 likes
    Last Post TazoTodua  
    Started by TazoTodua, Today, 01:21 AM
    0 responses
    1 view
    0 likes
    Last Post TazoTodua  
    Started by TikDaddy, Yesterday, 02:08 PM
    3 responses
    11 views
    0 likes
    Last Post TikDaddy  
    Started by Brillo, Yesterday, 01:52 PM
    1 response
    16 views
    0 likes
    Last Post NinjaTrader_Jim  
    Started by TazoTodua, 02-09-2018, 08:40 AM
    10 responses
    884 views
    0 likes
    Last Post NinjaTrader_JoshG  
    Working...
    X