According to documentation located here: https://ninjatrader.com/support/help.../?barbrush.htm, I am not supposed to use variables or coded methods to pass values into this function. According to documentation, these values must be hardcoded because reliability of using variables in the (State == State.Configure) of the OnStateChange() event is not reliable.
Unfortunately, I find myself in need of doing this very thing. In order to avoid writing a version of this indicator for every symbol and every timeframe of every symbol to hardcode the values into AddDataSeries, I am using variables, populated through code, so that only one indicator would be needed regardless of the charts period, bar type, or symbol.
On the (State == State.Configure) of the OnChageState event, I have the following code:
BarsPeriodType bt = this.Bars.BarsPeriod.BarsPeriodType;
AddDataSeries(bt, _DoubleBarPeriod);
Print("Double Bar Period = " +_DoubleBarPeriod.ToString());
Now on to the issue...
I am working on the understanding that the close value of each bar on a smaller timeframe will be different than the close value of larger timeframe of the same symbol. This is why the same indicator can plot with different values on different timeframes of the same chart. I need to obtain a LinearRegression of a series of closes on a time from twice as large as the chart to which the indicator is applied. I have tried using both Input and BarsArray[1]. of the Linear Regression function... Code as follows:
double myValue2 = LinReg(Input, _myPeriod)[0];
Print ("myValue = " + _myValue.ToString() + " myValue2 = " + myValue2.ToString());
myValue = 1500.90602150538 myValue2 = 1500.90602150538
myValue = 1501.21677419355 myValue2 = 1501.21677419355
myValue = 1501.53096774194 myValue2 = 1501.53096774194
myValue = 1501.84731182796 myValue2 = 1501.84731182796
myValue = 1502.16451612904 myValue2 = 1502.16451612904
myValue = 1502.48129032258 myValue2 = 1502.48129032258
myValue = 1502.79634408603 myValue2 = 1502.79634408603
myValue = 1503.10838709678 myValue2 = 1503.10838709678
myValue = 1503.41612903226 myValue2 = 1503.41612903226
myValue = 1503.7182795699 myValue2 = 1503.7182795699
myValue = 1504.0135483871 myValue2 = 1504.0135483871
myValue = 1504.3006451613 myValue2 = 1504.3006451613
myValue = 1504.5782795699 myValue2 = 1504.5782795699
myValue = 1504.84516129033 myValue2 = 1504.84516129033
myValue = 1505.10000000001 myValue2 = 1505.10000000001
myValue = 1505.34150537635 myValue2 = 1505.34150537635
myValue = 1505.56838709678 myValue2 = 1505.56838709678
Thanks in advance
Comment