コード例 #1
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            if (CurrentBars[0] < 0 || CurrentBars[1] < 0 || CurrentBars[2] < 0 || CurrentBars[3] < 0)
            {
                return;
            }

            Min15_KAMA.Set(KAMA(BarsArray[1], 2, 10, 30)[0]);
            Min30_KAMA.Set(KAMA(BarsArray[2], 2, 10, 30)[0]);
            Min60_KAMA.Set(KAMA(BarsArray[3], 2, 10, 30)[0]);
        }
コード例 #2
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            int    mALongLen       = 100; // Default setting for MALongLen
            int    mAMedLen        = 50;  // Default setting for MAMedLen
            int    mAShortLen      = 20;  // Default setting for MAShortLen
            Color  uptick          = Color.Blue;
            Color  downtick        = Color.Red;
            double currentEMALong  = EMA(BarsArray[0], mALongLen)[0];
            double currentEMAMed   = EMA(BarsArray[0], mAMedLen)[0];
            double currentEMAShort = EMA(BarsArray[0], mAShortLen)[0];

            if (CurrentBars[0] < 0 || CurrentBars[1] < 0 || CurrentBars[2] < 0 || CurrentBars[3] < 0)
            {
                return;
            }

            // decide if current chart time frame is long or short
            if (((currentEMAMed > currentEMALong) || (currentEMAShort > currentEMALong)))
            {
                Min15_KAMA.Set(10);
                PlotColors[0][0] = uptick;
                //if(CrossBelow(EMA(mAShortLen),currentEMALong,7))
                if (currentEMAShort < currentEMALong)
                {
                    PlotColors[0][0] = downtick;
                }
            }
            else if ((currentEMAMed < currentEMALong) || (currentEMAShort < currentEMALong))
            {
                Min15_KAMA.Set(10);
                PlotColors[0][0] = downtick;
            }
            else
            {
                Min15_KAMA.Set(10);
                PlotColors[0][0] = Color.Green;
            }

            currentEMAShort = EMA(BarsArray[1], mAShortLen)[0];
            currentEMAMed   = EMA(BarsArray[1], mAMedLen)[0];
            currentEMALong  = EMA(BarsArray[1], mALongLen)[0];

            // decide if 1 time frame higher is long or short
            if (((currentEMAMed > currentEMALong) || (currentEMAShort > currentEMALong)))
            {
                Min30_KAMA.Set(0);
                PlotColors[1][0] = uptick;
                //if(CrossBelow(EMA(mAShortLen),currentEMALong,7))
                if (currentEMAShort < currentEMALong)
                {
                    PlotColors[1][0] = downtick;
                }
            }
            else if ((currentEMAMed < currentEMALong) || (currentEMAShort < currentEMALong))
            {
                Min30_KAMA.Set(0);
                PlotColors[1][0] = downtick;
            }
            else
            {
                Min30_KAMA.Set(0);
                PlotColors[1][0] = Color.Green;
            }


            //Min60_KAMA.Set(KAMA(BarsArray[3], 2, 10, 30)[0]);
        }