コード例 #1
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            if (CurrentBar < rSILen + 10)
            {
                return;
            }

            CummRSI_DS[1] = CummRSI;
            CummRSI       = 0;

            for (int i = 0; i < numDaysX; i++)
            {
                CummRSI = CummRSI + RSI(Close, 2, 1)[i];
            }

            CummRSI_DS[0] = CummRSI;

            //CummRSIPlot.Set(CummRSI);
            //Print("CummRSI = " + CummRSI + "  CummRSI_DS[1] = " + CummRSI_DS[1] + " CummRSI_DS[0] = " + CummRSI_DS[0]);
            if ((CummRSI_DS[1] >= cummRSIThres) && (CummRSI_DS[0] < cummRSIThres))
            {
                BuySignal.Set(5);
            }
            else
            {
                BuySignal.Set(0);
            }
        }
コード例 #2
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            // Use this method for calculating your indicator values. Assign a value to each
            // plot below by replacing 'Close[0]' with your own formula.
            double currentMacd;
            bool   buySignal1;
            bool   buySignal2;
            bool   buySignal3;
            bool   buySignal4;

            currentMacd = MACD(Close, mACDShortLen, mACDLongLen, 9)[0];

            if (CrossBelow(MACD(Close, mACDShortLen, mACDLongLen, 9), 0.03, 1))
            {
                macdDropUpperThres[0] = 1;
            }
            else
            {
                macdDropUpperThres[0] = 0;
            }

            if (CrossAbove(MACD(Close, mACDShortLen, mACDLongLen, 9), 0.02, 1))
            {
                macdCrossUpperThres[0] = 1;
            }
            else
            {
                macdCrossUpperThres[0] = 0;
            }


            buySignal3 = !CrossBelow(MACD(Close, mACDShortLen, mACDLongLen, 9), -0.06, 15);
            buySignal4 = EMA(Close, 20)[0] > EMA(Close, 100)[0];

            if (CrossAbove(macdDropUpperThres, 0.5, 10) && macdCrossUpperThres[0] == 1)
            {
                BuySignal.Set(Low[0]);
            }
            //if(macdDropUpperThres[0]==1)
            // SellSignal.Set(Low[0]);
        }