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, 11: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 asgandabdoil, Yesterday, 10:48 PM
          0 responses
          3 views
          0 likes
          Last Post asgandabdoil  
          Started by asgandabdoil, Yesterday, 10:47 PM
          0 responses
          5 views
          0 likes
          Last Post asgandabdoil  
          Started by soon123, Yesterday, 07:37 PM
          2 responses
          11 views
          0 likes
          Last Post s.kinra
          by s.kinra
           
          Started by MKV17, Yesterday, 07:16 PM
          0 responses
          7 views
          0 likes
          Last Post MKV17
          by MKV17
           
          Started by BrennanSalibrici, Yesterday, 07:03 PM
          0 responses
          4 views
          0 likes
          Last Post BrennanSalibrici  
          Working...
          X