Esempio n. 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);
            }

            double paramDbl1 = ParamDbl(1);

            if (paramDbl1 <= 0)
            {
                ProcessError("Invalid Max AF for indicator " + FullName, IndicatorErrorType.ShowErrorMessage);
                return(false);
            }
            double paramDbl2 = ParamDbl(2);

            if (paramDbl2 <= 0)
            {
                ProcessError("Invalid Min AF for indicator " + FullName, IndicatorErrorType.ShowErrorMessage);
                return(false);
            }


            // Get the data
            string paramStr0 = ParamStr(0);
            Field  pHigh     = SeriesToField("High", paramStr0 + ".high", iSize);

            if (!EnsureField(pHigh, paramStr0 + ".high"))
            {
                return(false);
            }
            Field pLow = SeriesToField("Low", paramStr0 + ".low", iSize);

            if (!EnsureField(pLow, paramStr0 + ".low"))
            {
                return(false);
            }

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

            pRS.AddField(pHigh);
            pRS.AddField(pLow);

            pNav.Recordset_ = pRS;


            // Calculate the indicator
            Oscillator ta   = new Oscillator();
            Recordset  pInd = ta.ParabolicSAR(pNav, pHigh, pLow, paramDbl1, paramDbl2, FullName);


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