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

Best Approach to Export Indicator that Uses a standalone C# Class

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

  • BarzTrading
    replied
    That's it, Chelsea! I moved all my code under the AddOns folder and all of the files are now recognized in the Export dialog as "Add On" items.
    Last edited by BarzTrading; 01-28-2019, 12:14 PM.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello BarzTrading,

    I would advise against creating a new folder in the Documents\NinjaTrader 8\bin\Custom folder.

    Instead, add any custom classes to the Addon folder.

    Leave a comment:


  • BarzTrading
    replied
    I've added my common classes in a folder called Barz at the same level as /AddOns, /BarsTypes, /ChartStyles, etc.

    This folder does not show up in the NinjaScript editor. I always use Visual Studio so I hadn't noticed that.

    The common classes are using the Barz namespace.

    I put my indicators in the folder /Indicators/Barz and use the namespace: NinjaTrader.NinjaScript.Indicators.Barz. This works fine and I can see these and edit them in the NinjaScript editor.

    I don't know if namespace is relevant here, but where should the class files go?

    Thanks,

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello BarzTrading,

    Is the open source script in NinjaTrader? Can you open it in the NinjaScript Editor?

    If so, it should be available in the export window.

    What folder is it in? Is it in the Addons folder?

    Leave a comment:


  • BarzTrading
    replied
    Thanks, Chelsea.

    I understand the video and can replicate it. What I don't understand is how you would include a random *.cs file that contains a plain old c# class (a shared class). When I use the export operation I have no option to select individual source code files.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello BarzTrading,

    Yes, the instructions in that video apply to all classes (no matter what other class they happen to be extending such as Indicator or Strategy or if its just a class in an Addon)

    The idea with the video is that the shared class would also be exported as a dll, but sure if you wanted to include open source .cs files with the export these can be selected in the export window. (Open source scripts will import to specific folders so these should be added using the Tools > Export > NinjaScript Addon window)

    Yes, you can create a dll in Visual Studio, create a reference to in the NinjaScript Editor and compile, then when exporting include a reference to the dll, then drag and drop the .dll file in the exported .zip file.

    Leave a comment:


  • BarzTrading
    replied
    Thanks for the video, Chelsea. It answered several of my questions. A couple remain.

    So, if the dependency is a code file, a plain class, rather than an indicator as you demo'd, would I be correct that I have two choices?

    1) I could drop one or more *.cs files into the zip file?
    2) I could use Visual Studio to create a separate project which produces a DLL that can be referenced by NinjaTrader.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello BarzTrading,

    When exporting a closed source assembly with scripts that use a shared class, this should be exported in a separate file and should be referenced in the export.

    Below is a link to a video I have created that demonstrates.


    NinjaTrader does not support classes that extend NinjaTrader classes such as Indicator or Strategy.
    This thread will remain open for any community members that would like to assist with this unsupported code.

    Leave a comment:


  • Best Approach to Export Indicator that Uses a standalone C# Class

    1) How to export an indicator that depends on another plain old class object?

    In trying to export an indicator I've created, I'm trying to determine the best approach because it depends on another class in a separate file.

    I've done all of this in the standard Custom project. The class is a simple basic class having nothing to do with NinjaTrader.

    I don't see a way to include code unless it's a special NinjaTrader component like an Indicator or Strategy or unless it's a DLL reference.

    Do I need to put my class in a separate project and reference the DLL in order to get exporting to work?

    2) Is it possible to create ninjascript objects, like indicators and strategies, in a separate DLL that is then referenced in NinjaTrader?

    Is this do-able so long as our separate project references all of the necessary NinjaTrader DLLs including NinjaTrader.Vendor.dll? Then when
    we deploy the DLL to the custom folder we just copy the main DLL and not the references because they are, theoretically, already referenced
    by NinjaTrader?

    What is the primary purpose of the NinjaTrader.Vendor.dll?

    What is the recommended location from which to reference those DLLs? The custom/bin area in MyDocs? Or the NinjaTrader
    installation folder in Program Files, C:\Program Files (x86)\NinjaTrader 8\bin\Custom\Backup ?

    3) What if the dependencies are not just plain old C# classes but are say, extensions for the NT Instrument class?

    I have a lot of extensions to NT classes which I use in indicators and strategies. How can I include these in an export of an
    indicator? Can they be added to that separate project? That project would require a reference to NinjaTrader.Core which contains the Instrument class. Would that work? Is that sufficient, recommended?

    4) If I'm creating multiple indicators which all depend on some common classes, what is the best approach?

    I could have a common DLL that is used by multiple indicators, but if I export each indicator individually they'll each depend on the same DLL.
    Will there be problems if the indicators are imported separately, with that same DLL added to each .zip file? Will their common dependency be handled gracefully without trying to add multiple copies of the DLL?

    Or, would it be best to export all indicators in a single export package?

    Thanks,





    Last edited by BarzTrading; 01-27-2019, 10:03 PM.

Latest Posts

Collapse

Topics Statistics Last Post
Started by NRITV, Today, 01:15 PM
1 response
5 views
0 likes
Last Post NinjaTrader_Jesse  
Started by maybeimnotrader, Yesterday, 05:46 PM
5 responses
24 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by quantismo, Yesterday, 05:13 PM
2 responses
16 views
0 likes
Last Post quantismo  
Started by frankthearm, Today, 09:08 AM
6 responses
27 views
0 likes
Last Post frankthearm  
Started by adeelshahzad, Today, 03:54 AM
5 responses
33 views
0 likes
Last Post NinjaTrader_BrandonH  
Working...
X