Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 CortexZenUSA, Today, 12:53 AM
          0 responses
          1 view
          0 likes
          Last Post CortexZenUSA  
          Started by CortexZenUSA, Today, 12:46 AM
          0 responses
          1 view
          0 likes
          Last Post CortexZenUSA  
          Started by usazencortex, Today, 12:43 AM
          0 responses
          5 views
          0 likes
          Last Post usazencortex  
          Started by sidlercom80, 10-28-2023, 08:49 AM
          168 responses
          2,265 views
          0 likes
          Last Post sidlercom80  
          Started by Barry Milan, Yesterday, 10:35 PM
          3 responses
          11 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X