// values[0] - Point CurrentMousePosition
        // values[1] - double VolumeHistogramHeight
        // values[2] - CandleExtremums visibleCandlesExtremums
        // values[3] - double VolumeHistogramTopMargin
        // values[4] - double VolumeHistogramBottomMargin
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values == null || values.Length < 5 || (values[0]).GetType() != typeof(Point) || (values[1]).GetType() != typeof(double) || (values[2]).GetType() != typeof(CandleExtremums) ||
                (values[3]).GetType() != typeof(double) || (values[4]).GetType() != typeof(double))
            {
                return((long)0);
            }

            Point           currentMousePosition        = (Point)values[0];
            double          volumeHistogramHeight       = (double)values[1];
            CandleExtremums visibleCandlesExtremums     = (CandleExtremums)values[2];
            double          volumeHistogramTopMargin    = (double)values[3];
            double          volumeHistogramBottomMargin = (double)values[4];
            string          fmt = values.Length >= 6 ? (string)values[5] : null;

            long calcVal = ((long)((visibleCandlesExtremums.VolumeHigh - (currentMousePosition.Y - volumeHistogramTopMargin) / (volumeHistogramHeight - volumeHistogramTopMargin - volumeHistogramBottomMargin) * visibleCandlesExtremums.VolumeHigh)));

            if (!string.IsNullOrEmpty(fmt))
            {
                return(calcVal.ToString(fmt));
            }
            else
            {
                return(calcVal.ToString());
            }
        }
Beispiel #2
0
        // values[0] - Point CurrentMousePosition
        // values[1] - double VolumeHistogramHeight
        // values[2] - CandleExtremums visibleCandlesExtremums
        // values[3] - double VolumeHistogramTopMargin
        // values[4] - double VolumeHistogramBottomMargin
        // values[5] - CultureInfo candleChartCulture
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values == null || values.Length < 5 || (values[0]).GetType() != typeof(Point) || (values[1]).GetType() != typeof(double) || (values[2]).GetType() != typeof(CandleExtremums) ||
                (values[3]).GetType() != typeof(double) || (values[4]).GetType() != typeof(double))
            {
                return(0.0);
            }

            Point           currentMousePosition        = (Point)values[0];
            double          volumeHistogramHeight       = (double)values[1];
            CandleExtremums visibleCandlesExtremums     = (CandleExtremums)values[2];
            double          volumeHistogramTopMargin    = (double)values[3];
            double          volumeHistogramBottomMargin = (double)values[4];

            CultureInfo candleChartCulture = (CultureInfo)values[5];
            string      decimalSeparator   = candleChartCulture.NumberFormat.NumberDecimalSeparator;

            char[] decimalSeparatorArray = decimalSeparator.ToCharArray();

            double volume = (((visibleCandlesExtremums.VolumeHigh - (currentMousePosition.Y - volumeHistogramTopMargin) / (volumeHistogramHeight - volumeHistogramTopMargin - volumeHistogramBottomMargin) * visibleCandlesExtremums.VolumeHigh)));

            return(MyNumberFormatting.VolumeToLimitedLengthString(volume, candleChartCulture, decimalSeparator, decimalSeparatorArray));
        }
Beispiel #3
0
 ///<summary>Draws this OverlayIndicator chart for a specified time span.</summary>
 ///<param name="drawingContext">Provides methods for drawing lines and shapes on the price chart area.</param>
 ///<param name="visibleCandlesRange">Specifies the time span currently shown on the price chart area. The range of the candles currently visible on the price chart.</param>
 ///<param name="visibleCandlesExtremums">The maximal High and minimal Low of the candles in visibleCandlesRange.</param>
 ///<param name="candleWidth">The Width of candle of the price chart, in device-independent units.</param>
 ///<param name="gapBetweenCandles">The Gap between candles of the price chart, in device-independent units.</param>
 ///<param name="RenderHeight">The height of the price chart area, in device-independent units.</param>
 ///<remarks>
 ///This is an analog of the <see href="https://docs.microsoft.com/en-za/dotnet/api/system.windows.uielement.onrender?view=netframework-4.7.2">UIElement.OnRender()</see> method.
 ///Participates in rendering operations that are directed by the layout system. The rendering instructions for this indicator are not used directly when this method is invoked, and are instead preserved for later asynchronous use by layout and drawing.
 ///</remarks>
 public abstract void OnRender(DrawingContext drawingContext, IntRange visibleCandlesRange, CandleExtremums visibleCandlesExtremums,
                               double candleWidth, double gapBetweenCandles, double RenderHeight);
        public object Convert(object candleExtremums_value, Type targetType, object parameter, CultureInfo culture)
        {
            CandleExtremums cndlExtr = (CandleExtremums)candleExtremums_value;

            return(new Point(cndlExtr.PriceLow, cndlExtr.PriceHigh));
        }
Beispiel #5
0
#pragma warning  restore CS1591
        //---------------------------------------------------------------------------------------------------------------------------------------
        ///<summary>Implements the <see cref="OverlayIndicator.OnRender"/> abstract method inherited from the <see cref="OverlayIndicator"/> base class.</summary>
        ///<param name="drawingContext">Provides methods for drawing lines and shapes on the price chart area.</param>
        ///<param name="visibleCandlesRange">Specifies the time span currently shown on the price chart area. The range of the candles currently visible on the price chart.</param>
        ///<param name="visibleCandlesExtremums">The maximal High and minimal Low of the candles in visibleCandlesRange.</param>
        ///<param name="candleWidth">The Width of candle of the price chart, in device-independent units.</param>
        ///<param name="gapBetweenCandles">The Gap between candles of the price chart, in device-independent units.</param>
        ///<param name="RenderHeight">The height of the price chart area, in device-independent units.</param>
        ///<remarks>
        ///This is an analog of the <see href="https://docs.microsoft.com/en-za/dotnet/api/system.windows.uielement.onrender?view=netframework-4.7.2">UIElement.OnRender()</see> method.
        ///Participates in rendering operations that are directed by the layout system. The rendering instructions for this indicator are not used directly when this method is invoked, and are instead preserved for later asynchronous use by layout and drawing.
        ///</remarks>
        public override void OnRender(DrawingContext drawingContext, IntRange visibleCandlesRange, CandleExtremums visibleCandlesExtremums,
                                      double candleWidth, double gapBetweenCandles, double RenderHeight)
        {
            double candleWidthPlusGap = candleWidth + gapBetweenCandles;
            double range                   = visibleCandlesExtremums.PriceHigh - visibleCandlesExtremums.PriceLow;
            double prevCndlCenterX         = 0;
            double prevLocalIndicatorValue = 0;

            int cndl_i0 = Math.Max(1, N - visibleCandlesRange.Start_i);

            if (cndl_i0 < visibleCandlesRange.Count)
            {
                prevCndlCenterX = (cndl_i0 - 1) * candleWidthPlusGap + 0.5 * candleWidth;
                double prevIndicatorValue = GetIndicatorValue(visibleCandlesRange.Start_i + cndl_i0 - 1);
                prevLocalIndicatorValue = (1.0 - (prevIndicatorValue - visibleCandlesExtremums.PriceLow) / range) * RenderHeight;
            }

            for (int cndl_i = cndl_i0; cndl_i < visibleCandlesRange.Count; cndl_i++)
            {
                double indicatorValue      = GetIndicatorValue(visibleCandlesRange.Start_i + cndl_i);
                double localIndicatorValue = (1.0 - (indicatorValue - visibleCandlesExtremums.PriceLow) / range) * RenderHeight;
                double cndlCenterX         = cndl_i * candleWidthPlusGap + 0.5 * candleWidth;

                //ClipLineSegment(prevCndlCenterX, prevLocalIndicatorValue, cndlCenterX, localIndicatorValue, RenderHeight, out Point newPoint0, out Point newPoint1);
                //drawingContext.DrawLine(Pen, newPoint0, newPoint1);
                drawingContext.DrawLine(Pen, new Point(prevCndlCenterX, prevLocalIndicatorValue), new Point(cndlCenterX, localIndicatorValue));

                prevCndlCenterX         = cndlCenterX;
                prevLocalIndicatorValue = localIndicatorValue;
            }
        }
Beispiel #6
0
        //---------------------------------------------------------------------------------------------------------------------------------------
        ///<summary>Implements the <see cref="OverlayIndicator.OnRender"/> abstract method inherited from the <see cref="OverlayIndicator"/> base class.</summary>
        ///<param name="drawingContext">Provides methods for drawing lines and shapes on the price chart area.</param>
        ///<param name="visibleCandlesRange">Specifies the time span currently shown on the price chart area. The range of the candles currently visible on the price chart.</param>
        ///<param name="visibleCandlesExtremums">The maximal High and minimal Low of the candles in visibleCandlesRange.</param>
        ///<param name="candleWidth">The Width of candle of the price chart, in device-independent units.</param>
        ///<param name="gapBetweenCandles">The Gap between candles of the price chart, in device-independent units.</param>
        ///<param name="RenderHeight">The height of the price chart area, in device-independent units.</param>
        ///<remarks>
        ///This is an analog of the <see href="https://docs.microsoft.com/en-za/dotnet/api/system.windows.uielement.onrender?view=netframework-4.7.2">UIElement.OnRender()</see> method.
        ///Participates in rendering operations that are directed by the layout system. The rendering instructions for this indicator are not used directly when this method is invoked, and are instead preserved for later asynchronous use by layout and drawing.
        ///</remarks>
        public override void OnRender(DrawingContext drawingContext, IntRange visibleCandlesRange, CandleExtremums visibleCandlesExtremums,
                                      double candleWidth, double gapBetweenCandles, double RenderHeight)
        {
            if (visibleCandlesRange.Count < 0 || visibleCandlesRange.Start_i < 0)
            {
                return;
            }

            double candleWidthPlusGap = candleWidth + gapBetweenCandles;
            double range                   = visibleCandlesExtremums.PriceHigh - visibleCandlesExtremums.PriceLow;
            double prevCndlCenterX         = 0;
            double prevLocalIndicatorValue = 0;

            prevCndlCenterX = 0.5 * candleWidth;
            double prevIndicatorValue = GetIndicatorValue(visibleCandlesRange.Start_i);

            prevLocalIndicatorValue = (1.0 - (prevIndicatorValue - visibleCandlesExtremums.PriceLow) / range) * RenderHeight;

            for (int cndl_i = 1; cndl_i < visibleCandlesRange.Count; cndl_i++)
            {
                double indicatorValue      = GetIndicatorValue(visibleCandlesRange.Start_i + cndl_i);
                double localIndicatorValue = (1.0 - (indicatorValue - visibleCandlesExtremums.PriceLow) / range) * RenderHeight;
                double cndlCenterX         = cndl_i * candleWidthPlusGap + 0.5 * candleWidth;

                drawingContext.DrawLine(Pen, new Point(prevCndlCenterX, prevLocalIndicatorValue), new Point(cndlCenterX, localIndicatorValue));

                prevCndlCenterX         = cndlCenterX;
                prevLocalIndicatorValue = localIndicatorValue;
            }
        }