Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Same class in FILE vs. in DLL

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

    Same class in FILE vs. in DLL

    I found, that is it possible to have same class in NinjaTrader defined twice.

    1. Class Strategy1 in file Strategy1.cs
    2. Same class Strategy1 defined in imported DLL.
    (this happen by exporting the first Strategy1 and importing it back, which resulted in new Strategy1.dll in the Custom folder.)

    BTW, I also found, that if both classes coexist, then the *.cs file has priority
    and is executed the Strategy Analyzer instead of the class contained in DLL.

    Question:

    How Ninjatrader handles such a conflicting scenario when there are more strategies with the same class?
    (one in a *.cs file and same in the imported *.dll file).

    Related question:
    I am also interested, how NT handles when multiple strategies (for examle Strategy1, Strategy2, Strategy3) and each of them extend the same CustomBaseStrategy.

    I export all 3 strategies, then import them back. Does it not make any conflict, when each one of the 3 strategies imports the same base class CustomBaseStrategy?

    I found, that is does'nt make any conflict, but I would like to understand why and how it works. Probably there is some level of isolation, which I have not found documented anywhere.

    Could you please explain how NT handles these scenarios mentioned above and why multiple classes with same name can coexist in NT ?

    #2
    Hello misova,

    Thank you for your post.

    I do not fully understand the steps you have taken with the multiple strategies under the same name. In general, importing a protected .dll file with a file that already exists will result in an error and the same goes for importing an unprotected .cs file when it already exists in a protected .dll.

    There are multiple strategies already under the class strategy and multiple indicators already under the class name indicator. So you can use multiple files under the same class. For example "public class EMA : Indicator".

    Are you naming them "public class strategyName : Strategy1" or "public class Strategy1 : Strategy"?

    Comment


      #3
      Thanx, you are right.
      After restarting NinjaTrader, it reported error and I was not able to compile source anymore.

      The steps, how you can get same class twice is this:
      1. Create simplistic Strategy1 and compile it.
      2. Then export it and import it.
      (this results in Strategy1.dll in Custom folder).

      Now, there is same class twice:
      1. in source file
      2. in Strategy1.dll


      If you run backtest: you can see, that the one from 1) Strategy.cs is backtested.
      But when you delete 1) Strategy1.cs, that automatically that one from 2) Strategy1.dll is backtested.

      There is no problem anymore - I provided the steps just because you asked about it.
      Thanx
      Misova

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      669 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      378 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      111 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      575 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      580 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X