In the Ninjatrader 8 Help Guide Ninjascript Best Practices you have the following section that I would like some clarification on.
================================================== ================================================
Setting class level variables
Do not set variables at the class level unless they are constant.
You should delay setting or resetting variables until the State has reached State.Configure.
You can use const keyword to differentiate values which do not change from variables which do change.
Why: Waiting to set up and define resources until the object has been configured
ensures that values not set up and declared prematurely.
================================================== ================================================
In the above section when you say delay setting or resetting class variables until State.Configure
do you mean we shouldn't set or reset variables :
1) defined within custom classes like Var1 in class A as shown below
2) defined in the indicator class like Var2 shown below
3) when creating the reference thingy in class B and
instantiating the object A as shown below
4) defined in the indicator class like when creating
the reference object1 to class B and instantiating
the object B as shown below
Or if it's something else please explain.
namespace NinjaTrader.NinjaScript.Indicators
{
public class example : Indicator
{
public class A
{
int Var1 = 0;
}
public class B
{
A thingy = new A();
}
B object1 = new object1();
int Var2 = 0;
}
}
Comment