Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error Importing indicator

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

    Error Importing indicator

    Hi - i have an indicator that compiles just fine and exports also correctly on my dev computer. But when I try to import it on the trading PC, i get some error that I cannot figure out the root cause for.. Any help or pointers would be super helpful

    Below is the error I get. The code that it is referrencing is generated code by Ninjatrader and not part of the indicator code i have written.

    CS0266: Cannot implicitly convert type 'NinjaTrader.NinjaScript.DrawingTools.TextPosition [C:\Users\Administrator\Documents\NinjaTrader 8\bin\Custom\DrawingTools\@Text.cs(513)]' to 'NinjaTrader.NinjaScript.DrawingTools.TextPosition [C:\Users\Administrator\Documents\NinjaTrader 8\bin\Custom\DMR_Tools.v24.10.19.2.dll]'. An explicit conversion exists (are you missing a cast?),
    10/19/2024 2:37:10 AM,Default,Error compiling import assembly: C:\Users\Administrator\Documents\NinjaTrader 8\bin\Custom\DMR_Tools.v24.10.19.2.cs(1761544): error CS0019: Operator '==' cannot be applied to operands of type 'TextPosition' and 'TextPosition',​


    #2
    Hello jpkulkarni,

    The error appears to be from the DMR_Tools.v24.10.19.2.dll assembly.

    Is this a custom assembly you have created yourself?

    Do any classes in this assembly call Draw.TextFixed()?

    The error is likely caused by a script using a method such as Draw.TextFixed() which uses an enum for TextPosition. That enum is defined in the core of NinjaTrader; when NinjaScripts are imported, the platform searches for that enum within the assembly being imported and not within the core assembly.

    A workaround to resolve this is for the developer to include a custom enum in a custom namespace that has the same properties, such as the various TextPosition values, and then that enum can be cast to the TextPosition type using the fully qualified namespace. This will allow the script to be exported as a compiled assembly and then subsequently it can be imported successfully. Here is an example of a custom enum you could use:
    Code:
    namespace MyEnums
    {
    public enum TextPosDLL
    {
    BottomLeft,
    BottomRight,
    Center,
    TopLeft,
    TopRight
    }
    }​
    The Draw.TextFixed() method within the script would look like the following:
    Code:
    Draw.TextFixed(this, "tag", "Text", (NinjaTrader.NinjaScript.DrawingTools.TextPosition )MyEnums.TextPosDLL.Center);
    For a full working example of this in an open source indicator script you can text exporting as a closed assembly, please see the attached TextPositionDLL.zip.
    TextPositionDLL.zip
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea.. As usual you have been fantastic with these kinds of weird issues. yes. the DMR_Tools is something i packaged but was not sure why it would give me error on import if it didn't give me error at compile time and also at run time on my dev machine. I will try above workaround to see if i can get the get it to work.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      581 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      338 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
      554 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      552 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X