Example #1
0
        /// <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 iSize = _chartPanel._chartX.RecordCount;

            if (iSize == 0)
            {
                return(false);
            }

            int paramInt1 = ParamInt(1);

            if (paramInt1 < 3 || paramInt1 > iSize / 2)
            {
                ProcessError("Invalid Long Cycle for indicator " + FullName, IndicatorErrorType.ShowErrorMessage);
                return(false);
            }
            int paramInt2 = ParamInt(2);

            if (paramInt2 < 2 || paramInt2 > iSize / 2 || paramInt2 >= paramInt1)
            {
                ProcessError("Invalid Short Cycle for indicator " + FullName, IndicatorErrorType.ShowErrorMessage);
                return(false);
            }
            IndicatorType param3 = (IndicatorType)ParamInt(3);

            if (param3 < Constants.MA_START || param3 > Constants.MA_END)
            {
                ProcessError("Invalid Moving Average Type for indicator " + FullName, IndicatorErrorType.ShowErrorMessage);
                return(false);
            }

            // Get the data
            string paramStr0 = ParamStr(0);
            Field  pSource   = SeriesToField("Source", paramStr0, iSize);

            if (!EnsureField(pSource, paramStr0))
            {
                return(false);
            }

            Navigator pNav = new Navigator();
            Recordset pRS  = new Recordset();

            pRS.AddField(pSource);
            pNav.Recordset_ = pRS;


            // Calculate the indicator
            Oscillator ta   = new Oscillator();
            Recordset  pInd = ta.PriceOscillator(pNav, pSource, paramInt1, paramInt2, param3, FullName);


            // Output the indicator values
            Clear();
            for (int n = 0; n < iSize; ++n)
            {
                AppendValue(DM.TS(n), n < paramInt1 ? null : pInd.Value(FullName, n + 1));
            }
            return(_calculateResult = PostCalculate());
        }