Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

TextPosition Draw.TextFixed() Method to Custom variable With a Switch/Enum Namespace

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

    TextPosition Draw.TextFixed() Method to Custom variable With a Switch/Enum Namespace

    I'm trying to set the five TextPosition positions in variables for use in a switch statement to use as User Defined parameter in the indicator's properties.

    I get a type error when trying to compile
    NinjaScript File Error Code Line Column
    Testa.cs Member 'CustomEnumNamespace1.TextPositions.BottomLeft' cannot be accessed with an instance reference; qualify it with a type name instead CS0176 271 36
    NinjaScript File Error Code Line Column
    Testa.cs Cannot implicitly convert type 'CustomEnumNamespace1.TextPositions' to 'NinjaTrader.NinjaScript.DrawingTools.TextPosition '. An explicit conversion exists (are you missing a cast?) CS0266 271 36
    What's causing the error? If it's a wrong type, what's the correct type? And how do I formulate it? Thanks!

    The doc seems to indicate the type as TextPosition.
    Syntax

    Draw.TextFixed(NinjaScriptBase owner, string tag, string text, TextPosition textPosition, Brush text Brush, SimpleFont font, Brush outlineBrush, Brush areaBrush, int areaOpacity)
    Draw.TextFixed(NinjaScriptBase owner, string tag, string text, TextPosition textPosition)
    Draw.TextFixed(NinjaScriptBase owner, string tag, string text, TextPosition textPosition, bool isGlo bal, string templateName)
    https://ninjatrader.com/de/support/h..._textfixed.htm
    https://ninjatrader.com/de/support/h.../textfixed.htm
    Class File: public class ServiceAccess { public DataTable GetAllShortCodes() { DataTable ShortCodeTable = new DataTable(); // logic to add data to Datatable return

    https://www.gemboxsoftware.com/prese...tPosition.html



    My switch statement
    PHP Code:
    switch (TextPosition)
    {
         case CustomEnumNamespace1.TextPositions.BottomLeft:
         {
              TextPosition chartPosition = TextPosition.BottomLeft;
              break;
         }
    
         case CustomEnumNamespace1.TextPositions.BottomRight:
         {
              TextPosition chartPosition = TextPosition.BottomRight;
              break;
         }
    
         case CustomEnumNamespace1.TextPositions.Center:
         {
              TextPosition chartPosition = TextPosition.Center;
              break;
         }
    
         case CustomEnumNamespace1.TextPositions.TopLeft:
         {
              TextPosition chartPosition = TextPosition.TopLeft;
              break;
         }
    
         case CustomEnumNamespace1.TextPositions.TopRight:
         {
              TextPosition chartPosition = TextPosition.TopRight;
              break;
         }
    } 
    

    My Draw Draw.TextFixed() method with the custom variable chartPosition TextPosition

    PHP Code:
    Draw.TextFixed(
         this,
         "Testa",
         "TestA",
         chartPosition,
         Brushes.White,
         myFont,
         Brushes.Transparent,
         Brushes.Transparent,
         0); 
    
    MY Enum namespace using the switch
    PHP Code:
    namespace CustomEnumNamespace1
    {
         public enum TextPositions
         {
              BottomLeft,
              BottomRight,
              Center,
              TopLeft,
              TopRight
         }
    } 
    

    #2
    Hello PaulMohn,

    If you want to use this as the TextPosition value for Draw.TextFixed() it will need to be the same enum. You can however make a public property with TextPosition as the type.

    Code:
    [NinjaScriptProperty]
    [Display(Name = " Text Position", Description = "Controls where the text will appear", GroupName = "NinjaScriptParameters", Order = 0)]
    public TextPosition MyTextPositionInput
    { get; set; }
    
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    MyTextPositionInput = TextPosition.BottomLeft;
    }
    }
    
    protected override void OnBarUpdate()
    {
    Draw.TextFixed(this, "Testa", "TestA", [B]MyTextPositionInput[/B], Brushes.White, myFont, Brushes.Transparent, Brushes.Transparent, 0);
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Chelsea I don't understand what you mean by "it will need to be the same enum". Isn't it the same already? How would you recommend making it the same enum if it's not already?

      my #region Properties
      PHP Code:
      #region Properties
      [Range((int) CustomEnumNamespace1.TextPositions.BottomLeft, (int) CustomEnumNamespace1.TextPositions.TopRight), NinjaScriptProperty]
      [Display(ResourceType = typeof(Custom.Resource), Name = "TextPosition", GroupName = "NinjaScriptParameters", Order = 3)]
      public CustomEnumNamespace1.TextPositions TExtPosition
      {
      get { return TextPosition; }
      set { TextPosition = value; }
      }
      #endregion 
      

      But I don't have it set in the State == State.SetDefaults scope (and I tested as you showed and it's not working, same errors show).

      My goal is to have a switch to select from a dropdown the location of the text drawn on the chart.

      For example, in the dropdown control if I select "BottomLeft" then the Draw.TextFixed() method's 4th parameter for the Text position is switched to "TextPosition.BottomLeft", but if I select "BottomRight" instead then the Draw.TextFixed() method's 4th parameter for the Text position is switched to "TextPosition.BottomRight" (and so on for each 3 extra text positions).

      To achieve that, I'd use a custom variable "chartPosition", the same for all 5 text positions (as shown in my switch statement, I set
      a single chartPosition variable for all 5 positions, and the switch should distribute the text position 4th parameter according to my dropdown selection)

      As you can see the chartPosition variable is the same for all the switch actions
      Code:
      switch (TextPosition)
      {
          case CustomEnumNamespace1.TextPositions.[B]BottomLeft[/B]:
           {
                TextPosition [B]chartPosition [/B]= TextPosition.[B]BottomLeft[/B];
                break;
           }
      
           case CustomEnumNamespace1.TextPositions.[B]BottomRight[/B]:
           {
                TextPosition [B]chartPosition [/B]= TextPosition.[B]BottomRight[/B];
                break;
           }
      
           case CustomEnumNamespace1.TextPositions.[B]Center[/B]:
           {
                TextPosition [B]chartPosition [/B]= TextPosition.[B]Center[/B];
                break;
           }
      
           case CustomEnumNamespace1.TextPositions.[B]TopLeft[/B]:
           {
                TextPosition [B]chartPosition [/B]= TextPosition.[B]TopLeft[/B];
                break;
           }
      
           case CustomEnumNamespace1.TextPositions.[B]TopRight[/B]:
           {
                TextPosition [B]chartPosition [/B]= TextPosition.[B]TopRight[/B];
                break;
           }
      )

      I tested as you show but it's not working.
      The not working code (see additions to the Class level scope and in the State.Set.Defaults scope)
      Code:
      namespace NinjaTrader.NinjaScript.Indicators
      {
           public class Testa : Indicator
           {
                private CustomEnumNamespace1.TextPositions TextPosition = CustomEnumNamespace1.TextPositions.BottomLeft;
      
      [COLOR=#c0392b]          private TextPosition chartPosition;[/COLOR]
      
                protected override void OnStateChange()
                {
                      if (State == State.SetDefaults)
                      {
                           ...
      [COLOR=#c0392b]                    chartPosition = TextPosition.BottomLeft;
                           chartPosition = TextPosition.BottomRight;
                           chartPosition = TextPosition.Center;
                           chartPosition = TextPosition.TopLeft;
                           chartPosition = TextPosition.TopRight;[/COLOR]
                      }
                }
      
                protected override void OnBarUpdate()
                {
                     switch (TextPosition)
                     {
                          case CustomEnumNamespace1.TextPositions.BottomLeft:
                          {
                               TextPosition chartPosition = TextPosition.BottomLeft;
                               break;
                          }
      
                          case CustomEnumNamespace1.TextPositions.BottomRight:
                          {
                               TextPosition chartPosition = TextPosition.BottomRight;
                               break;
                          }
      
                          case CustomEnumNamespace1.TextPositions.Center:
                          {
                               TextPosition chartPosition = TextPosition.Center;
                               break;
                          }
      
                          case CustomEnumNamespace1.TextPositions.TopLeft:
                          {
                               TextPosition chartPosition = TextPosition.TopLeft;
                               break;
                          }
      
                          case CustomEnumNamespace1.TextPositions.TopRight:
                          {
                               TextPosition chartPosition = TextPosition.TopRight;
                               break;
                          }
                     }
      
                     Draw.TextFixed(
                     this,
                     "Testa",
                     "TestA",
                     chartPosition,
                     Brushes.White,
                     myFont,
                     Brushes.Transparent,
                     Brushes.Transparent,
                     0);
                }
      
                #region Properties
                [Range((int) CustomEnumNamespace1.TextPositions.BottomLeft, (int) CustomEnumNamespace1.TextPositions.TopRight), NinjaScriptProperty]
                [Display(ResourceType = typeof(Custom.Resource), Name = "TextPosition", GroupName = "NinjaScriptParameters", Order = 3)]
                public CustomEnumNamespace1.TextPositions TExtPosition
                {
                     get { return TextPosition; }
                     set { TextPosition = value; }
                }
                #endregion
           }
      }
      
      namespace CustomEnumNamespace0
      {
      }
      
      namespace CustomEnumNamespace1
      {
           public enum TextPositions
           {
                BottomLeft,
                BottomRight,
                Center,
                TopLeft,
                TopRight
           }
      }
      My original code (not working)
      Code:
      namespace NinjaTrader.NinjaScript.Indicators
      {
           public class Testa : Indicator
           {
                private CustomEnumNamespace1.TextPositions TextPosition = CustomEnumNamespace1.TextPositions.BottomLeft;
      
      [COLOR=#c0392b]...[/COLOR]
      
                protected override void OnStateChange()
                {
                     if (State == State.SetDefaults)
                     {
      [COLOR=#c0392b]...[/COLOR]
                     }
                }
      
                protected override void OnBarUpdate()
                {
                     switch (TextPosition)
                     {
                          case CustomEnumNamespace1.TextPositions.BottomLeft:
                          {
                               TextPosition chartPosition = TextPosition.BottomLeft;
                               break;
                          }
      
                          case CustomEnumNamespace1.TextPositions.BottomRight:
                          {
                               TextPosition chartPosition = TextPosition.BottomRight;
                               break;
                          }
      
                          case CustomEnumNamespace1.TextPositions.Center:
                          {
                               TextPosition chartPosition = TextPosition.Center;
                               break;
                          }
      
                          case CustomEnumNamespace1.TextPositions.TopLeft:
                          {
                               TextPosition chartPosition = TextPosition.TopLeft;
                               break;
                          }
      
                          case CustomEnumNamespace1.TextPositions.TopRight:
                          {
                               TextPosition chartPosition = TextPosition.TopRight;
                               break;
                          }
                     }
      
                     Draw.TextFixed(
                     this,
                     "Testa",
                     "TestA",
                     chartPosition,
                     Brushes.White,
                     myFont,
                     Brushes.Transparent,
                     Brushes.Transparent,
                     0);
                }
      
                #region Properties
                [Range((int) CustomEnumNamespace1.TextPositions.BottomLeft, (int) CustomEnumNamespace1.TextPositions.TopRight), NinjaScriptProperty]
                [Display(ResourceType = typeof(Custom.Resource), Name = "TextPosition", GroupName = "NinjaScriptParameters", Order = 3)]
                public CustomEnumNamespace1.TextPositions TExtPosition
                {
                     get { return TextPosition; }
                     set { TextPosition = value; }
                }
                #endregion
           }
      }
      
      namespace CustomEnumNamespace0
      {
      }
      
      namespace CustomEnumNamespace1
      {
           public enum TextPositions
           {
                BottomLeft,
                BottomRight,
                Center,
                TopLeft,
                TopRight
           }
      }
      Thanks!
      Last edited by PaulMohn; 02-28-2022, 06:53 AM.

      Comment


        #4
        Hello PaulMohn,

        CustomEnumNamespace1.TextPositions is not the same as NinjaTrader.NinjaScript.DrawingTools.TextPosition.

        You have made your own enum that ambiguously has the same name as an existing enum. They are not the same.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Chelsea, I think I got it working, but not sure I understand why.


          I modified the enum to
          PHP Code:
          private CustomEnumNamespace1.TextPos TextPosition1 = CustomEnumNamespace1.TextPos.BottomLeft;
          
          namespace CustomEnumNamespace1
          {
          
               public enum TextPos
               {
                    BottomLeft,
                    BottomRight,
                    Center,
                    TopLeft,
                    TopRight
               }
          } 
          

          Which doesn't return the prior compile errors anymore. But why?
          Was it because "TextPositions" is some sort of reserved term in Ninjascript? Or is it for another reason? If it it another reason, what other reason?

          I took the SampleUniversalMovingAverage_NT8.zip sample as example reference for my first enum and it worked


          Line 33
          PHP Code:
          private CustomEnumNamespace.UniversalMovingAverage    maType    = CustomEnumNamespace.UniversalMovingAverage.SMA; 
          

          Lines 112 - 122
          PHP Code:
          namespace CustomEnumNamespace
          {
               public enum UniversalMovingAverage
               {
                    EMA,
                    HMA,
                    SMA,
                    WMA,
               }
          } 
          


          My failing code

          line x
          PHP Code:
          private CustomEnumNamespace1.TextPositions TextPosition = CustomEnumNamespace1.TextPositions.BottomLeft; 
          
          lines y - z
          PHP Code:
          namespace CustomEnumNamespace1
          {
               public enum TextPositions
               {
                    BottomLeft,
                    BottomRight,
                    Center,
                    TopLeft,
                    TopRight
               }
          } 
          

          Why does it work with
          PHP Code:
          CustomEnumNamespace1.TextPositions TextPosition 
          

          or with
          PHP Code:
          CustomEnumNamespace1.TextPos TextPosition1 
          

          but not with
          PHP Code:
          CustomEnumNamespace1.TextPositions TextPosition 
          
          ?


          Other question:

          I'm now getting that compile error
          NinjaScript File Error Code Line Column
          Testa.cs 'chartPosition' conflicts with the declaration 'NinjaTrader.NinjaScript.Indicators.Testa.chartPos ition' CS0135 383 5
          I suspect it's due to the way I declared the variable at class scope level as
          PHP Code:
          namespace NinjaTrader.NinjaScript.Indicators
          {
               public class Testa : Indicator
               {
                  private TextPosition chartPosition; 
          
          PHP Code:
          Draw.TextFixed(
               this,
               "Testa",
               "TestA",
               chartPosition, /// the compile error get here
               Brushes.White,
               myFont,
               Brushes.Transparent,
               Brushes.Transparent,
               0); 
          
          If I don't declare the chartPosition variable at the class scope level
          or if I only initialize it in the State == State.SetDefaults I get this other compile error

          PHP Code:
          NinjaScript File Error Code Line Column
          Testa.cs The name 'chartPosition' does not exist in the current context CS0103 382 5 
          

          If I declare it locally (just above the Draw.TextFixed() method as
          PHP Code:
          TextPosition chartPosition;
          
          ​​​​​​​Draw.TextFixed(
               this,
               "Testa",
               "TestA",
               chartPosition, /// the compile error get here
               Brushes.White,
               myFont,
               Brushes.Transparent,
               Brushes.Transparent,
               0); 
          
          I get that other compile error
          NinjaScript File Error Code Line Column
          FreqDistHighMinOpen.cs A local variable named 'chartPosition' cannot be declared in this scope because it would give a different meaning to 'chartPosition', which is already used in a 'child' scope to denote something else CS0136 376 17
          With my other (the first) enum using Ints as in the SampleUniversalMovingAverage_NT8.zip no declaration nor initialization is required.

          Do I need to declare the variable at Class level scope or not? If I do, what's the correct way to declare the chartPosition variable? What's its type?
          Thanks!

          Comment


            #6
            Hello PaulMohn,

            Yes, NinjaTrader.NinjaScript.DrawingTools.TextPosition is already a NinjaScript object. You would not want to name a enum with the same name as this would conflict with the existing enum. Also, there is no need to duplicate this. Just use the existing enum. You can make public input for it with the type of that enum.

            private TextPosition chartPosition, this uses the existing enum. Supplying this to a draw method would be ok. If its not declared, that variable cannot be used.

            A variable should be class level if you intended to use it through out the class.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Ok thanks for the answer. how do you use the existing enum?
              Do you have an example of using the same enum? When you say
              Also, there is no need to duplicate this. Just use the existing enum.
              What do you mean? How would I use the same enum as NinjaTrader.NinjaScript.DrawingTools.TextPosition?

              my new code that returns the same error
              PHP Code:
              namespace NinjaTrader.NinjaScript.Indicators
              {
                   public class Testa : Indicator
                   {
                        private NinjaTrader.NinjaScript.DrawingTools.TextPosition TextPosition1 = NinjaTrader.NinjaScript.DrawingTools.TextPosition.BottomLeft;
              
                        private TextPosition chartPosition;
              
                        protected override void OnStateChange()
                        {
                             if (State == State.SetDefaults)
                             {
                             }
              
                        public enum TextPos
                        {
                             BottomLeft,
                             BottomRight,
                             Center,
                             TopLeft,
                             TopRight
                        };
              
                        protected override void OnBarUpdate()
                        {
                             switch (TextPosition1)
                             {
                                  case NinjaTrader.NinjaScript.DrawingTools.TextPosition.BottomLeft:
                                  {
                                       TextPosition chartPosition = TextPosition.BottomLeft;
                                       break;
                                  }
              
                                  case NinjaTrader.NinjaScript.DrawingTools.TextPosition.BottomRight:
                                  {
                                       TextPosition chartPosition = TextPosition.BottomRight;
                                       break;
                                  }
              
                                  case NinjaTrader.NinjaScript.DrawingTools.TextPosition.Center:
                                  {
                                       TextPosition chartPosition = TextPosition.Center;
                                       break;
                                  }
              
                                  case NinjaTrader.NinjaScript.DrawingTools.TextPosition.TopLeft:
                                  {
                                       TextPosition chartPosition = TextPosition.TopLeft;
                                       break;
                                  }
              
                                  case NinjaTrader.NinjaScript.DrawingTools.TextPosition.TopRight:
                                  {
                                       TextPosition chartPosition = TextPosition.TopRight;
                                       break;
                                  }
                             }
              
                             Draw.TextFixed(
                                      this,
                                      "Testa",
                                      "TestA",
                                      chartPosition, // the compile error get here
                                      Brushes.White,
                                      myFont,
                                      Brushes.Transparent,
                                      Brushes.Transparent,
                                      0);
                        }
              
                        #region Properties
                        [Range((int) NinjaTrader.NinjaScript.DrawingTools.TextPosition.BottomLeft, (int) NinjaTrader.NinjaScript.DrawingTools.TextPosition.TopRight), NinjaScriptProperty]
                        [Display(ResourceType = typeof(Custom.Resource), Name = "TextPosition", GroupName = "NinjaScriptParameters", Order = 3)]
                        public NinjaTrader.NinjaScript.DrawingTools.TextPosition TExtPosition
                        {
                             get { return TextPosition1; }
                             set { TextPosition1 = value; }
                        }
                        #endregion
                   }
              } 
              

              The error from line
              PHP Code:
              chartPosition, // the compile error get here 
              
              The error
              NinjaScript File Error Code Line Column
              Testa.cs 'chartPosition' conflicts with the declaration 'NinjaTrader.NinjaScript.Indicators.Testa.chartPos ition' CS0135 392 5
              Last edited by PaulMohn; 02-28-2022, 03:23 PM.

              Comment


                #8
                Hello PaulMohn,

                Your chartPosition is using the TextPosition original enum as the type. You don't need your own enum type. The TextPos enum isn't needed.

                The TextPosition1 variable is also confusing things and isn't needed. You already have a variable for the TextPosition.

                You are redeclaring chartPosition several time inside of the switch case blocks. It's already been declared within the scope of the class and should not be declared again.

                To make chartPosition an input, make this public and use the NinjaScriptProperty attribute as well as an auto getter and setter. Set a default for the variable in State.SetDefaults.

                Attached is an example.
                Attached Files
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Many thanks Chelsea! Now it's working! It was that simple. I thought as required premise we had to create a switch, with the corresponding range of values in the Properties statements (same as with the SampleUniversalMovingAverage sample).
                  Now I see you meant that right from your first answer in post #2 above. I originally thought your post #2 code couldn't work because there was no range specification (i thought only the BottomLeft value could show up from the MyTextPositionInput = TextPosition.BottomLeft. Also since no enum was in sight in your code I thought it couldn't work as a selection (now I think the enum is handled behind the scene by Ninja internal functions)).
                  Going forward i will make the effort to always test your recommendations before assuming they are only approximate solutions.

                  Thanks again!

                  The code with ALL CAPS notes
                  PHP Code:
                  namespace NinjaTrader.NinjaScript.Indicators
                  {
                       public class Testa : Indicator
                       {
                            // DELETED LINE***/private NinjaTrader.NinjaScript.DrawingT ools.TextPosition TextPosition1 = NinjaTrader.Ninj aScript.DrawingTools.TextPosition.BottomLeft;
                  
                            // DELETED LINE***/private TextPosition chartPosition;
                  
                            protected override void OnStateChange()
                            {
                                 if (State == State.SetDefaults)
                                 {
                                      Name = "TextPositionInputExample";
                                      IsOverlay = true;
                                      // ADDED LINE
                                      ChartPosition = TextPosition.BottomLeft;
                                 }
                  
                            /* DELETED LINES***
                            public enum TextPos
                            {
                                 BottomLeft,
                                 BottomRight,
                                 Center,
                                 TopLeft,
                                 TopRight
                            };
                            */
                  
                            /* DELETED LINES***
                            protected override void OnBarUpdate()
                            {
                                 switch (TextPosition1)
                                 {
                                      case NinjaTrader.NinjaScript.D rawingTools.TextPosition.BottomLeft:
                                      {
                                           TextPosition chartPositio n = TextPosition.BottomLeft;
                                           break;
                                      }
                  
                                      case NinjaTrader.NinjaScript.D rawingTools.TextPosition.BottomRight:
                                      {
                                           TextPosition chartPositio n = TextPosition.BottomRight;
                                           break;
                                      }
                  
                                      case NinjaTrader.NinjaScript.D rawingTools.TextPosition.Center:
                                      {
                                           TextPosition chartPositio n = TextPosition.Center;
                                           break;
                                      }
                  
                                      case NinjaTrader.NinjaScript.D rawingTools.TextPosition.TopLeft:
                                      {
                                           TextPosition chartPositio n = TextPosition.TopLeft;
                                           break;
                                      }
                  
                                      case NinjaTrader.NinjaScript.D rawingTools.TextPosition.TopRight:
                                      {
                                           TextPosition chartPositio n = TextPosition.TopRight;
                                           break;
                                      }
                                 }
                                 */
                  
                                 Draw.TextFixed(
                                          this,
                                          "Testa",
                                          "TestA",
                                          chartPosition,
                                          Brushes.White,
                                          myFont,
                                          Brushes.Transparent,
                                          Brushes.Transparent,
                                          0);
                            }
                  
                            #region Properties
                  
                            /* DELETED LINES***
                            [Range((int) NinjaTrader.NinjaScript.DrawingTools.T extPosition.BottomLeft, (int) NinjaTrader.NinjaScr ipt.DrawingTools.TextPosition.TopRight), NinjaScri ptProperty]
                            [Display(ResourceType = typeof(Custom.Resource), Na me = "TextPosition", GroupName = "NinjaScriptParam eters", Order = 3)]
                            public NinjaTrader.NinjaScript.DrawingTo ols.TextPosition TExtPosition
                            {
                                 get { return TextPosition1; }
                                 set { TextPosition1 = value; }
                            }
                            */
                            // ADDED LINES
                            [NinjaScriptProperty]
                            [Display(Name = "Chart Position", Description = "Select The Text Position on the Chart", GroupName="NinjaScriptProperties", Order = 0)]
                            public TextPosition ChartPosition
                            { get; set; }
                            #endregion
                       }
                  } 
                  

                  Comment


                    #10
                    Hello PaulMohn,

                    The SampleUniversalMovingAverage uses a custom enum that does not already exist for some custom logic.
                    It's appropriate if you are using an enum for your custom logic and not a NinjaTrader method, to use a custom enum.

                    The TextPosition used for drawing object methods already exists. This is why it's a parameter to those methods. Those methods require that exact enum type which is declared by NinjaTrader in the namespace NinjaTrader.NinjaScript.DrawingTools.TextPosition.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      That's more efficient that way with Ninja internal method.
                      But can we detect the a method is an already existing Ninjatrader method (for possible future cases)?
                      I saw the doc colorcodes the TextPosition parameter type with white text (also the first "NinjaScriptBase" parameter)
                      https://ninjatrader.com/de/support/h..._textfixed.htm

                      Wheras the other parameters ("string" and "bool") are colorcoded in Amethyst color.

                      Syntax

                      Draw.TextFixed(NinjaScriptBase owner, string tag, string text, TextPosition textPosition, Brush text Brush, SimpleFont font, Brush outlineBrush, Brush areaBrush, int areaOpacity)
                      Draw.TextFixed(NinjaScriptBase owner, string tag, string text, TextPosition textPosition)
                      Draw.TextFixed(NinjaScriptBase owner, string tag, string text, TextPosition textPosition, bool isGlobal, string templateName)
                      Are the colorcodes relevant to know wheter a parameter is a "reserved" ninjatrader type or not? If not, how else can we figure it out?
                      (I mean "NinjaScriptBase" with the Ninjascript mention can be obvious the type is "reserved/internal to Ninjatrader" (but then again maybe not that obvious considering) but for parameters with no "ninjascript" reference)
                      When in doubt how do you check? thanks!
                      Last edited by PaulMohn; 02-28-2022, 04:55 PM.

                      Comment


                        #12
                        Hello PaulMohn,

                        Type the word TextPosition. However the mouse over it. If there is a signature, it exists.

                        You can also do a search in the help guide and see if the property or method exists in the help guide.

                        string and bool are not NinjaScript. These are part of C#.
                        Chelsea B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        598 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        343 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        103 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        556 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        555 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X