/// <summary> /// Action to be executd for calculating indicator /// </summary> /// <returns>for future usage. Must be ignored at this time.</returns> protected override bool TrueAction() { // Validate int size = _chartPanel._chartX.RecordCount; if (size == 0) { return(false); } if (ParamInt(1) < 1 || ParamInt(1) > size / 2) { ProcessError("Invalid Periods for indicator " + FullName, IndicatorErrorType.ShowErrorMessage); return(false); } if (ParamInt(2) < 0 || ParamInt(2) > 10) { ProcessError("Invalid Standard Deviations for indicator " + FullName, IndicatorErrorType.ShowErrorMessage); return(false); } if (ParamInt(3) < (int)Constants.MA_START || ParamInt(3) > (int)Constants.MA_END) { ProcessError("Invalid Moving Average Type for indicator " + FullName, IndicatorErrorType.ShowErrorMessage); return(false); } Field pSource = SeriesToField("Source", ParamStr(0), size); if (!EnsureField(pSource, ParamStr(0))) { return(false); } Navigator pNav = new Navigator(); Recordset pRS = new Recordset(); pRS.AddField(pSource); pNav.Recordset_ = pRS; // Calculate the indicator Bands ta = new Bands(); Recordset pInd = ta.BollingerBands(pNav, pSource, ParamInt(1), ParamInt(2), (IndicatorType)ParamInt(3)); // Output the indicator values Clear(); Series series = _chartPanel._chartX.GetSeriesByName(ParamStr(0)); TwinIndicator pTop = (TwinIndicator)EnsureSeries(FullName + " Top"); pTop.SetStrokeColor(StrokeColor, false); pTop.SetStrokeThickness(StrokeThickness, false); pTop.SetStrokePattern(_strokePattern, false); TwinIndicator pBottom = (TwinIndicator)EnsureSeries(FullName + " Bottom"); pBottom.SetStrokeColor(StrokeColor, false); pBottom.SetStrokeThickness(StrokeThickness, false); pBottom.SetStrokePattern(_strokePattern, false); int paramInt1 = ParamInt(1); for (int n = 0; n < size; ++n) { double?top; double?median; double?bottom; if (n < paramInt1) { top = null; median = null; bottom = null; } else { top = pInd.Value("Bollinger Band Top", n + 1); median = pInd.Value("Bollinger Band Median", n + 1); bottom = pInd.Value("Bollinger Band Bottom", n + 1); } AppendValue(series[n].TimeStamp, median); pTop.AppendValue(series[n].TimeStamp, top); pBottom.AppendValue(series[n].TimeStamp, bottom); } return(_calculateResult = PostCalculate()); }