Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Update:
The problem is apparently in the constructor methods of my indicators. I was copying the framework of the built-in indicator constructors (see attached for example), and doing so somehow blocks access in the VS workspace to built-in indicator methods. So if I comment out my constructor methods and save, I can literally watch the squiggly lines disappear, and the built-in indicators are immediately instantiable.
I'd really like to create invokable indicators. I don't know how to create constructor methods that NT recognizes that don't follow the built-in way of doing it. I suppose one way around this is to simply duplicate the code I want to instantiate, every time I need it in another indicator. Le ugh.
Can you help answer these questions from other members on NexusFi?
Just reading your posts now. I agree that you are most likely having a dll reference issue. If you look at the way I did it (your problem is exactly why I did it this way), I have a "Libs" folder where I put all of the necessary NT8 dll files. Those files are then reference in the .csproj so that I can have access to all of the built in NT8 functionality including indicators, gui stuff, etc. If you don't reference these dll files, you just won't have access to the features you're wanting.
As far as the constructor issues you're having. I went at it for weeks trying to get constructors to work. I mean, C# is a high level object oriented language so constructors are where everything start, right??? Not quite so much when you're developing to NT8. There are some significant things that happen under the hood of NT8 that we can't see which is why they have exposed certain methods to use. If you're in a strategy, I believe there is an AddChartIndicator (doing this from memory so might be slightly different). There is another way which isn't documented well, or possibly not at all, which I'll link to here.
This locking on NinjaScripts object then adding your indicator to THAT collection is essentially using a constructor. Once you have your indicator in that collection, the underlying events like OnBarUpdate, OnMarketDepth, etc will fire as expected. I've tried to document this in my examples but didn't get into it on my videos since it's a fairly in depth topic.
I actually wanted to ask you about the copying of the NT8 system files to the Libs folder. I followed your method, but I was wondering what the difference would be in just referencing the system files where they are, natively (e.g. in c:\progra...\...rader 8\bin64, etc.). I've tried both ways, seemingly without issue. I could write a script for finding the references and adding them to the csproj file, if you want to include it in your project, if that's even a good idea.
But as far as the NT8 system files references within VS, where I have the libraries in a Libs folder, those definitely are being recognized. IntelliSense does a great job of filling in all the stuff that comes out of those libraries. My indicators build, successfully, and then load within NT8.
I'll check out AddChartIndicator and your strat you linked to (I have that in your solution folder, already, actually).
Broker: NT Brokerage, Kinetick, IQFeed, Interactive Brokers
Trading: ES
Posts: 159 since Dec 2014
Thanks Given: 40
Thanks Received: 166
Take a look at the Copy Files project I have on my solution. This not only moves the files to the correct spots, but it also checks for versions. I think this is the most robust way to do it because NinjaTrader does update stuff from time to time and this ensures you always have to most you to date. It can also let you know whether your system is behind your referenced files. This, for me, was important because I do dev on my laptop as well when in on the road. So if you've updated your NT8 installation on your main trading machine bit not your laptop, it won't overwrite files that are the wrong version. As well as if you update from your laptop, it will let you know you need to update your main machine's NT8 installation.
That is the purpose of the unit tests I wrote. You simply run those suite of tests and in less than a second you know whether you need to update your C# soliton or your NT8 installation. The way I update the files is with that Copy Files console application. It's super simple but does all the checks I mentioned.
Hi Jasonnator, first many thanks for your great work! I'm trying to expand the folder structure, unfortunately I haven't had any success with it. Maybe you can give me a hint what I have to change or pay attention to? As an example, the indicators are stored and displayed in the default directory \Indicators. I would like to have a folder structure like for example \Indicators\Testfolder\Testfolder1. When I now create the folder, I can't find it in the namespace and in NT8 the indicators are still displayed in the default directory.
Broker: NT Brokerage, Kinetick, IQFeed, Interactive Brokers
Trading: ES
Posts: 159 since Dec 2014
Thanks Given: 40
Thanks Received: 166
I've never had a need to nest indicators inside another folder so I've never researched it. I'm sure it can be done but for simplicity, I would recommend a naming convention which groups them together.
Is "Include in Project" not what you're looking for? You'll have to enable "Show All Files" in VS to be able to see a folder you created outside of VS, and maybe hit Refresh. Alternatively, you can right-click Indicators in the Solution Explorer and add a New Folder, which will create it for you in the directory and automatically add it to the project. Once you throw something compilable in there, it should show up in the NinjaScript Editor.
Additionally, you can name the files "Test1.BarGap.cs," "Test2.BarGap.cs," and I believe the NS Editor will present them to you in the Explorer as if they're in separate folders, Test1 and Test2.
Broker: NT Brokerage, Kinetick, IQFeed, Interactive Brokers
Trading: ES
Posts: 159 since Dec 2014
Thanks Given: 40
Thanks Received: 166
If I had to guess, I think NT8 would look at the actual namespaces and populate folders accordingly. I would try adding your desired folder name to the end of the built in namespace.
As it looks, it works. No Intellisense is applied, and the directory must be written by hand, besides, it is not displayed in NinjaTrader Editor, but the file in the directory can be loaded and displayed on the chart.