Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IndicatorBase

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

    IndicatorBase

    Here MobjBase is my Strategy object

    internal IndicatorBase getIndicators(IndicatorBase myBase)
    {
    IndicatorBase indbase;

    System.Type indType = myBase.GetType ();
    IEnumerable<PropertyInfo> indicatorProperties = this.GetIndicatorProperties (indType);

    indbase = (IndicatorBase)Activator.CreateInstance(indType);
    indbase.BarsRequired = MobjBase.BarsRequired;

    indbase.CalculateOnBarClose = MobjBase.CalculateOnBarClose;

    indbase.ForceMaximumBarsLookBack256 = MobjBase.ForceMaximumBarsLookBack256;

    indbase.MaximumBarsLookBack = MobjBase.MaximumBarsLookBack;
    indbase.Input = MobjBase.Input;

    foreach (PropertyInfo info in indicatorProperties)
    {
    object obj2 = info.GetValue(myBase, null);
    info.SetValue(indbase, obj2, null);
    }

    base.Indicators.Add(indbase);
    indbase.SetUp();
    return indbase;
    }


    The above code is working in Ninja Trader 7. I converted these codes to Ninja Trader 8 as below


    internal NinjaTrader.NinjaScript.IndicatorBase getIndicators(NinjaTrader.NinjaScript.IndicatorBas e myBase)
    {
    NinjaTrader.NinjaScript.IndicatorBase indbase;

    System.Type indType = myBase.GetType();
    IEnumerable<PropertyInfo> indicatorProperties = this.GetIndicatorProperties(indType);

    indbase = (NinjaTrader.NinjaScript.IndicatorBase)Activator.C reateInstance(indType);
    indbase.BarsRequiredToPlot = MobjBase.BarsRequiredToPlot;
    indbase.Calculate = MobjBase.Calculate;

    indbase.ForcePlotsMaximumBarsLookBackInfinite =
    MobjBase.ForcePlotsMaximumBarsLookBackInfinite;

    indbase.MaximumBarsLookBack = MobjBase.MaximumBarsLookBack;
    indbase.Input = MobjBase.Input;

    foreach (PropertyInfo info in indicatorProperties)
    {
    object obj2 = info.GetValue(myBase, null);
    info.SetValue(indbase, obj2, null);
    }

    base.Indicators.Add(indbase);
    indbase.SetUp();
    return indbase;

    }


    But the following errors are shows.

    1.Property or indexer NinjaTrader.NinjaScript.NinjaScriptBase.Input cannot be assigned to – it is read only.

    2. NinjaTrader.NinjaScript.Strategies.Strategy does not contain definition for Indicators

    3. NinjaTrader.NinjaScript.IndicatorBase does not contain definition for ‘Setup’ and no extension method ‘Setup’ accepting a first argument of type ‘NinjaTrader.NinjaScript.IndicatorBase’ could be found(are you missing a using directive or an assembly reference?)

    #2
    This is some pretty heavily undocumented stuff, so I have not fully tested my suggestions, please proceed with caution and let me know if you have issues

    Originally posted by rmk View Post
    But the following errors are shows.

    1.Property or indexer NinjaTrader.NinjaScript.NinjaScriptBase.Input cannot be assigned to – it is read only.
    Code:
    indbase.Inputs[0] = MobjBase.Input;
    Originally posted by rmk View Post
    2. NinjaTrader.NinjaScript.Strategies.Strategy does not contain definition for Indicators
    Code:
    lock (NinjaScripts)
        NinjaScripts.Add(indbase);
    Originally posted by rmk View Post
    3. NinjaTrader.NinjaScript.IndicatorBase does not contain definition for ‘Setup’ and no extension method ‘Setup’ accepting a first argument of type ‘NinjaTrader.NinjaScript.IndicatorBase’ could be found(are you missing a using directive or an assembly reference?)
    Code:
    indbase.SetState(State.Configure);
    MatthewNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

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