Пример #1
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            PlotConfirmation.Set(0);

            _currPrice = (decimal)(Open[0] + High[0] + Low[0] + Close[0]) / 4;

            TestForBoundaries();
            TestForTriggers();
            TestForConfirmations();
        }
Пример #2
0
        private void TestForConfirmations()
        {
            if (_triggerUpPrice == 0 || _triggerDownPrice == 0)
            {
                return;
            }

            DateTime lookbackTime = Time[0].Subtract(new TimeSpan(Hours, 0, 0));

            // check for highs over upper boundary
            // check for up trigger
            // check for timespan
            if (High[0] >= boundaryUpper && _triggerUpPrice == boundaryUpper - 0.0050 && _triggerUpDateTime >= lookbackTime)
            {
                _confirmationUpDateTime = Time[0];
                _confirmationUpPrice    = boundaryUpper;
                BackColor = Color.LightGreen;

                Print("UP " + _triggerUpPrice + " @ " + _triggerUpDateTime + " -> " + _confirmationUpPrice + " @ " + _confirmationUpDateTime);
                PlotConfirmation.Set(1);
            }



            // check for lows under lower boundary
            // check for low trigger
            // check for timespan
            if (Low[0] <= boundaryLower && _triggerDownPrice == boundaryLower + 0.0050 && _triggerDownDateTime >= lookbackTime)
            {
                _confirmationDownDateTime = Time[0];
                _confirmationDownPrice    = boundaryLower;
                BackColor = Color.Pink;

                Print("DOWN " + _triggerDownPrice + " @ " + _triggerDownDateTime + " -> " + _confirmationDownPrice + " @ " + _confirmationDownDateTime);
                PlotConfirmation.Set(-1);
            }
        }