Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to create an indicator with several source filese?

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

    How to create an indicator with several source filese?

    Hello!

    It is easy to create an indicator using the embed script editor. All examples shows an indicator in a single source file.
    One source file is suitable for a simple tasks. For the complex tasks it is possible to create a huge file with all required files of course.

    It may be more convenient to split the source of the indicator on several files for testing/debugging purposes.


    Can an indicator have several source files?
    Could you provide me with an example of the dummy indicator with several source files, please?

    #2
    Hello AlexMocc,

    Thanks for your post.

    It is possible to use partial classes to create shared methods that can be reused and the partial classes can reside in other source files. Please see the example below.

    Shared Methods in NinjaTrader 8 - https://ninjatrader.com/support/foru...est#post733956

    We should note that while this is possible, there are going to be limitations using inheritance and abstract and partial classes. Indicators have wrappers to generate NinjaScript Generated Code so they can interface with other NinjaScripts, and these approaches may not work nicely with these wrappers.

    Please see known NinjaScript limitations here - https://ninjatrader.com/support/help...neousPractices

    We look forward to assisting.

    Comment


      #3
      Hello Jim,
      Thank you for message!

      Assume the indicator consists of 3 source files: SuperIndicator.cs, SuperIndicatorTool.cs, SuperIndicatorTool2.cs
      The file SuperIndicator.cs was created in ScriptEditor of NT8. It is a main class of the indicator.
      The file SuperIndicator.cs refers classes from SuperIndicatorTool.cs and SuperIndicatorTool2.cs
      Nothing special. Let us assume all classes are small and trivial if it matters.

      What is the folder to put files? Is it "C:\Users\User\Documents\NinjaTrader 8\bin\Custom\Indicators" ?

      Comment


        #4
        Hello AlexMocc,

        I would suggest making CS files in the AddOn folder and adding your partial classes and helper classes in there.

        Keep in mind, abstract and partial classes can break NinjaScript wrappers/NinjaScript generated code and is not fully supported. Much of this has to do with public properties to build constructors. If you keep all necessary properties in the main Indicator\SuperIndicator.cs file, and only offload helper methods and helper classes that are not needed for the indicator's construction, you should still be in clear waters.

        Please note, if you are looking for support later down the line, factors involving partial classes should be rules out since this is not fully supported.

        We look forward to assisting.

        Comment

        Latest Posts

        Collapse

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