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

System ArgumentException

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

    System ArgumentException

    Hi:

    This code DOES compile, but it acts strange. Ran it through SharpDevelop and saw a System ArgumentException when CMFneg.Set(valueMF) and CMFpos.Set(valueMF) are executed.

    I also noticed that one of the plots always has values while the other has values when appropriate.

    I've attached the code.

    Thanks in advance.
    Attached Files

    #2
    Hello ronb107,

    I have run your script on the ES 06-16 but I was not able to reproduce the error and the script ran without issue.

    A screenshot is attached.

    What instrument are you running this on?
    Are you able to generate the error every time the script is added to a chart?
    Does the error occur immediately after adding the script?
    What is the full text of the error message?
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      System ArgumentException

      Hi Chelsea:

      Yes, it appears to run ok, but the colors do get messed up (it took some experimenting to get it work properly with the right colors).

      If you look at the values on each bar (above and below zero) you will see that two get values together (above zero), and then the wrong one gets a value (below zero).

      When tracing through the code (with SharpDevelp), it showed a System ArgumentException for those two plots.

      Take a closer look and you'll see the problem (I hope).

      Thanks.

      Btw, the color for the bars above zero are supposed to be Lime (not Red); hence, the problem.
      Last edited by ronb107; 03-30-2016, 03:56 PM.

      Comment


        #4
        System ArgumentException

        Chelsea:

        To answer your questions...

        1) the underlying is /ES
        2) the color problem exists even when added to new charts
        - I've also noticed that at times the color remains red for one or two bars when it is above zero
        3) again, the error is noted in SharpDevelop which allows me to look at the objects directly; not in NT7 (it always compiles). The behavior remains unpredictable.

        I appreciate if you (or someone else) could take another (deeper) look.

        Thanks

        Comment


          #5
          Hello ronb107,

          If the exception is not occuring in NinjaTrader you should be able to print the values of any data series.

          I would not be able to assist you in using a 3rd party debugging tool. However, it sounds as if there is no issue with the series as the script is functioning.

          If the script is functioning then its not hitting an error in NinjaTrader.

          I would not be able to tell if the colors are correct or not as I do not know what the logic is that you are trying to code.

          I recommend you use Prints to debug your script.
          In other words, right after you set the value of the plot print the value of the plot.
          Is this value an expected value?
          If not, check your calculation.

          Is valueMF in your print the wrong value? If so, then it was calculated incorrectly.
          Is valueMF the correct value but on the wrong plot, then its being set to the wrong plot.
          Is the value and color not matching? Then something is happening if the branching command.

          Further, the code:
          Code:
          CMFneg.Set(valueMF);
          that is inside of the branching commands where valueMF is less than 0
          Code:
          if (valueMF < 0)
          { PlotColors[0][0] = Color.Red; [B]CMFneg.Set(valueMF);[/B] }
          Is not needed.

          You are calling
          Code:
          Value.Set(valueMF);
          on line 61.

          Value is the same thing as Values[0][0] which means Value is the same thing as CMFneg in your script. In other words, whatever you set CMFneg to in the branching command on line 57 is always ignored because you are always overwriting that value on line 61.

          Further, in the support department at NinjaTrader we do not create, debug, or modify code for our clients. This is so that we can maintain a high level of service for all of our clients as well as our partners. However, this thread will remain open for any community members that would like to debug your code on your behalf.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Chelsea, that solved the problem. Just using one plot and changing the color rather than two plots.

            Thanks

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Kaledus, Today, 01:29 PM
            0 responses
            3 views
            0 likes
            Last Post Kaledus
            by Kaledus
             
            Started by PaulMohn, Today, 12:36 PM
            1 response
            16 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by yertle, Yesterday, 08:38 AM
            8 responses
            37 views
            0 likes
            Last Post ryjoga
            by ryjoga
             
            Started by rdtdale, Today, 01:02 PM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by alifarahani, Today, 09:40 AM
            3 responses
            19 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X