NexusFi: Find Your Edge


Home Menu

 





Test Driven Development


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one shansen with 4 posts (0 thanks)
    2. looks_two jerbersoft with 2 posts (1 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 gomi with 1 posts (1 thanks)
    1. trending_up 3,473 views
    2. thumb_up 2 thanks given
    3. group 3 followers
    1. forum 7 posts
    2. attach_file 3 attachments




 
Search this Thread

Test Driven Development

  #1 (permalink)
 shansen 
Melbourne, Australia
 
Experience: Intermediate
Platform: NinjaTrader
Trading: ES
Posts: 18 since Aug 2013
Thanks Given: 2
Thanks Received: 5

nexusfi.com (formerly BMT) Forum,

Happy to report I am successfully using Visual Studio Pro 2013 (VS2013) as my Integrated development environment (IDE) for NT. Thanks to all posters who have illuminated the way.

This was achieved by:
1) Open NinjaTrader.Custom in VS2013 ( )
2) Construct an AutoHotKey script to easily compile in NT from VS2013 ( )
3) Set up version control with MS Team Foundation Server ( Visual Studio Online Basic) Free for five users.

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.

 
Code
namespace NinjaTrader.Indicator.<IndicatorName>.Tests
{
  [TestClass()]
  public class <InnerClassNameTests>
  {
    [TestMethod()]
    public void <MethodNameTest>()
    {
      //-- Arrange
        //  Struggling to instantiate <IndicatorName> or <InnerClassName>      
        //  e.g. var instance = new NinjaTrader.Indicator.<IndicatorName>();       
      //-- Act
      //-- Assert       
    }
  }
}
Any assistance or guidance would be appreciated.
Regards
Shannon

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Deepmoney LLM
Elite Quantitative GenAI/LLM
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
37 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #3 (permalink)
 
jerbersoft's Avatar
 jerbersoft 
Manila, Philippines
 
Experience: Beginner
Platform: CQG,Bookmap,Sierra Chart
Broker: CQG
Trading: BUND
Posts: 59 since Apr 2014
Thanks Given: 47
Thanks Received: 26


hi shannon, what is the exact error message? maybe i might be able to help.

"You are only as good as the decisions you make."
Follow me on Twitter Reply With Quote
  #4 (permalink)
 shansen 
Melbourne, Australia
 
Experience: Intermediate
Platform: NinjaTrader
Trading: ES
Posts: 18 since Aug 2013
Thanks Given: 2
Thanks Received: 5

jerbersoft,

Thanks for your response.

To help explain my predicament, please find attached two screenshots.
  1. "NinjaTrader.Indicator.Phase.SmaRepository" which depicts the Indicator "Phase140109" using peak to show the nested helper class "SmaRepository" and one of its methods "AddCross".
  2. "NinjaTrader.Indicator.Phase.Tests" which depicts my attempt at the unit test "AddCrossTest"

There is no error as such aside from the message "Cannot resolve symbol "_smaCollection" when hovering over the line "_smaCollection = new SmaRepository();".

Should it be of assistance, the screenshots include the references of of NinjaTrader.CustomTests.

Any assistance would be greatly appreciated.

Thanks again
Shannon

Attached Thumbnails
Click image for larger version

Name:	NinjaTrader.Indicator.Phase.SmaRepository.PNG
Views:	105
Size:	44.2 KB
ID:	150293   Click image for larger version

Name:	NinjaTrader.Indicator.Phase.Tests.PNG
Views:	99
Size:	38.1 KB
ID:	150294  
Started this thread Reply With Quote
  #5 (permalink)
 gomi 
Paris
Market Wizard
 
Experience: None
Platform: NinjaTrader
Posts: 1,270 since Oct 2009
Thanks Given: 282
Thanks Received: 4,505

try
using NinjaTrader.Indicator;

and instantiating Phase140109.SmaRepository()

your class is nested in another class..

Reply With Quote
Thanked by:
  #6 (permalink)
 
jerbersoft's Avatar
 jerbersoft 
Manila, Philippines
 
Experience: Beginner
Platform: CQG,Bookmap,Sierra Chart
Broker: CQG
Trading: BUND
Posts: 59 since Apr 2014
Thanks Given: 47
Thanks Received: 26

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.

try out:

var _smaRepository = new Phase140109.SmaRepository();

hope we have helped.

"You are only as good as the decisions you make."
Follow me on Twitter Reply With Quote
Thanked by:
  #7 (permalink)
 shansen 
Melbourne, Australia
 
Experience: Intermediate
Platform: NinjaTrader
Trading: ES
Posts: 18 since Aug 2013
Thanks Given: 2
Thanks Received: 5

gomi & jerbersoft,

Thank you for your input.

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.

Thanks again
Shannon

Started this thread Reply With Quote
  #8 (permalink)
 shansen 
Melbourne, Australia
 
Experience: Intermediate
Platform: NinjaTrader
Trading: ES
Posts: 18 since Aug 2013
Thanks Given: 2
Thanks Received: 5

jerbersoft,

I am very interested in your suggestion:

jerbersoft View Post
...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.

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.

Regards
Shannon

Attached Thumbnails
Click image for larger version

Name:	Indicator window.PNG
Views:	81
Size:	22.6 KB
ID:	150376  
Started this thread Reply With Quote




Last Updated on July 4, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts