Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Coherency Test Indicator Conversion from 7 to 8

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

    Coherency Test Indicator Conversion from 7 to 8

    Hi, I'm trying to convert the NT7 c-test indicator from the NinjaTrader user-app-share site to NT8 Format. I have partial converted the indicator, but not sure how to start changing the private IndicatorBase? I get errors at line 128. I'm attaching the conversion I have so far. Maybe someone could direct me. Once we get it, I will load it to the user-app-share site for all to use.
    Thanks,
    Attached Files

    #2
    Hello woodyfox,

    This would be undocumented and code I am not familiar with.

    What is this code in the CreateInstance() method meant to do?

    is this just meant to call other indicators? (If so, this may not be necessary)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi ChelseaB,
      Yes that is exactly what the it does, calls other indicators. This is an indicator that i'm trying to convert to NT8. The NT7 Version is located on the NinjaTrader user-app-share site. This indicator is based on the C-test created by William Eckhardt. Its meant to help evaluate indicators based on a methodological test for dimensional coherency. I'm looking for direction with converting the lower part of the code, and I get an error at line 128. So...if anybody on the Forum could help guide me on this, I will post the indicator on the user-share site when its completed.
      Thanks,

      I have attached the NT7 Working Version and the NT8 I have so far.
      Attached Files

      Comment


        #4
        Hi woodyfox,

        here is what I've come up with because Input cannot be assigned: create an instance of the indicator, make it set its default values and then invoke the regular indicator instantiation method with said parameter values.

        This step seems fine but the coherence test fails.

        Requires System.Reflection and System.Collections
        Code:
                private IndicatorBase CreateInstance(string indicatorName, ISeries<double> inputSeries)
                {
                    Type indicatorType = Type.GetType("NinjaTrader.NinjaScript.Indicators." + indicatorName);
                    if (indicatorType == null)
                    {
                        return null;
                    }                    
                    IndicatorBase dummyIndicatorBase = (IndicatorBase) Activator.CreateInstance(indicatorType);
                    dummyIndicatorBase.SetState(State.SetDefaults);
        
                    MethodInfo indicatorMethod = GetType().GetMethods().First(
                        method => indicatorName.Equals(method.Name)
                            && method.GetParameters().FirstOrDefault(parameter => "input".Equals(parameter.Name.ToLower())) != null
                    );
                    ArrayList parameterValues = new ArrayList();
                    foreach(var parameter in indicatorMethod.GetParameters()) {
                        if("input".Equals(parameter.Name)) {
                            parameterValues.Add(inputSeries);
                            continue;
                        }
                        PropertyInfo propertyInfo = indicatorType.GetProperty(parameter.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
                        parameterValues.Add(propertyInfo.GetValue(dummyIndicatorBase));
                    }
                    IndicatorBase indicatorBase = (IndicatorBase)indicatorMethod.Invoke(this, parameterValues.ToArray());
                    indicatorBase.BarsRequiredToPlot = BarsRequiredToPlot;
                    indicatorBase.Calculate = Calculate.OnBarClose;
                    //indicatorBase.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                    indicatorBase.MaximumBarsLookBack = MaximumBarsLookBack;
                    //indicatorBase.Input = inputSeries;
                    //Indicators.Add(indicatorBase);
                    //indicatorBase.SetState();
                    return indicatorBase;
                }

        Comment

        Latest Posts

        Collapse

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