Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

region ninjatrader generated code isn't generated

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

    region ninjatrader generated code isn't generated

    After compiling indicators on one of my pc's the region 'NinjaScript generated code. Neither change nor remove.' isn't generated, while on another pc it is.
    Both pc's run exactly the same NinjaTrader version 8.0.23.2.

    The problem with this is that whenI want to create a variable of another indicator indicator on the pc that has no NinjaScript generated code region I get a message 'NinjaTrader.NinjaScript.Indicator.myReferencedInd icator is a type but is used as a variable'.
    On the pc with that region everything compile fine.


    Example:

    The custom myReferencedIndicator has a 'Period' input (code not shown, but not important).
    I try to reference this indicator in another custom indicator like this:

    Code:
    public class myNewIndicator : Indicator
    {
        private myReferencedIndicator indi1;
    
        protected override void OnStateChange()
        {
            if (State==State.DataLoaded) {
                indi1 = myReferencedIndicator(14);
            }
        }
    }
    If I hover over myReferencedIndicator I also don't see the expected 'myReferencedIndicator(int period)' tooltip, but only 'class myReferencedIndicator'.

    I expect this is caused by the missing region, because that region defines a partial class for the 'Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase' class with the indicator constructors like this (which I see on the other pc that HAS the region):

    Code:
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
        {
            private myReferencedIndicator[] cachemyReferencedIndicator;
            public myReferencedIndicator myReferencedIndicator(int period)
            {
                return myReferencedIndicator(Input, period);
            }
    
            public myReferencedIndicator myReferencedIndicator(ISeries<double> input, int period)
            {
                if (cachemyReferencedIndicator != null)
                    for (int idx = 0; idx < cachemyReferencedIndicator.Length; idx++)
                        if (cachemyReferencedIndicator[idx] != null && cachemyReferencedIndicator[idx].Period == period && cachemyReferencedIndicator[idx].EqualsInput(input))
                            return cachemyReferencedIndicator[idx];
                return CacheIndicator<myReferencedIndicator>(new myReferencedIndicator(){ Period = period}, input, ref cachemyReferencedIndicator);
            }
        }
    }

    So I also tried adding the constructor of the above partial class to the myReferencedIndicator class on the pc without the region, but that didn't help.


    Anyone got an idea why one pc does generate the region during compile and the other doesn't?
    PS: to be complete: my indicator is based on another indicator.
    So the clas definition is not public class myNewIndicator : Indicator
    But its public class myNewIndicator : myOtherIndicator, where my OtherIndicator is based on Indicator.


    Anyone has a suggestion how to solve this on the pc without the region?
    Last edited by wjadevries; 02-24-2021, 04:03 AM.

    #2
    Hello wjadevries,

    Thank you for your post.

    Are you using Visual Studio to create the indicator? If so, are you compiling within Visual Studio or within the NinjaScript editor? The script would need to be compiled from the NS editor for those regions to be added.

    Thanks in advance; I look forward to assisting you further.

    Comment


      #3
      I DO compile with the NinjaScript editor but the region only comes in the base class, not in the inherited indicators.

      Comment


        #4
        Hello wjadevries,

        Thank you for your reply.

        After reviewing with my colleagues, this would be expected.

        NinjaTrader doesn't support inheritance, except with an AddOn script. In Strategies or Indicators it breaks the generated code and can cause issues with optimiaztions. We generally would suggest using partial classes instead of inheritance.

        This section of our help guide goes over using a partial class:


        Please let us know if we may be of further assistance to you.

        Comment


          #5
          That's a pity!
          A partial class is of course totally different from a base class for inheritance.
          As I understand the example in the help guide you mentioned, I could use it only for methods to call, not for generic behaviors in indicators (for instance in the OnStateChanged, OnBarUpdate and OnRender).
          Is inheritance in indicators somewhere on the roadmap or feature requests?
          Then add a +10 for me.

          Comment


            #6
            Hello wjadevries,

            Thank you for your reply.

            We do have a feature request for this currently, so I've added a vote on your behalf. This request is being tracked under the number SFT-5158.

            As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted in the Release Notes page of the Help Guide.

            Release Notes — https://ninjatrader.com/support/help...ease_notes.htm

            Please let us know if we may be of further assistance to you.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            571 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            330 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            548 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            548 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X