My Questions:
(Note: I'm using the term autogenerate, this is what I am calling the NinjaScript process of automatically adding additional c# code to the end of the indicator after compiling the indicator).
1. Why doesn't the indicator autogenerate an overloaded constructor?
2. What is the proper way to compile NinjaScript indicator and have it recognize the overloaded constructor and autogenerate correctly?
Problem: My strategy does not recognize my custom Indicator with an overloaded constructor.
Error Message
"No Overload for method 'MyIndicator' takes '4' arguments." - this is on compiling MyStrategy (Pseudo code below)
Trial and Error
I deleted and recreated both the indicator and the strategy, same error.
My thoughts:
- I have an indicator that has an overloaded constructor but I can't get my strategy to recognize the new constructor with 4 arguments.
-Although my indicator has an overloaded constructor, it is not in the auto generated ninjascript REGION at the end of the indicator. (the "region NinjaScript generated code. Neither change nor remove" )
My Pseudo code
My Indicator
namespace NinjaTrader.Indicator
{
Public Class MyIndicator : Indicator
{
private int field1;
private int field2;
private int field3;
private int field4;
Public MyIndicator (int x_param1, int x_param2, int x_param3, int x_param4)
{
this.field1 = x_param1;
this.field2 = x_param2;
this.field3 = x_param3;
this.field4 = x_param4;
}
}
}
MyStrategy
namespace NinjaTrader.Strategy
{
Public Class MyStrategy : Strategy
{
private int field1 = 1;
private int field2 = 2;
private int field3 = 3;
private int field4 = 4;
protected override void Initialize()
{
base.Add(MyIndicator(this.field1,this.field2,this. field3,this.field4));
}
}
}
Comment