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

Draw.Text with TextPosition Error

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

    Draw.Text with TextPosition Error

    Guys, we are seeing a problem when trying to import an indicator that uses Draw.Text and allows the user to select the text position with a common input like this:

    [NinjaScriptProperty]
    [Display(Name = "Text Box Position", Description = "Position of text on chart.", GroupName = "Settings", Order = 1)]
    public TextPosition MyTextBoxPosition
    {
    get {return textBoxPosition;}
    set {textBoxPosition= value;}
    }

    where textBoxPosition is a previously defined variable:

    private TextPosition textBoxPosition = TextPosition.BottomRight;

    Importing the protected assembly produces an error message saying "error: CS0246: The type or namespace name 'TextPosition' could not be found..." The same problem (or nearly the same) appears to have been reported on March 16, 2016:



    and Matthew reports then that it was scheduled to be resolved in 'B11 - NTEIGHT-9577'. We can work around it, but is there any resolution to this issue?

    Thanks for your help!

    Light

    #2
    Hello Light,

    I was able to replicate and have passed this on to development.

    Thank you for your report.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Alan. I'll look for the solution in an upcoming release. Until then, we'll use a work-around.

      Thanks again,

      Light

      Comment


        #4
        Hello Light,

        To update you on the issue.

        Using a type which is defined in NT's native Drawing Tool sources such as Text.Position.Bottom right in your code which is being compiled to a protected assembly, should not be done. You should instead create your own source code to prevent the issue, then re-export and provide that file to user.

        Please see the following section of our helpguide,


        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          I ran into the same issue and already read the helpguide section. I wan the same behaviour than Draw.TextFixed. How to implement my own Draw-Method the rigth way. Could you please provide the sourcecode:

          public static class MyDrawCustom
          {

          }

          Comment


            #6
            Hello DarthTraderson,

            I will follow up with you in the morning with an example.

            Thank you for your patience.
            Alan P.NinjaTrader Customer Service

            Comment


              #7
              Hello DarthTraderson,

              Thank you for your patience.

              The following link contains a sample written by Jesse which can be exported as a complied assembly.



              Please let us know if you need further assistance.
              Alan P.NinjaTrader Customer Service

              Comment


                #8
                there should be obviously workaround from NT devs, not from us, creating custom sources for drawingtools or etc.
                Last edited by ttodua; 06-27-2018, 07:45 AM.

                Comment


                  #9
                  Hello TazoTodua,

                  You should not be using types which are defined in NT’s native Drawing Tool sources. You should instead create your own in the code to prevent this issue.

                  See the note in the help guide titled, Exporting custom drawing tools as assembly / DLL


                  Please let us know if you need further assistance.
                  Alan P.NinjaTrader Customer Service

                  Comment


                    #10
                    AlanP.
                    frankly speaking, we can't create our extensive custom codes for just to use Draw.TextFixed in compiled indicators.

                    btw, here is solution: https://trading.codes/tutorials/fix-...-not-be-found/
                    Last edited by ttodua; 02-23-2021, 01:29 AM.

                    Comment


                      #11
                      Hello TazoTodua,

                      Thank you for providing the solution to the forum, this is helpful.

                      Please let us know if you need further assistance.
                      Alan P.NinjaTrader Customer Service

                      Comment


                        #12
                        ttodua,

                        the link to the solution isn't valid anymore.
                        I have the same issue and don't want to rewrite a complete draw library.
                        could you please point out the solution to me?

                        many tanks in advance!

                        Comment


                          #13
                          Hello wjadevries,

                          You can create your own enum property and cast it to NinjaTrader.NinjaScript.DrawingTools.TextPosition.

                          Code:
                          Draw.TextFixed(this, "tag", "Text", (NinjaTrader.NinjaScript.DrawingTools.TextPosition)TextPos);
                          Code:
                          namespace MyEnums
                          {
                              public enum TextPosDLL
                              {
                                  BottomLeft,
                                  BottomRight,
                                  Center,
                                  TopLeft,
                                  TopRight
                              }
                          }
                          I have attached an example.

                          We look forward to assisting.
                          Attached Files
                          JimNinjaTrader Customer Service

                          Comment


                            #14
                            Already phsed out the TextPosition property and introduced my own.

                            But thanks!

                            Comment


                              #15
                              Hello Jim,

                              Wait a sec, an enum can be casted just like that in DLL?!? That would have been SOOO useful to know that. I used enum.parse and had a fun time (not) figuring it out haha.

                              Code:
                              // In this case I was pulling an enum property from a tool template
                              var enumProp = newEnumObject.GetType().GetProperty(newEnum);
                              Enum.Parse(enumProp.PropertyType, xmlNodeList_ENUM[newSelectElementAt].InnerText); //
                              Last edited by Unsuitable; 02-23-2021, 06:13 PM.
                              Unsuitable
                              NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Barry Milan, Today, 10:35 PM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by WeyldFalcon, 12-10-2020, 06:48 PM
                              14 responses
                              1,427 views
                              0 likes
                              Last Post Handclap0241  
                              Started by DJ888, Yesterday, 06:09 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              40 views
                              0 likes
                              Last Post jeronymite  
                              Started by bill2023, Today, 08:51 AM
                              2 responses
                              16 views
                              0 likes
                              Last Post bill2023  
                              Working...
                              X