Now, in the vein of Test Driven Development (TDD) I am trying to write tests for indicators.
I have hit a brick wall ! As per the below code, I have successfully created the template for a test:
- It has a reference to NinjaTrader.Custom.
- However, IntelliSense is alerting me of an issue when I attempt to add the statement "using NinjaTrader.Custom"
- I am struggling to instantiate an indicator so that I may test its methods.
Any assistance or guidance would be appreciated.
looks like your class SmaRepository is nested inside Phase140109 class as what gomi points out. at least that is what we see in your screenshot. i don't know but on your screenshot there might be a syntax error (i'm pretty much sensitive on syntax being a programmer myself).
i suggest separating your classes to individual files (.cs files). for example, add a file named SmaRepository.cs containing only the SmaRepository class. this should help make your solution manageable.
var _smaRepository = new Phase140109.SmaRepository();
hope we have helped.
"You are only as good as the decisions you make."
The following user says Thank You to jerbersoft for this post:
You are both correct, the parent class (i.e. Phase140109) is required. Apologies for my oversight.
In addition to the omitting the parent class, it would seem the similarity between the two namespaces (i.e. NinjaTrader.Indicator and NinjaTrader.Indicator.Phase140109.Tests) was causing a conflict. While in my many attempts I did trial "new Phase140109.SmaRepository()", it was unsuccessful. The problem was resolved by changing the test namespace (in addition to including the parent class in the declaration). Tests are now housed in the namespace NinjaTrader.CustomTests.Indicator.
I would love to implement your suggestion but have several concerns:
1. SmaRepository is a helper class of the Phase class (Indicator). It is my understanding, if a class is useful to only one other class, then it is logical to embed it in that class and keep the two together (Nested Classes). As my list of nested classes grows, I agree the solution becomes more and more unruly.
Where the nested class SmaRepository is separated into its own .cs file, what structure do you implement to highlight it is a helper class the Phase class (Indicator)? Do you alter the namespace housing the newly split out SmaRepository Class to highlight its helper nature? How does the Indicator in question know how to access the helper classes, a using statement, a reference, both)?
2. It is my understanding all .cs files located in the directory ...\NinjaTrader 7\bin\Custom\Indicator will appear in the NT Indicator window (screenshot attached). Where do you file any helper class .cs files so:
1) they do not appear in the NT Indicator window,
2) remain organizationally tied to the Indicator in question (are they filed in an appropriately named folder "Phase helper classes"? Are they or their housing folder filed inside our outside the folder ...\NinjaTrader 7\bin\Custom\Indicator or somewhere completely different?)
I would love to separate out my nested classes and make my solution more manageable, but have no idea how. I am caught between trying to implement what I have read is "best practice" and my lack of experience to know any better. Any insight on the above concerns or approaches to address them would be greatly appreciated.