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

Error on Ninjascript

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

    Error on Ninjascript

    Hi,
    I have created a strategy using ninjascript.

    I need to use queue in c#, to deal with a collection of objects.

    Using System.Collections.Generic.Queue ;

    I am getting no error compiling the code,
    but when applying strategy to instrument, i am getting a message ,

    "Failed to execute DB job 'StrategyUpdateJob' There was an error reflecting type NinjaTrader.Strategy.abc': You must implement a default accessor on 'System.Collections.Generic.Queue' some so sand so ,, because it inherits from ICollection."

    Also, i am getting some crap output when i try to access the queue and print the elements in it.
    Could you please tell how to resolve this, and why i am gettnig this error.
    No error @ compiler

    #2
    Nemesis45,

    Thank you for your post.

    What does the full error message say?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Failed to execute DB job 'StrategyUpdateJob': There was an error reflecting type 'Ninjatrader.Strategy.GetBuySellPrintwithclasses'. You must implement a default accessor on System.Collections.Generic.Queue `1[[NinjaTrader.Strategy.Prints,ae3784a509af429fb375c8 f8dc5f6297, Version= 7.0.1000.22, Culture=neutral,PublickeyToken=null]] because it inherits from ICollection.

      This is the full message

      Comment


        #4
        Nemesis45,

        Thank you for that information.

        What are you trying to accomplish with creating an ICollection?

        Can you post a sample of how you are implementing this in your script?
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          hi

          I am processing data, obtained from OnMarketUpdate(), putting it into a queue.

          then, i need to perform a few operations on the data, which i am doing in OnBarUpdate()
          I have added a time series object using Add(PeriodType.Second,1)
          so that i can process my queue every second.

          In OnBarUpdate(), i need to use an enumerator to process the queue.

          Comment


            #6
            Nemesis45,

            Please note that this type of programming is not supported by NinjaTrader. However, are you using an ICollection object for your querying? You may want to use this kind of object for what you are trying to do.

            There are some debugging tools available such as Print() and DrawObjects()

            Debugging your script - http://www.ninjatrader.com/support/f...ead.php?t=3418

            Additionally, you may want to use a Timer event instead of the Add() for 1 second as if there is no ticks of data coming in, your script won't run the OnBarUpdate event.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Cal View Post
              Nemesis45,

              Please note that this type of programming is not supported by NinjaTrader. However, are you using an ICollection object for your querying? You may want to use this kind of object for what you are trying to do.

              There are some debugging tools available such as Print() and DrawObjects()

              Debugging your script - http://www.ninjatrader.com/support/f...ead.php?t=3418

              Additionally, you may want to use a Timer event instead of the Add() for 1 second as if there is no ticks of data coming in, your script won't run the OnBarUpdate event.
              Could you please specify, what kind of programming is that?
              I cant put objects into a queue? or is there a problem with accessing the queue.

              I have used Print() often for debugging, but this is something beyond the scope of debugging.

              I am using the class Queue , as in
              private Queue<Object type> queue1 = new Queue<objecttype>() ;

              and then putting the objects in the queue

              Isnt this fairly basic?
              Thank you for the suggestion to use a timer. I had overlooked that fact.

              using System.Collections.Generic;
              I have added this to my using declarations.

              Can i use file I/O with ninjatrader? i will need to write this data onto something.. database or a file or a queue.

              Comment


                #8
                Nemsis45,

                We don't have any documentation on using the Queue inside of NinjaScript.

                What object type are you using inside your script for the data from OnMarketData()?

                Can you post a sample script of how you are doing this?

                Yes, you can use System.IO to write to a text file.
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  public class Prints: Strategy

                  These are the variables in the class Prints

                  private double printstart ;
                  private double printend ;
                  private long printvol;
                  private TimeSpan printtime ; // no of hh/mm/ss in print
                  private DateTime timestamp ;

                  The queue is a queue of a few prints.
                  I could manually implement a stack/queue, if using system.collections is a problem.
                  Just wanted to know if there will be a problem allocating/ deallocating memory?
                  Could you please share the limitations of ninjatrader programming.
                  can i add onto the using namespace?

                  I could share the code, but dont want it to be public.

                  Comment


                    #10
                    Nemsis45,

                    Can you send me the script that you are working with to support[at]ninjatrader[dot]com
                    Put ATTN Cal in the subject and a reference to this thread in the body.
                    Cal H.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks a lot, just saved my code!
                      Excellent support for NinjaTrader

                      Comment


                        #12
                        hi

                        Originally posted by NinjaTrader_Cal View Post
                        Nemesis45,

                        Additionally, you may want to use a Timer event instead of the Add() for 1 second as if there is no ticks of data coming in, your script won't run the OnBarUpdate event.
                        Just noticed that if CalculateOnBarClose = false, I cant use OnBarUpdate(), as a timer, since it is being called for each incoming tick.

                        Could you please tell me how to use a timer event?
                        I dont see a timer() in alphabetical reference.

                        I can always implement one using TimeSpan object, is there another way to do it inside of ninjascript?

                        Thanks

                        Comment


                          #13
                          Yes, you could use a Timer to trigger a custom event, please check into this reference on the topic - http://www.ninjatrader.com/support/f...ead.php?t=5965
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            Thanks, the timer i need will be executed every second.
                            Would it save processing if i simply use a TimeSpan object? or a custom trigger

                            Comment


                              #15
                              Generally there would be an overheard compared to just quering DateTime.Now, however for one timer I wouldn't really be concerned.
                              BertrandNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by pechtri, 06-22-2023, 02:31 AM
                              9 responses
                              122 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by frankthearm, 04-18-2024, 09:08 AM
                              16 responses
                              65 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by habeebft, Today, 01:18 PM
                              1 response
                              5 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by benmarkal, Today, 12:52 PM
                              2 responses
                              13 views
                              0 likes
                              Last Post benmarkal  
                              Started by f.saeidi, Today, 01:38 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Working...
                              X