Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Why code works in one indicator and not in another

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

    Why code works in one indicator and not in another

    Hello Support,
    I am having problems when compiling the code below:-

    if (CrossBelow(Avg, Value, 1))
    {
    // DrawVerticalLine(CurrentBar.ToString(),0,Color.Blu e, DashStyle.Dash,2);
    BackColor = Color.Green;
    // DrawLine(CurrentBar.ToString(), false, 0, 80, 0, 30, Color.Red, DashStyle.Solid, 2);
    }

    BackColor is plotted OK, but when I activate either of the other "actions", the error message is "The name 'DashStyle' does not exist in the current context". Yet, similar code in another indicator compiles and prints OK.

    How can I fix the problem, so that the short line is drawn on the RSI indicator.
    Thank you from Bill R

    #2
    oldhiker,

    Could you possible post more of your code so we may review?
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by oldhiker View Post
      Hello Support,
      I am having problems when compiling the code below:-

      if (CrossBelow(Avg, Value, 1))
      {
      // DrawVerticalLine(CurrentBar.ToString(),0,Color.Blu e, DashStyle.Dash,2);
      BackColor = Color.Green;
      // DrawLine(CurrentBar.ToString(), false, 0, 80, 0, 30, Color.Red, DashStyle.Solid, 2);
      }

      BackColor is plotted OK, but when I activate either of the other "actions", the error message is "The name 'DashStyle' does not exist in the current context". Yet, similar code in another indicator compiles and prints OK.

      How can I fix the problem, so that the short line is drawn on the RSI indicator.
      Thank you from Bill R
      I just cut out and pasted your DrawLine() statements into a dummy indicator for test. They both are correct, as I suspected that they would be. It means that your code is bombing from some other effect; not because your statements are wrong.

      Comment


        #4
        Hello koganam,
        I have attached my file "MyRSI".
        It would appear that "arrows" and "triangles" plot OK - see my comments at the end of each line of code, but it does not like "DashStyle".
        Thank you for your help,
        Bill R
        Attached Files

        Comment


          #5
          Originally posted by oldhiker View Post
          Hello koganam,
          I have attached my file "MyRSI".
          It would appear that "arrows" and "triangles" plot OK - see my comments at the end of each line of code, but it does not like "DashStyle".
          Thank you for your help,
          Bill R
          You some how deleted a line in your Using Declarations Region

          One of these is required.


          using System;
          using System.ComponentModel;
          using System.Diagnostics;
          using System.Drawing;
          using System.Drawing.Drawing2D;
          using System.Xml.Serialization;
          using NinjaTrader.Cbi;
          using NinjaTrader.Data;
          using NinjaTrader.Gui.Chart;
          #endregion

          Comment


            #6
            Hello Sledge,
            Thank you for your speedy reply.
            Your suggestion has corrected the problem. Thank you very much.

            I did not know how I had omitted some of the declarations, as I had just copied the whole code and put it into my file, so I went back to see what had happened.
            As it appears, the RSI code does not have all the necessary declarations to do additional plotting. When I had added the additional declarations, everything worked as expected.

            Another trap for young coders.

            Comment


              #7
              Originally posted by oldhiker View Post
              Hello koganam,
              I have attached my file "MyRSI".
              It would appear that "arrows" and "triangles" plot OK - see my comments at the end of each line of code, but it does not like "DashStyle".
              Thank you for your help,
              Bill R
              It is a wonder that your code even runs at all, seeing how you are not using the NinjaTrader.Cbi namespace at all!

              You somehow lost 3 of the namespaces that NT uses by default in all indicators. I believe that the particular culprit here is the missing use of System.Drawing.Drawing2D.

              In any case, I think you should just restore all 9 namespaces that are being used.
              Last edited by koganam; 06-03-2012, 09:59 PM.

              Comment


                #8
                Hello koganam,
                Yes, I did have some other problems with "Line" styles, and at one stage, it corrupted my main chart.
                As you can see, "sledge" alerted me to the problem, and you can see my reply to where I had made the mistake.
                Thank you both for your help.
                I have rated your replies as excellent, as they always are excellent.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Conceptzx, 10-11-2022, 06:38 AM
                2 responses
                53 views
                0 likes
                Last Post PhillT
                by PhillT
                 
                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  
                Working...
                X