I have used Addon classes as suggested here, but with a slight change that might be causing the issue.
The issue is an error, but as far as I can see, the only issue is the error and nothing else, everything works as expected in spite of it.
Error:
| 22/04/2023 4:31:46 | NinjaScript | Unable to create instance of NinjaScript 'class_name'. Most likely either the implementation no longer exists, there is no default constructor defined, the default constructor does not work correctly, or the 'OnStateChange' implementation for State=SetDefaults is flawed: System.MissingMethodException: Constructor on type 'NinjaTrader.NinjaScript.AddOns.Classes.Patterns.f older_name.class_name' not found. at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Reflection.Assembly.CreateInstance(String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at NinjaTrader.Core.AssemblyRegistry.set_Item(String assemblyName, Assembly value) |
This Is is the base code used for all these extensions:
public class class_name: NinjaTrader.NinjaScript.AddOnBase
{
public Strategy _strategy;
private custom_addon_1;
private custom_addon_2;
private custom_addon_3;
private custom_indicator_1;
private default_indicator_1;
public class_name(Strategy strategy)
{
_strategy = strategy;
custom_addon_1 = _strategy.CustomAddon1();
custom_addon_2 = _strategy.CustomAddon2();
custom_addon_3 = _strategy.CustomAddon3();
custom_indicator_1 = _strategy.CustonIndicator1();
default_indicator_1 = _strategy.DefaultIndicator1(); // this could be for example SMA(200);
}
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @".";
}
}
bool someBoolValue = _strategy.Close[0].ApproxCompare(default_indicator_1[0]) == -1;
In the strategy code, i declare the addon class under the class block:
private AddonClass1 addon_class_1;
else if (State == State.DataLoaded)
{
addon_class_1= new AddonClass1( this );
}
Thanks for the continued support!
Aviram Y.

Comment