• 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 Events

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

    Custom Events

    HI

    I currently wrote a custom event handler. My question deals with the

    TriggerCustomEvent(CustomEvent customEvent, int barsIndex, object state)


    Can you please clarify the nature of the state object. I have tried using an object array, and i have tried isung a strongly-typed list. In both cases the issue seemed to be that indexing was not supported. I have even tried using the ElementAt method with the list but not extension method of that type was provided. Clearly there are some severe restrictions on the nature of the object. Can you please suggest a way to pass more than a simple refernce type as the state? Thank you.

    #2
    Hello Zeos6,

    Object is any object you want to pass to your custom method.

    State is just the variable name used in the example but this is really any thing you want to pass.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you for the response Chelsea but you are not answering the question. If the object is ANY object, as you state, why does it not support an indexer?

      *** EDIT ****

      Figured it out. My apologies Chelsea. It was simply a casting issue on my end. Thank you for the confirmation that the object can be anything.
      Last edited by Zeos6; 03-16-2015, 10:48 AM.

      Comment


        #4
        Hello Zeos6,

        What are you passing this? This will only take an object.

        Below is a link to a microsoft site on the object class.

        https://msdn.microsoft.com/en-us/lib...vs.110%29.aspx

        You could have that object contain a indexer... (by indexer is this a method that sorts something)?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi ChelseaB,

          Thank you for the follow up. I am aware of the object class. I was simply passing a strongly typed list, and was unpacking it via casting. Indexers allow instances of a class, struct, list, etc. to be indexed just like arrays. So a first element of a list called myList can be accessed as myList[0] (or myList.ElementAt(0)).

          My issue was simply that I forgot to cast the object back to a list before accesing it's elements and casting those elements to their respective types.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by faisamtrader, Yesterday, 10:03 PM
          0 responses
          2 views
          0 likes
          Last Post faisamtrader  
          Started by johnnybegoode, Yesterday, 08:11 PM
          0 responses
          2 views
          0 likes
          Last Post johnnybegoode  
          Started by Bionian, Yesterday, 02:47 PM
          2 responses
          21 views
          0 likes
          Last Post Bionian
          by Bionian
           
          Started by RickB60, Yesterday, 01:55 PM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Started by filopearson, Yesterday, 01:18 PM
          6 responses
          11 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X