Both usages are set to CalculateOnBarClose = false
The time frames are 2 minute, 4 minutes, 6 minutes.
Market Analyzer set to 2 minutes.
Using 24/7 default in MA properties and chart, ES 3-13 2 min.
I built a debugging statement to see what is happening.
Here is sample debugging outputs of that line for the same tick from each usage
Print(" c1n " +CurrentBars[0] + " c2n " + CurrentBars[1] + " c3n " + CurrentBars[2]);
From Chart Indicator:
c1n 12268 c2n 3882 c3n 1312
From Market Analyzer indicator for look back 200
c1n 254 c2n 199 c3n 199
You can see the count ratios are related to that for the chart indicator values.
But the values in the MA indicator instance for 4 minute and 6 minute are not updated
They should be appropriately 254, 218, 206
The CurrentBars[1] and CurrentBars[2] will update slowly if I run Replay
for long time but are still not correct
Here are the values after running replay for another 146 minutes worth of Replay data
c1n 12341 c2n 3906 c3n 1320
c1n 328 c2n 200 c3n 200
Both CurrentBars[0] values are correct, but the CurrentBars[1] and
CurrentBars[2] for the MA indicator has barely budged.
Changing Look back value in MA properties and MA indicator reference to 1000 did not fix things
The problem seems to be that MA does not like the Initialize() code that is OK in a Chart
and aborts with an error some times "Add method only accepts positive value but value was -3 min"
and other times about bad object reference.
Here is the initialize() code which is OK in the Chart usage.but aborts in MA
===
protected override void Initialize()
{
CalculateOnBarClose = false;
Overlay = true;
PriceTypeSupported = false;
BarsRequired = barsReq;
Print("Initialize open " );
tpSignal = new DataSeries (this);
Add(new Plot(Color.FromKnownColor(KnownColor.SlateBlue), PlotStyle.Bar, "BuySell"));
// Plots[0].PanelUI = 1; // nope doesn't work
if (secondInstDupe == true)
secondInstrument = Instrument.FullName; // force identical
string pType = BarsPeriod.BasePeriodType.ToString();
var pBaseType = BarsPeriod.BasePeriodType;
string tunit = BarsPeriod.ToString(); // e.g. "3 Min"
string tId = BarsPeriod.Id.ToString();
Print("Initialize period length = " + tunit);
int iPos=tunit.IndexOf(" ");
if (iPos!=-1) {
tunit=tunit.Substring(0,iPos);
// Print("Initialize period Type = " + pType + ", <" + tunit + ">");
baseSize = Convert.ToInt32(tunit);
Print("Initialize period Type = " + pType + ", <" +
tunit + "> baseSize " + " ID<" + tId + "> " +
+ baseSize);
}
// Add(secondInstrument, pBaseType, baseSize);
int b2count = (int) (bigMult * baseSize);
int b3count = (int) (bigMult * bigMult * baseSize);
Print("Initialize period 2 & 3 length = " + b2count + " " +
b3count);
Add(secondInstrument, BarsPeriod.Id, b2count);
Add(secondInstrument, BarsPeriod.Id, b3count);
}
How can I get Initialize to perform in MA the same way as in the Chart usage
Thanks in advance
Roland
Comment