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

Calling values from Other Incicators

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

    Calling values from Other Incicators

    Dear Support, Hi

    In converting NT7 to NT8, this working NT7 line code below assigns the K[0] value to the int xle:

    int xle = Stochastics(Input, PeriodD, PeriodK, Smoothing).K[0]

    However, when compiled under NT8 I get the following error:

    "NinjaTrader.NinjaScript.Indicator.Stochastics " is a"type" but is used as "variable" "- CS0118

    The above code works fine in NT7. I could not find any information in support documents.

    What is the correct NT8 conversion of the above NT7 line code?

    Many thanks.
    Last edited by aligator; 09-23-2016, 01:27 PM.

    #2
    Hello aligator,

    Thanks for your post.

    You might want to check that the error message relates to that particular line as I don't get that here. What I do get is an error that you cannot implicitly convert type double to int. The stochastics output is a double.

    Assuming that PeriodD, PeriodK and Smoothing are correctly defined you would need to change the variable xle to a double

    double xle = Stochastics(Input, PeriodD, PeriodK, Smoothing).K[0];
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Paul View Post
      Hello aligator,

      Thanks for your post.

      You might want to check that the error message relates to that particular line as I don't get that here. What I do get is an error that you cannot implicitly convert type double to int. The stochastics output is a double.

      Assuming that PeriodD, PeriodK and Smoothing are correctly defined you would need to change the variable xle to a double

      double xle = Stochastics(Input, PeriodD, PeriodK, Smoothing).K[0];
      Thank you Paul.

      Actually, the code I attached was an example of similar code that causes the error. Specifically, the actual indicator to be converted is the May2013SC.zip createated by RyanM of NT. The zip file includes two indicators. The first one (HSBasicDef called by the second indicator) converts to NT8 smoothly. The second one HSIdentify is the culprit that generates error similar to above code when converted using the conversion script provide on this Forum.

      Sometimes ago I had asked RyanM from NT to covert these indicators to NT8. I have never heard back from him.

      My attempt using the conversion tool shows very little effort is needed to convert May2013SC.zip to NT8 with a knowledge of NT8 programming.

      The May2013SC.zip is in NT7 download section. Perhaps a quick look at any of the Lines 57 through 63 of HSIdentify.cs will be a great help to determine the cause for the error.

      btw, using double instead of int did not resolve the issue. I have attached your May2013SC.zip.

      Many thanks.
      Attached Files
      Last edited by aligator; 09-23-2016, 06:41 PM.

      Comment


        #4
        Hello aligator,

        Thank you for your response.

        We are already converting this on our end. It will be uploaded to the forum when we have completed it. If you are still looking to convert this yourself then please post your full code so we may investigate this matter further.

        Comment


          #5
          Originally posted by NinjaTrader_PatrickH View Post
          Hello aligator,

          Thank you for your response.

          We are already converting this on our end. It will be uploaded to the forum when we have completed it. If you are still looking to convert this yourself then please post your full code so we may investigate this matter further.
          Thank You PatrickH,

          Here are the converted May2013SC files for NT8. I figured out the kink and both files included in May2013SC ( HSBasicDef and HSIdentify) are now converted and compiled fine. However, the HSBasicDef generates the following error:

          "value of property "Period" of NinjaScript "MAX" is 0 and not in valid range between 1 and 2147483647"

          As far as I can see there no places in the code that a value of Period for MAX has been assigned as zero. I can not figure out how this error is generated. But if fixed, the second indicator should work fine and ready to go.

          Thanks a bunch
          Attached Files

          Comment


            #6
            Hello aligator,

            Thanks for your post.

            The error message is advising that the period of the method MAX() is not an acceptable value.
            Reference: http://ninjatrader.com/support/helpG...aximum_max.htm

            It appears that the period for the MAX() method is being calculated in several lines. You can debug by printing out the various period calculations.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Paul View Post
              Hello aligator,

              Thanks for your post.

              The error message is advising that the period of the method MAX() is not an acceptable value.
              Reference: http://ninjatrader.com/support/helpG...aximum_max.htm

              It appears that the period for the MAX() method is being calculated in several lines. You can debug by printing out the various period calculations.
              Thanks for reply Paul,

              The original NT7 indicator HSBasicDef.cs developed by RyanM does not have this error. The indicator converts smoothly to NT8 using the conversion script posted in the forum and compiles fine. However, this error appears in NT8 version only. I can't see from print what the issue is.

              Thanks.

              Comment


                #8
                Hello aligator,

                Thanks for your post.

                As the indicator compiles successfully but errors when running indicates that some calculation is producing a result that is in error during the run operation. This is where you follow debugging steps typically consisting of print statements to help understand where the code stops and what the values were. From there you back up in the code to understand why the value is being produced and adjust as needed. Easy to say, difficult to do but is part of the coding / debugging process.

                In this case, the system is advising that the period value of the Max() method is being miscalculated to an unacceptable number. I would advise to add print statements before and after each MAX() statement and include any variables used in the MAX() that would relate to the period.

                Alternatively, as Patrick has advised, the indicator is in process of being converted and will be uploaded when completed. I do not know when that will be.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Paul View Post
                  Hello aligator,

                  Thanks for your post.

                  As the indicator compiles successfully but errors when running indicates that some calculation is producing a result that is in error during the run operation. This is where you follow debugging steps typically consisting of print statements to help understand where the code stops and what the values were. From there you back up in the code to understand why the value is being produced and adjust as needed. Easy to say, difficult to do but is part of the coding / debugging process.

                  In this case, the system is advising that the period value of the Max() method is being miscalculated to an unacceptable number. I would advise to add print statements before and after each MAX() statement and include any variables used in the MAX() that would relate to the period.

                  Alternatively, as Patrick has advised, the indicator is in process of being converted and will be uploaded when completed. I do not know when that will be.
                  Thank you Paul,

                  I do not want to drag this on for too long, but the print statements only gives the MAX value and the chart Bar # for the 3 instances of MAX without the Line # location in the code where error is generated. So, its not easy to spot the code lines causing the error.

                  Thank you again for you help.

                  Comment


                    #10
                    Originally posted by aligator View Post
                    Thank you Paul,

                    I do not want to drag this on for too long, but the print statements only gives the MAX value and the chart Bar # for the 3 instances of MAX without the Line # location in the code where error is generated. So, its not easy to spot the code lines causing the error.

                    Thank you again for you help.
                    You determine the line where you have an error by also Print()ing out a checkpoint text, (can be the line number for instance).

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by terkk, Today, 01:16 PM
                    4 responses
                    24 views
                    0 likes
                    Last Post bltdavid  
                    Started by TraderElegante, Today, 12:14 PM
                    1 response
                    20 views
                    0 likes
                    Last Post NinjaTrader_PaulH  
                    Started by dgee949, Today, 11:44 AM
                    1 response
                    15 views
                    0 likes
                    Last Post NinjaTrader_JustinD  
                    Started by NinjaTrader_Kate, Today, 12:01 PM
                    0 responses
                    21 views
                    0 likes
                    Last Post NinjaTrader_Kate  
                    Started by efeuvejota01, Today, 11:42 AM
                    4 responses
                    38 views
                    0 likes
                    Last Post efeuvejota01  
                    Working...
                    X