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

Adding References (From Visual Studio)

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

  • NinjaTrader_Jesse
    replied
    Hello PaulMohn,

    I won't be able to tell what is happening with that library.

    The line you mentioned seems that it is creating a new list, that is really all i can tell from that code.

    Leave a comment:


  • PaulMohn
    replied
    Ok thanks Jesse.

    I found a way from this helping post
    Why can't I assign List<int> to IEnumerable<object> in .NET 4.0

    I had to formulate it this way
    PHP Code:
    namespace NinjaTrader.NinjaScript.Indicators
    {
      public class 
    TestaIndicator
      
    {
        private List<
    doublelistOfSeriesValues;

        
    IEnumerable<doublemedian;


        protected 
    override void OnStateChange()
        {
          if (
    State == State.SetDefaults)
          {
            
    //properties etc. here
          
    }
          else if (
    State == State.Configure)
          {
          }
          else if (
    State == State.DataLoaded)
          {        
            
    listOfSeriesValues = new List<double>();

            
    median = new List<double>();
          }



        protected 
    override void OnBarUpdate()
        {
          
    Rng0Rng1[Rng0Index] = Rng0[Rng0Index] - Rng1[Rng1Index];

          
    listOfSeriesValues.Add(Rng0Rng1[0]);


          
    double meds listOfSeriesValues.Median();

          
    double var02b Instrument.MasterInstrument.RoundToTickSize(meds TickSize); 

    It is returning a value for the variable meds (please see attached images), though I'm not sure if that's right as there seems to be no connection between the

    PHP Code:
    IEnumerable<doublemedian; / median = new List<double>(); 

    and the

    PHP Code:
    double meds listOfSeriesValues.Median(); 

    Click image for larger version  Name:	meds.png Views:	0 Size:	1.21 MB ID:	1193422

    And when I comment out the

    PHP Code:
    IEnumerable<doublemedian; / median = new List<double>(); 

    it's not returning the value.

    Any advice on what the connection is? Thanks!
    Last edited by PaulMohn; 03-11-2022, 11:19 AM.

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello PaulMohn,

    I won't be able to tell you what you need for the library to work or be able to help with that libraries use, adding the reference assumes you have something working with that library externally or know exactly what you need already. You may need other libraries referenced based on the error.

    If you are using nuget that generally entails that you make your own external project to collect needed resources or even form a test C# application to ensure you have something working beforehand. Once you have all the requirements you could copy the requirements like the dlls to NinjaTrader folders and then try and reference it.

    Leave a comment:


  • PaulMohn
    replied
    Ok so it does load but I got these error

    NinjaScript File Error Code Line Column
    Testa.cs 'NinjaTrader.NinjaScript.Series<double>' does not contain a definition for 'Median' and the best extension method overload 'MathNet.Numerics.Statistics.Statistics.Median(Sys tem.Collections.Generic.IEnumerable<double>)' has some invalid arguments CS1928 939 21
    NinjaScript File Error Code Line Column
    Testa.cs Instance argument: cannot convert from 'NinjaTrader.NinjaScript.Series<double>' to 'System.Collections.Generic.IEnumerable<double>' CS1929 939 21
    The package ref for the median

    states
    double Median(this IEnumerable<double> data)

    Estimates the sample median from the provided samples (R8).
    Parameters

    IEnumerable<double> data


    The data sample sequence.
    I use a list for the data
    PHP Code:
            private Series<doubleRng0Rng1;

            
    Rng0Rng1[Rng0Index] = Rng0[Rng0Index] - Rng1[Rng1Index];

            
    double median Rng0Rng1.Median();

            
    double var02b Instrument.MasterInstrument.RoundToTickSize(median TickSize); 

    Is there a way to use the list as/with IEnumerable<double> ?

    Or what other solution would you suggest? Thanks!

    Leave a comment:


  • PaulMohn
    replied
    Thanks Jesse I didn't look for the add.
    I got it on now!

    Click image for larger version

Name:	add.png
Views:	172
Size:	96.6 KB
ID:	1193380

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello PaulMohn,

    but the new .dlls don't show up.
    The only .dll showing from the Custom folder is Ninjatrader.Vendor.dll
    Are you clicking Add to browse to the bin/custom folder? The dlls don't add themselves to the list, you have to add each dll manually.

    Leave a comment:


  • PaulMohn
    replied
    Oh ok I've reuploaded the images now (I had the 5 images per post limit issues before)

    I forgot to reference them
    Using 3rd Party Indicators

    I checked from the script in Ninjascript editor > right click > references
    but the new .dlls don't show up.
    The only .dll showing from the Custom folder is Ninjatrader.Vendor.dll
    Any reason why? Thanks!

    I saw the same .dll showing at this timestamp
    10 Benefits of Using Visual Studio with NinjaTrader - Ninja Mastery
    Last edited by PaulMohn; 03-10-2022, 04:57 PM.

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello PaulMohn,

    Not all of your images loaded from post 12 on. From the details I can see you would need to copy the dlls from the addon projects build folder into to the bin/custom folder and then reference any dlls which are needed to use that namespace. The addon project has a bin/debug sub folders and the build data for visual studio exists there.



    Leave a comment:


  • PaulMohn
    replied
    I've added
    PHP Code:
    using MathNet.Numerics.Statistics
    to my declarations region but I get

    NinjaScript File Error Code Line Column
    Testa.cs The type or namespace name 'MathNet' could not be found (are you missing a using directive or an assembly reference?) CS0246 25 7
    Why isn't it detecting it?

    Leave a comment:


  • PaulMohn
    replied
    6.Copy the files you need to the bin/custom folder so you can reference any needed dlls.
    Click image for larger version

Name:	copy.png
Views:	560
Size:	286.1 KB
ID:	1193323​​

    Are the ones needed only the new files from the bin/Custom or are there new files elsewhere I should also copy to Documents\NinjaTrader 8\bin\Custom? Thanks!
    Last edited by PaulMohn; 03-10-2022, 04:39 PM.

    Leave a comment:


  • PaulMohn
    replied
    Click image for larger version  Name:	4.png Views:	0 Size:	1.41 MB ID:	1193318


    Click image for larger version  Name:	5.png Views:	0 Size:	1.22 MB ID:	1193319

    4. F6 build the solution

    Click image for larger version  Name:	Build.png Views:	0 Size:	1.43 MB ID:	1193320

    Click image for larger version  Name:	7.png Views:	0 Size:	1.36 MB ID:	1193321

    5. You can now view the bin/debug folder from that solution to see what files got copied, some nuget packages have extra files or build actions that require copying or creating specific files/structures.
    I found there are only 2 new files (the left window is the new folder bin/debug folder, while the right window is the folder still in the archive)

    Click image for larger version  Name:	new files.png Views:	0 Size:	475.6 KB ID:	1193322
    Last edited by PaulMohn; 03-10-2022, 04:45 PM. Reason: I found there are only 2 new files (the left window is the new folder bin/debug folder, while the right window is the folder still in the archive)

    Leave a comment:


  • PaulMohn
    replied
    Thanks.
    I had to download 4.8, install it, then close visual studio and relaunch it for it to load the addon project.

    1. Go to the following link and download the addon visual studio project:
    https://ninjatrader.com/support/help...t_overview.htm
    Click image for larger version  Name:	0download.png Views:	0 Size:	1.02 MB ID:	1193290
    Click image for larger version  Name:	Extract.png Views:	0 Size:	59.3 KB ID:	1193291

    2. Open the project in visual studio
    Click image for larger version  Name:	0.1Open.png Views:	0 Size:	223.1 KB ID:	1193292

    3. Add the nuget reference that you wanted to use by using visual studios nuget manager.
    Click image for larger version  Name:	2.png Views:	0 Size:	1.37 MB ID:	1193294
    Click image for larger version  Name:	3.png Views:	0 Size:	1.14 MB ID:	1193293
    Last edited by PaulMohn; 03-10-2022, 04:42 PM.

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello PaulMohn,

    NT8 is now 4.8, to develop 4.8 assemblies you would need to install the targeting pack.

    Leave a comment:


  • PaulMohn
    replied
    Thanks Jesse,

    I've downloaded the Addon archive, unziped on my desktop and double clicked the .sln file.
    I'm getting this
    Click image for larger version  Name:	vmplayer_4dVwh7aGFW.png Views:	0 Size:	13.3 KB ID:	1193269
    What should I do next? Isn't NT8 4.5? Thanks!

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello PaulMohn,

    I wouldn't really be able to say because I am not familiar with that library, you can however find out by using visual studio. The easiest way to get nuget references for NinjaTrader would be the following process:
    1. Go to the following link and download the addon visual studio project: https://ninjatrader.com/support/help...t_overview.htm
    2. Open the project in visual studio
    3. Add the nuget reference that you wanted to use by using visual studios nuget manager.
    4. F6 build the solution
    5. You can now view the bin/debug folder from that solution to see what files got copied, some nuget packages have extra files or build actions that require copying or creating specific files/structures.
    6. Copy the files you need to the bin/custom folder so you can reference any needed dlls.

    This process does copy the addon dll to the bin/custom folder as well, to delete that open the folder Documents\NinjaTrader 8\bin\Custom and remove the addon dll that was copied.
    This also makes sure the target .net version is the correct one for NT8.


    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by alifarahani, Today, 09:40 AM
6 responses
31 views
0 likes
Last Post alifarahani  
Started by Waxavi, Today, 02:10 AM
1 response
17 views
0 likes
Last Post NinjaTrader_LuisH  
Started by Kaledus, Today, 01:29 PM
5 responses
14 views
0 likes
Last Post NinjaTrader_Jesse  
Started by Waxavi, Today, 02:00 AM
1 response
12 views
0 likes
Last Post NinjaTrader_LuisH  
Started by gentlebenthebear, Today, 01:30 AM
3 responses
17 views
0 likes
Last Post NinjaTrader_Jesse  
Working...
X