Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Compiled Assemblies and TextPosition

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

    Compiled Assemblies and TextPosition

    Hi,
    a compiled assembly cannot be imported because TextPosition could not be found in any namespace.
    I'm across the "Considerations for compiled assemblies" in the Help, and have previously used the dynamic type to work with draw objects. I'm not clear on how to apply this technique to help out TextPosition which in this indicator export is a use- adjustable Property and within Draw.TextFixed(...). (maybe I need more coffee)
    Can you assist?
    Thanks,

    saltminer

    #2
    Hello saltminer,

    Accessing any type that is part of the NinjaTrader.Custom project would require using dynamic however that would just be for items you are trying to work with like a drawing object. If you are drawing objects in your code that use TextPosition and then exporting it as compiled you would need to make sure you have the fully qualified namespace being used:

    NinjaTrader.NinjaScript.DrawingTools.TextPosition

    Anywhere TextPosition is used you should change it to the full namespace like above. Please try that and re export and test the zip to see if that resolves the error. If it does not I would need more details on what code you are using with TextPosition and how its being used in your script.


    Comment


      #3
      Hi Jesse,
      thanks, but implementing your advice only gets me so far. At import, this log entry occurs (and import fails).

      Error compiling import assembly: c:\Users\Administrator\Documents\NinjaTrader 8\bin\Custom\MyIndicator.cs(49,257) : error CS0266: Cannot implicitly convert type 'NinjaTrader.NinjaScript.DrawingTools.TextPosition [c:\Users\Administrator\Documents\NinjaTrader 8\bin\Custom\DrawingTools\@Text.cs(514)]' to 'NinjaTrader.NinjaScript.DrawingTools.TextPosition [c:\Users\Administrator\Documents\NinjaTrader 8\bin\Custom\MyIndicator.dll]'. An explicit conversion exists (are you missing a cast?)


      TextPosition is used as an input Property, like this:

      [NinjaScriptProperty]
      [Display(Name="ChartTextLocation", Description="", Order=5, GroupName="Parameters")]
      public NinjaTrader.NinjaScript.DrawingTools.TextPosition ChartTextLocation
      { get; set; }

      And then ChartTextLocation (which is of type TextPosition) is used to draw text, like this:

      Draw.TextFixed(this,name,arrow.ToString(),ChartTex tLocation,directionColor,BigArrowFont,Brushes.Tran sparent,Brushes.Transparent,0);​
      Attached Files
      Last edited by saltminer; 11-02-2023, 09:22 PM. Reason: fixed typo

      Comment


        #4
        Hello saltminer,

        Did you make sure to change that everywhere TextPosition is used? Any usage of TextPosition would have to reflect the full namespace.

        If you are still having problems it would be best for you to make a small sample script that shows the specific code that is failing to import and then attach that as a .cs file so we can see what code is used.

        Comment


          #5
          Hi Jesse,
          here is a super simple example, which fails on import when it has been exported as an assembly. (both source code and assembly export are attached)
          I look forward to your solution.
          Thanks,
          saltminer

          Code:
          // INPUTS
          ChartTextLocation = NinjaTrader.NinjaScript.DrawingTools.TextPosition. TopRight;
          
          }
          else if (State == State.Configure)
          {
          
          }
          }
          
          protected override void OnBarUpdate()
          {
          try
          {
          NinjaTrader.NinjaScript.DrawingTools.Draw.TextFixed(this,"infotest","HERE I AM",ChartTextLocation);
          }
          catch (Exception obuEx)
          {
          throw new Exception(obuEx.ToString());
          }
          
          }
          region Properties
          [NinjaScriptProperty]
          [Display(Name="ChartTextLocation", Description="", Order=5, GroupName="Parameters")]
          public NinjaTrader.NinjaScript.DrawingTools.TextPosition ChartTextLocation
          { get; set; }
          Attached Files

          Comment


            #6
            Hello saltminer,

            It looks like you have [NinjaScriptProperty] on your public property to make it optimizable and an input for other NinjaScript items. That will cause the error during importing so the solution would be to remove [NinjaScriptProperty]

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Mindset, 04-21-2026, 06:46 AM
            0 responses
            57 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            78 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            41 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            101 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            61 views
            0 likes
            Last Post PaulMohn  
            Working...
            X