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

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.


    JesseNinjaTrader Customer Service

    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.

        JesseNinjaTrader Customer Service

        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]
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Graci117, Today, 09:02 PM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by ETFVoyageur, Today, 07:55 PM
            0 responses
            7 views
            0 likes
            Last Post ETFVoyageur  
            Started by janio973, Today, 07:24 PM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by aligator, 01-06-2022, 12:14 PM
            4 responses
            246 views
            0 likes
            Last Post john_44573  
            Started by reynoldsn, Today, 05:56 PM
            0 responses
            14 views
            0 likes
            Last Post reynoldsn  
            Working...
            X