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

Export assembly compilation error

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

    Export assembly compilation error

    I've created a custom BarsType that I would like to include in an export compiled assembly. Although the BarsType compiles successfully on its own, when I try to include it as part of a compiled assembly, the export compilation fails, I get the following error: error CS0246: The type or namespace name 'MinuteBarsType' could not be found (are you missing a using directive or an assembly reference?).
    The line in error is part of GetInitialLookBackDays code as shown below

    Code:
    public override int GetInitialLookBackDays(BarsPeriod barsPeriod, TradingHours tradingHours, int barsBack)
    {
    switch (BarsPeriod.BaseBarsPeriodType)
    {
    case BarsPeriodType.Day : return new DayBarsType() .GetInitialLookBackDays(barsPeriod, tradingHours, barsBack);
    case BarsPeriodType.Minute : return new MinuteBarsType() .GetInitialLookBackDays(barsPeriod, tradingHours, barsBack);
    case BarsPeriodType.Month : return new MonthBarsType() .GetInitialLookBackDays(barsPeriod, tradingHours, barsBack);
    case BarsPeriodType.Second : return new SecondBarsType() .GetInitialLookBackDays(barsPeriod, tradingHours, barsBack);
    case BarsPeriodType.Tick : return new TickBarsType() .GetInitialLookBackDays(barsPeriod, tradingHours, barsBack);
    case BarsPeriodType.Volume : return new VolumeBarsType() .GetInitialLookBackDays(barsPeriod, tradingHours, barsBack);
    case BarsPeriodType.Week : return new WeekBarsType() .GetInitialLookBackDays(barsPeriod, tradingHours, barsBack);
    case BarsPeriodType.Year : return new YearBarsType() .GetInitialLookBackDays(barsPeriod, tradingHours, barsBack);
    default : return new MinuteBarsType() .GetInitialLookBackDays(barsPeriod, tradingHours, barsBack);
    }
    }
    I don't believe I'm missing a using directive, but are there specific assembly references that I need to use?

    #2
    Hello toughcookie,

    Thank you for your note.

    Normally when you export a NinjaScript that references a system assembly, when that assembly is an indicator such as the SMA, Ninja will give you the option of adding the system NinjaScript file (e.g. SMA.cs) to your exported assembly. Since Ninja does not give you this option with BarsTypes there are some more steps that need to be taken.

    Steps to export an ASSEMBLY:
    • Navigate to the Documents\NinjaTrader 8\bin\Custom\ folder to find your system NinjaScript. For example, Documents\NinjaTrader 8\bin\Custom\BarsTypes\@HeikenAshiBarsType.cs
    • Rename this file to remove the "@" NinjaTrader will no longer identify the file as a System NinjaScript, and we can now export it
    • Export the custom BarsType that uses the System NinjaScript we just renamed, and also add the renamed System NinjaScript
    • After exporting, Rename the the System NinjaScript back so it includes the "@"
    In your case it looks like you'd need to temporarily rename several bars types - make very sure you name them all back after exporting.

    An alternative approach would be to clone the System NinjaScript and use your copy for exporting.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Thanks, Kate. You're a star!

      Comment


        #4
        As a follow-up question, are there any known problems when using Agile.NET with bars types in an export file? I created an export file that includes several indicators and my custom bars type. When I protect the dll using Agile, the indicators import OK, but I get an error message saying "bars type can't be created - ignoring".
        If I import the zip file without using Agile protection on the dll, the bars type imports successfully.

        Edited to add: just did a test of exporting the bars type on its own an applying Agile protection to the dll and this time the bars type imported successfully.
        Last edited by toughcookie; 02-27-2021, 02:04 PM.

        Comment


          #5
          Another update - that last test with the bars type imported on its own didn't work. A message was displayed saying that all elements had been successfully imported, but in fact there was an error message in the Control Center Log saying that the custom bars type had been ignored.

          Comment


            #6
            Apologies, you can ignore the above. I managed to solve it.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by PaulMohn, Today, 12:36 PM
            0 responses
            2 views
            0 likes
            Last Post PaulMohn  
            Started by love2code2trade, 04-17-2024, 01:45 PM
            4 responses
            38 views
            0 likes
            Last Post love2code2trade  
            Started by alifarahani, Today, 09:40 AM
            2 responses
            14 views
            0 likes
            Last Post alifarahani  
            Started by junkone, Today, 11:37 AM
            3 responses
            20 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by frankthearm, Yesterday, 09:08 AM
            12 responses
            44 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Working...
            X