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)
I have been wanting to give back to the FIO community for a while and decided to start making some videos on how to get up and running creating, and more importantly, debugging indicators & strategies from within Visual Studio. This is what I hope will be the beginning of several videos showing how to not only get Visual Studio hooked up to NinjaTrader 8, but also how to create custom indicators and strategies also from within VS. I have pushed all the code used in the video to a GitLab repository which is free for anyone to use.
I welcome any feedback and questions. My target audience was someone somewhat familiar with writing/hacking through an indicator in NinjaTrader's NinjaScript Editor but looking to take their indicators and strategies to the next level by taking full advantage of the power and features of Visual Studio.
I have a lot of ideas and I'd like to see where people could use the most help so I can tailor future how to videos. I had help from a few power users early on and feel it's my time to give back some knowledge I've learned the hard way.
Broker: NT Brokerage, Kinetick, IQFeed, Interactive Brokers
Trading: ES
Posts: 159 since Dec 2014
Thanks Given: 40
Thanks Received: 166
I meant to include the link to the code repository. All code is freely available and located on my GitLab repository.
I think next, I want to do something a little simpler (and much shorter). @GraDman started a Ninjascript help Please thread which seems perfect for covering a quick topic on NinjaTrader's SessionIterator. Thanks for the idea @GraDman and great avatar on YouTube, ha
Thanks for the video. I am wondering about this code you posted in GraDman's thread, why do you use the "base." and "this." prefix in the OnBarUpdate? And why calling the base.OnBarUpdate(); within the OnBarUpdate()?
I use those prefixes to help me learn and remember where objects are located in the hierarchy. For example, anything with "this." prefix means that it was referring to something created in that specific/actual class. I use "base." when I am referencing objects in the Indicator base class(es). This is a pure syntax organization of mine and I think anywhere I've used a "base.", you could use a "this.".
I will caveat the above with those are not static objects. Whenever I refer to a static object, I try to use the actual class that it is in. For me, this helps readability when I come back to this code months later. I know if I see something like "IndicatorExtensions.IsInSession(some time parameter)", that "IsInSession" is a static method contained in the IndicatorExtensions class.
A long version of me saying it's purely for readability. Is it knit-picky, absolutely but any C# developer will be able to actually read my code and understand how things are structured and where to find stuff easily with F12'ing all over the place.
I just finished recording a quick "feature demo" video on NT's SessionIterator that I will start editing and post later this week. You'll be able to see more examples of my explanation in that video.
edit: forgot to answer this
This is done because of the polymorphism principle in object oriented programming. Any time you override a method or class, you should call its base "version". Constructors are like this as well as methods (and other things as well).
Broker: NT Brokerage, Kinetick, IQFeed, Interactive Brokers
Trading: ES
Posts: 159 since Dec 2014
Thanks Given: 40
Thanks Received: 166
Actually going back and looking at the code snippet I posted, those prefixes seem super tedious. I should've mentioned how handy it becomes when you have a class that is 1500+ lines of code (easy to do in a strategy). It becomes so much more useful in that scenario to know where objects reside so you aren't constantly bouncing around (which just slows down workflow).
The only thing which i don't understand is the call to Base.OnBarUpdate within the OnBarUdate. At first sight, i thought it would create a recursive loop that never end. As you can see, Ninjascripting is a new pursuit of mine so i might have basic questions at times. Thanks for your time.
It's been a long time since I looked at ninjascript but base.Method() just calls the abstract or virtual method implemented in the abstract class that you are inheriting, which is mostly likely empty, and probably even gets complied away. No worries about a stack overflow there.