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 executing DB command....

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

    Error on executing DB command....

    Hello.
    I am developing a strategy.
    I have been building codes for calculations, and have been advancing with no compilations errors.
    But now, developing the adition of entries and exits, I see in the Log tab :

    "Error on executing DB command: System.InvalidOperationException:There was an error reflecting type
    'NinjaTrader.NinjaScript.Strategies.mts66' -> System.InvalidOperationException:
    Cannot serialize member'NinjaTrader.Ninjascript.Strategies.mts66.SK _dim0 of type 'NinjaTrader.NinjaScript.Series'...

    In this message, mts66 is the name of this strategy,
    and SK_dim0 is an ISeries<double>

    In my code I have defined :

    public Series<double> SK_dim0;
    ...
    SK_dim0= new Series<double>(BarsArray[0],MaximumBarsLookBack.Infinite);
    ...
    In OnBarUpdate() I do:
    SK_dim0[0] = Math.Round(S_dim0.K[0],2); // S_dim0 is the StochasticsFast variable

    Before adding orders for entries and exits, the code for calculations of this StochasticsFast had no compilation errors, Printing values correctly....

    But now, adding orders ( entries and exits code...) I have this error.
    I have reset the DB, restart Ninja, but the error appears again....
    I donīt find why it happens.




    #2
    Hello Parmenides48,

    Thank you for the question.

    This would be due to the public series missing the XmlIgnore attribute for the serialization error however I am unsure if that also relates to the DB command error.

    Could you make sure any public series you have defined are in the following format?

    Code:
            [B][Browsable(false)]
            [XmlIgnore][/B]
            public Series<double> MyPublicSeriesName
            {
                get { return myPrivateSeriesName; }    
            }
    You can find an example of this concept here: https://ninjatrader.com/support/help...alues_that.htm

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello,
      I donīt have used that code you send me,
      I have to learn about attributes , I didnīt use that ...
      but this error only appears now, when I add code for entries and exit orders.
      Before that , I didnīt have any problems with all the ISeries that I created.
      I did differents Prints to see values and calculations about that ISeries,
      I didnīt have compilations errors and have seen that the values were well calculated....

      Comment


        #4
        Hello Parmenides48,

        While I can't say what may have happened in your script as you used unique syntax, I can point to the resources which show how to execute this concept correctly. The attributes used in this example prevent the platform from trying to save the series to xml which it cannot. Without the attribute, you would generally receive the error you had surrounding serialization. The series also does not need to be exposed as a user input which is the purpose of browsable false.

        Please let me know if I may be of additional assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hello,
          I am going to learn about attributes , how to code ISeries correctly, and make some tests ......
          Thanks a lot.

          Comment


            #6
            Hello again,
            here is a simple code showing how I code ISeries for StochasticsFast.K values.
            I create ISeries for StochasticsFast.k values, to hold that values with only 2 decimals.
            Running this simple sample strategy in CL futures,
            I don't in the log tab the error " on executing DB command...."
            I have correctly code that ISeries ?
            ISeriesTest.cs

            Comment


              #7
              Hello Parmenides48,

              Thank you for your reply.

              The script seems to be correct based on how we document this in the help guide and the sample I had provided. I just wanted to confirm, you are saying that you no longer see the error, and are just asking to see if this looks correct, is that right?

              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Hello,
                yes I don't see the error in the Log tab.
                But there are the same error with another strategy much more long ( +1200 lines...),
                with much more ISeries created exactly in the same way as in this sample code sent before,
                appearing the error DB command with some ISeries....
                I have solved that error just changing all that ISeries to simple double variables.
                And now has completely dissapeared the error message.
                the strategy do the same purpose with simple variables and run without errors.
                Then, I think that there are some mistake with ISeries,
                I can think that I have coded ISeries well, but the error is there...,then, I would have to code something else,
                and I have to investigate more about that.

                Comment


                  #9
                  Hello Parmenides48,

                  Thank you for your reply.

                  In the case of the other script, you will likely need to debug that script to see where the problem is coming from in that use case. This may involve reducing the code or making it smaller to find the problem. The details provided would not be specific enough for me to say what may have happened there.

                  I look forward to being of further assistance.
                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    I will work on it, debugging and trying to find the solution of "the mistery of ISeries"...
                    Thanks for your help.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by alifarahani, Today, 09:40 AM
                    6 responses
                    38 views
                    0 likes
                    Last Post alifarahani  
                    Started by Waxavi, Today, 02:10 AM
                    1 response
                    17 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by Kaledus, Today, 01:29 PM
                    5 responses
                    14 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by Waxavi, Today, 02:00 AM
                    1 response
                    12 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by gentlebenthebear, Today, 01:30 AM
                    3 responses
                    17 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X