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

Unit tests using Visual Studio

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

    Unit tests using Visual Studio

    I am trying to write unit tests for my indicators and strategies. For this, I have created a new Test project in Visual Studio and added the following two references: NinjaTrader.Core and WilsonORMapper.

    In order to use predictable data to test with, I am attempting to create a Bars class and populate it with bars. Here is a snippet of my code:

    Code:
            public static Bars MakeChart(string[] matrix)
            {
                DateTime today = DateTime.Today;
                Period period;
                MasterInstrument mi;
                Instrument instrument;
                Bars bars;
    
                period = new Period(PeriodType.Day, 1, MarketDataType.LastClose);
                mi = new MasterInstrument("TST", InstrumentType.Future);
                instrument = new Instrument(mi, Exchange.Amex, today.AddYears(1), 4, Right.Call);
                bars = new Bars(instrument, period, today, today.AddDays(matrix.Length), true, true);
    
                ...
           }
    The problem is that this code compiles well, but when run, immediately crashes with the following error:

    Code:
    A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
    A first chance exception of type 'System.TypeInitializationException' occurred in ConsoleApplication1.exe
    An unhandled exception of type 'System.TypeInitializationException' occurred in ConsoleApplication1.exe
    Additional information: The type initializer for '<Module>' threw an exception.
    I've narrowed this problem down to the declaration of any of the NinjaTrader classes, e.g. Period, MasterInstrument or any other. The mere declaration of the variable causes the crash, so it doesn't even get to the initialization of it.

    Is there some kind of a mandatory initialization that I have to include in order to be able to use any components from NinjaTrader.Core, outside of the NinjaTrader editor?

    I am open to any dirty hacks any workarounds.

    Thanks.

    #2
    Hello xsgex,

    Thank you for your post.

    This would be outside the scope of support we can provide here. However, one of our forum members may have information on what you are attempting to do here.

    Please let me know if you have any questions that I may answer.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by gravdigaz6, Today, 11:40 PM
    0 responses
    6 views
    0 likes
    Last Post gravdigaz6  
    Started by MarianApalaghiei, Today, 10:49 PM
    3 responses
    10 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by XXtrader, Today, 11:30 PM
    0 responses
    4 views
    0 likes
    Last Post XXtrader  
    Started by love2code2trade, Yesterday, 01:45 PM
    4 responses
    28 views
    0 likes
    Last Post love2code2trade  
    Started by funk10101, Today, 09:43 PM
    0 responses
    9 views
    0 likes
    Last Post funk10101  
    Working...
    X