Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problems with Draw.Text and Draw.Line

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

    Problems with Draw.Text and Draw.Line

    So I'm almost done with converting my first indicator to NT8 but these two methods are giving me trouble:

    Code:
    Draw.Text(barname + " Price", true, lowPrice.ToString(), 0, lowPrice, 8, sellColor, textFont, StringAlignment.Near, Brushes.Transparent, Brushes.Transparent, 0);
    Draw.Line(barname + " Line", true, 0, lowPrice, - (ExpireNL), lowPrice, sellColor, DashStyle.Dot, 2);
    Errors:

    NinjaScript File Error Code Line Column
    NetLines.cs The name 'StringAlignment' does not exist in the current context CS0103 122 115

    NinjaScript File Error Code Line Column
    NetLines.cs 'System.Windows.Media.DashStyle' does not contain a definition for 'Dot' CS0117 123 98

    I don't see anything in the code breaking changes that would prevent this from compiling. Any ideas?

    FYI - if I use System.Drawing.Drawing2D then I'm getting a slew of other errors, so my guess is that this shouldn't be done. Any thoughts?
    Attached Files

    #2
    Originally posted by molecool View Post
    So I'm almost done with converting my first indicator to NT8 but these two methods are giving me trouble:

    Code:
    Draw.Text(barname + " Price", true, lowPrice.ToString(), 0, lowPrice, 8, sellColor, textFont, StringAlignment.Near, Brushes.Transparent, Brushes.Transparent, 0);
    Draw.Line(barname + " Line", true, 0, lowPrice, - (ExpireNL), lowPrice, sellColor, DashStyle.Dot, 2);
    Errors:

    NinjaScript File Error Code Line Column
    NetLines.cs The name 'StringAlignment' does not exist in the current context CS0103 122 115

    NinjaScript File Error Code Line Column
    NetLines.cs 'System.Windows.Media.DashStyle' does not contain a definition for 'Dot' CS0117 123 98

    I don't see anything in the code breaking changes that would prevent this from compiling. Any ideas?

    FYI - if I use System.Drawing.Drawing2D then I'm getting a slew of other errors, so my guess is that this shouldn't be done. Any thoughts?
    Your calling signatures are completely wrong. The NT Help gives the correct syntax. There is no overlap in syntax between NT7 draw methods and NT8 draw methods.
    Last edited by koganam; 05-25-2015, 09:56 AM. Reason: Corrected spelling.

    Comment


      #3
      Originally posted by koganam View Post
      Your calling signatures are completely wrong. The NT Help gives the correct syntax. There is no overlap in syntax bewtween NT7 draw methods and NT8 draw methods.
      Alright, I'll take a look at the new signatures. Skimmed over them but was expecting them to be the same.

      Do I still have to import System.Drawing.Drawing2D?

      Phew... quite a lot of work converting all that!
      Last edited by molecool; 05-25-2015, 09:58 AM.

      Comment


        #4
        Hello molecool,

        Thank you for your post.

        Koganam refers to the NT 8 help guide, refer to this for the syntax for the drawing tools in your code.

        Comment


          #5
          Originally posted by NinjaTrader_PatrickH View Post
          Hello molecool,

          Thank you for your post.

          Koganam refers to the NT 8 help guide, refer to this for the syntax for the drawing tools in your code.
          Yup, looking at that one already - just an oversight on my part. Question: Do I still have to import System.Drawing.Drawing2D?

          Comment


            #6
            Wait a minute

            Just looked at Draw.Text and I seem to be calling it correctly:

            Draw.Text(barname + " Price", true, lowPrice.ToString(), 0, lowPrice, 8, sellColor, textFont, StringAlignment.Near, Brushes.Transparent, Brushes.Transparent, 0)

            See here:



            Draw.Text(NinjaScriptBase owner, string tag, bool isAutoScale, string text, int barsAgo, double y, int yPixelOffset, Brush textBrush, SimpleFont font, StringAlignment alignment, Brush outlineBrush, Brush areaBrush, int areaOpacity)

            Here's the method sig from NT7:

            DrawText(string tag, bool isAutoScale, string text, int barsAgo, double y, int yPixelOffset, Color textColor, SimpleFont font, StringAlignment alignment, Color outlineColor, Color areaColor, int areaOpacity)

            FYI - I added 'this' as the owner and am still getting the same errors.



            So this doesn't explain the error I'm getting.
            Last edited by molecool; 05-25-2015, 10:17 AM.

            Comment


              #7
              Originally posted by molecool View Post
              Just looked at Draw.Text and I seem to be calling it correctly:

              Draw.Text(barname + " Price", true, lowPrice.ToString(), 0, lowPrice, 8, sellColor, textFont, StringAlignment.Near, Brushes.Transparent, Brushes.Transparent, 0)

              See here:



              Draw.Text(NinjaScriptBase owner, string tag, bool isAutoScale, string text, int barsAgo, double y, int yPixelOffset, Brush textBrush, SimpleFont font, StringAlignment alignment, Brush outlineBrush, Brush areaBrush, int areaOpacity)

              So this doesn't explain the error I'm getting.
              Missing. You must specify it. Usually "this".

              Comment


                #8
                Originally posted by koganam View Post
                Missing. You must specify it. Usually "this".
                You beat me to the punch. However, I did add 'this' as the owner already but it's still throwing the same errors... :-(

                Code:
                Draw.Text(this, barname + " Price", true, lowPrice.ToString(), 0, lowPrice, 8, sellColor, textFont, StringAlignment.Near, Brushes.Transparent, Brushes.Transparent, 0);
                Draw.Line(this, barname + " Line", true, 0, lowPrice, - (ExpireNL), lowPrice, sellColor, DashStyle.Dot, 2);
                Attached Files

                Comment


                  #9
                  The plot thinnens

                  So I tried adding 'System.Drawing' per:



                  Unfortunately then I get all kinds of conflicts.

                  So I wasn't really calling the methods completely wrong - I just had left out the owner which is 'this'. The problem remains that StringAlignment and DashStyle are not being recognized. Perhaps it's those imports but if I add them (Drawing and Drawing2D) I get a host of other conflicts - please see screen errors in attached images below.
                  Attached Files

                  Comment


                    #10
                    Originally posted by molecool View Post
                    So I tried adding 'System.Drawing' per:



                    Unfortunately then I get all kinds of conflicts.

                    So I wasn't really calling the methods completely wrong - I just had left out the owner which is 'this'. The problem remains that StringAlignment and DashStyle are not being recognized. Perhaps it's those imports but if I add them (Drawing and Drawing2D) I get a host of other conflicts - please see screen errors in attached images below.
                    DashStyle is supposed to be fully qualified: System.Drawing.Drawing2D.DashStyledashStyle

                    You may be missing the necessary namespace for StringAlignment. The namespaces used by NT8 are quite different. Try generating a new class, then use it to test, and if necessary correct the namespace using statements in your current class.
                    Last edited by koganam; 05-25-2015, 10:56 AM.

                    Comment


                      #11
                      Originally posted by koganam View Post
                      DashStyle is supposed tgo be fully qualified: System.Drawing.Drawing2D.DashStyledashStyle
                      Thanks mate - now it compiles. I think we should add a few examples to the documentation as this is something easy to trip over. Many folks will try what I did - add the packages as imports which then causes conflicts with the System.Windows.Media stuff.

                      Alright, now let's see if the indicator actually works ;-)

                      Comment


                        #12
                        How do you like them apples?

                        See enclosed - my first NinjaTrader8 indicator :-)
                        Attached Files

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by gravdigaz6, Today, 11:40 PM
                        1 response
                        7 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Started by MarianApalaghiei, Today, 10:49 PM
                        3 responses
                        10 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Started by XXtrader, Today, 11:30 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post XXtrader  
                        Started by love2code2trade, Yesterday, 01:45 PM
                        4 responses
                        28 views
                        0 likes
                        Last Post love2code2trade  
                        Started by funk10101, Today, 09:43 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post funk10101  
                        Working...
                        X