The description of IsRemoveLastBarSupported is follows:
"Determines if the bars type can use the RemoveLastBar() method when true, otherwise an exception will be thrown. Bar Types which use remove last bar concepts CANNOT be used with Tick Replay, and as a result Tick Replay will be disabled on the UI when IsRemoveLastBarSupported is set to true."
Since the code is not calling RemoveLastBar(), what is the purpose of looking at IsRemoveLastBarSupported? What's the difference in the two sets of code and why is it required?
protected override void OnBarUpdate() { if (BarsArray[0].BarsType.IsRemoveLastBarSupported) { if (CurrentBar == 0) Value[0] = Input[0]; else { int back = Math.Min(Period - 1, CurrentBar); double val = 0; int weight = 0; for (int idx = back; idx >= 0; idx--) { val += (idx + 1) * Input[back - idx]; weight += (idx + 1); } Value[0] = val / weight; } } else { if (IsFirstTickOfBar) { priorWsum = wsum; priorSum = sum; myPeriod = Math.Min(CurrentBar + 1, Period); } wsum = priorWsum - (CurrentBar >= Period ? priorSum : 0) + myPeriod * Input[0]; sum = priorSum + Input[0] - (CurrentBar >= Period ? Input[Period] : 0); Value[0] = wsum / (0.5 * myPeriod * (myPeriod + 1)); } }
Comment