Пример #1
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            /// ensure bar has EmProps
            if (props is IEmProps)
            {
                /// get EmProps for the specified bar, matching on OHLCVT
                EmProps barProps = props.GetEmProps(Open[0], High[0], Low[0], Close[0], (long)Volume[0], Time[0]) as EmProps;

                /// ensure EmProps exist for given bar (note: some historical data may not be available)
                if (barProps == null)
                {
                    return;
                }

                /// update plots
                Surge.Set(barProps.Surge);
                Tide.Set(barProps.Tide);
                ErrorCount.Set(barProps.ErrorCount);
                ErrorVolume.Set(barProps.ErrorVolume);

                /// update average
                TideAvg.Set(EmMath.EMA((double)barProps.Tide, CurrentBar, smooth, CurrentBar == 0 ? Tide[0] : TideAvg[1]));
            }
            else
            {
                /// generate log message one time
                if (!invalid)
                {
                    Log(String.Format("{0} does not implement interface IEmProps", Bars.BarsType.ToString()), LogLevel.Warning);
                    invalid = true;
                }
            }
        }
Пример #2
0
        void DrawPlots()
        {
            /// get EmProps for the specified bar, matching on OHLCVT
            EmProps barProps = props.GetEmProps(Open[0], High[0], Low[0], Close[0], (long)Volume[0], Time[0]) as EmProps;

            /// ensure EmProps exist for given bar (note: some historical data may not be available)
            if (barProps == null)
            {
                return;
            }

            /// update barId so this only fires once per bar
            barId = CurrentBar;

            /// local variables
            double bear  = barProps.BearClose;
            double bull  = barProps.BullClose;
            double close = barProps.Close;

            /// draw bear close
            if (close != bear)
            {
                DrawLine("ebtClosePlotsBear_" + CurrentBar, true, 0, bear, -1, bear, bearColor, DashStyle.Dash, 2);
            }

            /// draw bull close
            if (close != bull)
            {
                DrawLine("ebtClosePlotsBull_" + CurrentBar, true, 0, bull, -1, bull, bullColor, DashStyle.Dash, 2);
            }

            /// add debug to output window
            if (showDebug)
            {
                Print(string.Format("Bar {0} => {1}", CurrentBar, barProps));
            }
        }
Пример #3
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            /// ensure bar has EmProps
            if (props is IEmProps)
            {
                /// get EmProps for the specified bar, matching on OHLCVT
                EmProps barProps = props.GetEmProps(Open[0], High[0], Low[0], Close[0], (long)Volume[0], Time[0]) as EmProps;

                /// ensure EmProps exist for given bar (note: some historical data may not be available)
                if (barProps == null)
                {
                    return;
                }

                /// update plots
                BearCount.Set(-barProps.BearCount);
                BearVolume.Set(-barProps.BearVolume);
                BullCount.Set(barProps.BullCount);
                BullVolume.Set(barProps.BullVolume);
                ErrorCount.Set(barProps.ErrorCount);
                ErrorVolume.Set(barProps.ErrorVolume);

                /// draw shading
                if (CurrentBar > 0)
                {
                    DrawRegion("EmVolume_Bull_" + CurrentBar.ToString(), 1, 0, BullVolume, BullCount, Color.Transparent, BullColor, BullOpacity);
                    DrawRegion("EmVolume_Bear_" + CurrentBar.ToString(), 1, 0, BearVolume, BearCount, Color.Transparent, BearColor, BearOpacity);
                    DrawRegion("EmVolume_Zero_" + CurrentBar.ToString(), 1, 0, BullCount, BearCount, Color.Transparent, ErrorColor, ErrorOpacity);
                }
            }
            else
            {
                /// generate log message one time
                if (!invalid)
                {
                    Log(String.Format("{0} does not implement interface IEmProps", Bars.BarsType.ToString()), LogLevel.Warning);
                    invalid = true;
                }
            }
        }
Пример #4
0
        protected override void OnBarUpdate()
        {
            /// ensure bar has EmProps
            if (props is IEmProps)
            {
                /// only fire once per bar
                if (barId == CurrentBar)
                {
                    return;
                }

                /// get EmProps for the specified bar, matching on OHLCVT
                EmProps barProps = props.GetEmProps(Open[0], High[0], Low[0], Close[0], (long)Volume[0], Time[0]) as EmProps;

                /// ensure EmProps exist for given bar (note: some historical data may not be available)
                if (barProps == null)
                {
                    return;
                }

                /// add debug to output window
                if (showDebug)
                {
                    Print(string.Format("Bar {0} => {1}", CurrentBar, barProps));
                }

                /// update barId so this only fires once per bar
                barId = CurrentBar;

                /// assign local variables from current bar EmProps and offset
                double bear = Instrument.MasterInstrument.Round2TickSize(barProps.BearClose - TickSize * Offset);
                double bull = Instrument.MasterInstrument.Round2TickSize(barProps.BullClose + TickSize * Offset);

                /// draw objects based on DisplayType
                switch (DisplayType)
                {
                case EmSamplesDisplayType.Lines:
                {
                    DrawLine(CurrentBar + "_BearClose", true, 0, bear, -1, bear, bearColor, DashStyle.Dash, 2);
                    DrawLine(CurrentBar + "_BullClose", true, 0, bull, -1, bull, bullColor, DashStyle.Dash, 2);
                }
                break;


                case EmSamplesDisplayType.Plots:
                default:
                {
                    BearClose.Set(bear);
                    BullClose.Set(bull);
                }
                break;
                }
            }
            else
            {
                /// generate log message one time
                if (!invalid)
                {
                    Log(String.Format("{0} does not implement interface IEmProps", Bars.BarsType.ToString()), LogLevel.Warning);
                    invalid = true;
                }
            }
        }