コード例 #1
0
ファイル: ChartControl.cs プロジェクト: xiechun/SquareOne
        public void TooltipPositionAndPriceShow(AlertArrow alertArrow, Bar barToPopulate, Rectangle rectangleYarrowXbar)
        {
            if (this.ChartSettings.TooltipPriceShow == false)
            {
                return;
            }
            // MouseX will never go over tooltip => PanelNamedFolding.OnMouseLeave() never invoked ???
            int awayFromBarXpx = this.ChartSettings.TooltipsPaddingFromBarLeftRightEdgesToAvoidMouseLeave;
            int xPosition      = -1;
            int xPrice         = -1;

            int twoTooltipsVerticalDistance = 4;
            int twoTooltipsCombinedHeight   = this.tooltipPosition.Height + twoTooltipsVerticalDistance + this.tooltipPrice.Height;

            if (alertArrow.ArrowIsForPositionEntry)
            {
                xPosition = rectangleYarrowXbar.Left - this.tooltipPosition.Width - awayFromBarXpx;
                xPrice    = rectangleYarrowXbar.Left - this.tooltipPrice.Width - awayFromBarXpx;
// LET_POSITION_TOOLTIP_GO_BEHIND_LEFT_EDGE_AND_PARTIALLY_OVERLAP_I_NEED_POSITION_LINE_TO_BE_FULLY_VISIBLE_TO_HIGHLIGHT
//				if (xPrice < 0)	xPrice = rectangleYarrowXbar.Right + awayFromBarXpx;
//				if (xPosition < 0) {	// positionTooltip is wider, dont squeeze priceTooltip but take the same side as the big brother
//					xPosition	= rectangleYarrowXbar.Right + awayFromBarXpx;
//					xPrice		= rectangleYarrowXbar.Right + awayFromBarXpx;
//				}
            }
            else
            {
                xPosition = rectangleYarrowXbar.Right + awayFromBarXpx;
                xPrice    = xPosition;
            }

            int yPrice = rectangleYarrowXbar.Top - twoTooltipsCombinedHeight / 2;

            if (yPrice <= 0)
            {
                yPrice = this.ChartSettings.TooltipBordersMarginToKeepBordersVisible;
            }
            if (yPrice + twoTooltipsCombinedHeight > this.HeightMinusBottomHscrollbar)
            {
                yPrice = this.HeightMinusBottomHscrollbar - twoTooltipsCombinedHeight - this.ChartSettings.TooltipBordersMarginToKeepBordersVisible;
                if (yPrice <= 0)
                {
                    yPrice = this.ChartSettings.TooltipBordersMarginToKeepBordersVisible;
                }
            }
            int yPosition = yPrice + this.tooltipPrice.Height + twoTooltipsVerticalDistance;

            this.tooltipPriceShowXY(barToPopulate, xPrice, yPrice);
            this.tooltipPositionShowXY(alertArrow, xPosition, yPosition);
        }
コード例 #2
0
ファイル: ChartControl.cs プロジェクト: xiechun/SquareOne
        private void tooltipPositionShowXY(AlertArrow alertArrowToPopup, int xPosition, int yPosition)
        {
            Point newLocation = new Point(xPosition, yPosition);

            //DOESNT_SHOWUP_MOUSE_BETWEEN_ARROW_AND_BAR
            //if (this.tooltipPosition.Location == newLocation) {	//Point is a structure with Equals() overriden => we are safe to compare
            //	this.tooltipPrice.Visible = true;
            //	return;
            //}

            this.tooltipPosition.PopulateTooltip(alertArrowToPopup);
            //this.tooltipPosition.Capture = false;
            this.tooltipPosition.Location = newLocation;
            this.tooltipPosition.Visible  = true;
        }
コード例 #3
0
ファイル: PanelPrice.cs プロジェクト: xiechun/SquareOne
        void renderBarsPrice(Graphics g)
        {
            //for (int i = 0; i < base.ChartControl.BarsCanFitForCurrentWidth; i++) {
            //	int barFromRight = base.ChartControl.BarsCanFitForCurrentWidth - i - 1;
            //int barX = this.BarTotalWidthPx_localCache * barFromRight;
            int barX = base.ChartControl.ChartWidthMinusGutterRightPrice;

            this.PositionLineAlreadyDrawnFromOneOfTheEnds.Clear();

            for (int barIndex = VisibleBarRight_cached; barIndex > VisibleBarLeft_cached; barIndex--)
            {
                if (barIndex > base.ChartControl.Bars.Count)                    // we want to display 0..64, but Bars has only 10 bars inside
                {
                    string msg = "YOU_SHOULD_INVOKE_SyncHorizontalScrollToBarsCount_PRIOR_TO_RENDERING_I_DONT_KNOW_ITS_NOT_SYNCED_AFTER_ChartControl.Initialize(Bars)";
                    Assembler.PopupException("RenderBarsPrice(): " + msg);
                    continue;
                }
                Bar bar = base.ChartControl.Bars[barIndex];
                //bar.CheckOHLCVthrow();
                barX -= this.BarWidthIncludingPadding_cached;
                int barYOpenInverted  = base.ValueToYinverted(bar.Open);
                int barYHighInverted  = base.ValueToYinverted(bar.High);
                int barYLowInverted   = base.ValueToYinverted(bar.Low);
                int barYCloseInverted = base.ValueToYinverted(bar.Close);
                //base.CheckConvertedBarDataIsNotZero(xOffsetFromRightBorder, barYOpen, barYHigh, barYLow, barYClose);
                bool fillCandleBody = (bar.Open > bar.Close) ? true : false;
                base.RenderBarCandle(g, barX, barYOpenInverted, barYHighInverted, barYLowInverted, barYCloseInverted, fillCandleBody);

                //int shadowX = 0;
                //MOVED_TO_AlignVisiblePositionArrowsAndCountMaxOutstanding()
                int shadowX = barX + this.BarShadowXoffset_cached;
                this.pendingAlertsDrawIfExistForBar(barIndex, shadowX, g);
                this.positionArrowsLinesDrawIfExistForBar(barIndex, shadowX, g);

                AlertArrow arrow = this.ChartControl.TooltipPositionShownForAlertArrow;
                if (arrow == null)
                {
                    continue;
                }
                if (arrow.BarIndexFilled != barIndex)
                {
                    continue;
                }
                this.drawPositionLineForArrow(arrow, g, true);
            }
        }
コード例 #4
0
		public void PopulateTooltip(AlertArrow arrow) {
			this.AlertArrow = arrow;
			Position position = arrow.Position;
			Bars bars = position.Bars;
			string priceFormat = "N" + bars.SymbolInfo.DecimalsPrice;

			if (position.PositionLongShort == PositionLongShort.Long) {
				lblEntry.Text = "Long" + position.EntryMarketLimitStop.ToString().Substring(0, 1);
				lblExit.Text = "Sold" + position.EntryMarketLimitStop.ToString().Substring(0, 1);
			} else {
				lblEntry.Text = "Short" + position.ExitMarketLimitStop.ToString().Substring(0, 1);
				lblExit.Text = "Covered" + position.ExitMarketLimitStop.ToString().Substring(0, 1);
			}
			lblEntry.Text += " (" + position.EntryPriceScript.ToString(priceFormat) + ")";
			lblExit.Text += " (" + position.ExitPriceScript.ToString(priceFormat) + ")";

			this.lblEntrySignalVal.Text = position.EntrySignal;
			this.lblExitSignalVal.Text = position.ExitSignal;

			string text = "";
			if (bars.IsIntraday) {
				//text = text + " " + bars.Date[barNumber].ToShortTimeString();
				//text = text + bars[bar].DateTimeOpen.ToString("HH:mm ");
				text = text + position.EntryDate.ToString("HH:mm ");
			}
			//text = text + bars[bar].DateTimeOpen.ToString("ddd dd-MMM-yyyy");
			text = text + position.EntryDate.ToString("ddd dd-MMM-yyyy");
			this.lblDateVal.Text = text;

			this.lblEntryVal.Text = position.EntryFilledPrice.ToString(priceFormat);
			this.lblExitVal.Text = position.ExitFilledPrice.ToString(priceFormat);

			double distancePoints = position.DistanceInPoints;
			this.lblDistancePointsVal.Text = distancePoints.ToString(priceFormat);

			this.lblSharesVal.Text = position.Shares.ToString();

			double grossProfit = distancePoints * position.Shares;
			this.lblGrossProfitLossVal.Text = grossProfit.ToString(priceFormat);
			this.lblPoint2DollarVal.Text = position.Bars.SymbolInfo.Point2Dollar.ToString();
			this.lblNetProfitLossValue.Text = position.NetProfit.ToString(priceFormat);
			
			double commissions = position.EntryFilledCommission + position.ExitFilledCommission;
			this.lblCommissionVal.Text = commissions.ToString();
			this.lblPriceLevelSizeVal.Text = position.Bars.SymbolInfo.PriceLevelSizeForBonds.ToString(priceFormat);
			this.lblBasisPriceVal.Text = position.EntryFilledPrice.ToString(priceFormat);
	
			Color color = (position.NetProfit > 0.0) ? Color.Green : Color.Red;
			this.lblDistancePoints.ForeColor = color;
			this.lblDistancePointsVal.ForeColor = color;
			this.lblNetProfitLoss.ForeColor = color;
			this.lblNetProfitLossValue.ForeColor = color;
			this.lblGrossProfitLoss.ForeColor = color;
			this.lblGrossProfitLossVal.ForeColor = color;

			if (position.NetProfit > 0.0) {
				this.lblNetProfitLoss.Text = "Net Profit";
				this.lblGrossProfitLoss.Text = "Grs Profit";
			} else {
				this.lblNetProfitLoss.Text = "Net Loss";
				this.lblGrossProfitLoss.Text = "Grs Loss";
			}

			this.lblSlippagesVal.Text = position.EntryFilledSlippage.ToString() + " / " + position.ExitFilledSlippage.ToString();
		}
コード例 #5
0
		private void drawPositionLineForArrow(AlertArrow arrow, Graphics g, bool highlighted = false) {
			Position position = arrow.Position;
			if (position.EntryFilledBarIndex == -1) return;		// position without EntryFilled shouldn't have a Line

			if (highlighted == false) {
				if (this.PositionLineAlreadyDrawnFromOneOfTheEnds.Contains(position)) return;
				this.PositionLineAlreadyDrawnFromOneOfTheEnds.Add(position);
			}

			int mouseEndX, mouseEndY, oppositeEndX, oppositeEndY;

			if (arrow.ArrowIsForPositionEntry) {
				// Entry
				mouseEndX = base.BarToXshadowBeyondGoInside(position.EntryFilledBarIndex);
				mouseEndY = base.ValueToYinverted(position.EntryFilledPrice);

				if (position.IsExitFilled) {
					// Exit
					oppositeEndX = base.BarToXshadowBeyondGoInside(position.ExitFilledBarIndex);
					oppositeEndY = base.ValueToYinverted(position.ExitFilledPrice);
				} else {
					// BarStreaming, end up on GutterRight
					oppositeEndX = this.ChartControl.ChartWidthMinusGutterRightPrice;
					oppositeEndY = base.ValueToYinverted(position.Bars.BarStreaming.Close);
				}
			} else {
				// Exit
				mouseEndX = base.BarToXshadowBeyondGoInside(position.ExitFilledBarIndex);
				mouseEndY = base.ValueToYinverted(position.ExitFilledPrice);

				// Entry (must be filled if Arrow was for an Exit)
				oppositeEndX = base.BarToXshadowBeyondGoInside(position.EntryFilledBarIndex);
				oppositeEndY = base.ValueToYinverted(position.EntryFilledPrice);
			}

			Pen penLine = this.ChartControl.ChartSettings.PenPositionLineEntryExitConnectedUnknown;
			if (double.IsNaN(arrow.Position.NetProfit) == false) {
				penLine = (arrow.Position.NetProfit > 0)
					? this.ChartControl.ChartSettings.PenPositionLineEntryExitConnectedProfit
					: this.ChartControl.ChartSettings.PenPositionLineEntryExitConnectedLoss;
			}

			if (highlighted == false) {
				g.DrawLine(penLine, mouseEndX, mouseEndY, oppositeEndX, oppositeEndY);
				return;
			}

			int alpha = this.ChartControl.ChartSettings.PositionLineHighlightedAlpha;
			int width = this.ChartControl.ChartSettings.PositionLineHighlightedWidth;
			Color colorLessTransparent = Color.FromArgb(alpha, penLine.Color.R, penLine.Color.G, penLine.Color.B);
			using (Pen penLineHighlighted = new Pen(colorLessTransparent, width)) {
				g.DrawLine(penLineHighlighted, mouseEndX, mouseEndY, oppositeEndX, oppositeEndY);
			};
		}
コード例 #6
0
		private void tooltipPositionShowXY(AlertArrow alertArrowToPopup, int xPosition, int yPosition) {
			Point newLocation = new Point(xPosition, yPosition);
			//DOESNT_SHOWUP_MOUSE_BETWEEN_ARROW_AND_BAR
			//if (this.tooltipPosition.Location == newLocation) {	//Point is a structure with Equals() overriden => we are safe to compare
			//	this.tooltipPrice.Visible = true;
			//	return;	
			//}

			this.tooltipPosition.PopulateTooltip(alertArrowToPopup);
			//this.tooltipPosition.Capture = false;
			this.tooltipPosition.Location = newLocation;
			this.tooltipPosition.Visible = true;
		}
コード例 #7
0
		public void TooltipPositionAndPriceShow(AlertArrow alertArrow, Bar barToPopulate, Rectangle rectangleYarrowXbar) {
			if (this.ChartSettings.TooltipPriceShow == false) return;
			// MouseX will never go over tooltip => PanelNamedFolding.OnMouseLeave() never invoked ???
			int awayFromBarXpx = this.ChartSettings.TooltipsPaddingFromBarLeftRightEdgesToAvoidMouseLeave;
			int xPosition	= -1;
			int xPrice		= -1;

			int twoTooltipsVerticalDistance = 4;
			int twoTooltipsCombinedHeight = this.tooltipPosition.Height + twoTooltipsVerticalDistance + this.tooltipPrice.Height;

			if (alertArrow.ArrowIsForPositionEntry) {
				xPosition	= rectangleYarrowXbar.Left - this.tooltipPosition.Width - awayFromBarXpx;
				xPrice		= rectangleYarrowXbar.Left - this.tooltipPrice.Width - awayFromBarXpx;
// LET_POSITION_TOOLTIP_GO_BEHIND_LEFT_EDGE_AND_PARTIALLY_OVERLAP_I_NEED_POSITION_LINE_TO_BE_FULLY_VISIBLE_TO_HIGHLIGHT
//				if (xPrice < 0)	xPrice = rectangleYarrowXbar.Right + awayFromBarXpx;
//				if (xPosition < 0) {	// positionTooltip is wider, dont squeeze priceTooltip but take the same side as the big brother
//					xPosition	= rectangleYarrowXbar.Right + awayFromBarXpx;
//					xPrice		= rectangleYarrowXbar.Right + awayFromBarXpx;
//				}
			} else {
				xPosition	= rectangleYarrowXbar.Right + awayFromBarXpx;
				xPrice		= xPosition;
			}

			int yPrice = rectangleYarrowXbar.Top - twoTooltipsCombinedHeight / 2;
			if (yPrice <= 0) yPrice = this.ChartSettings.TooltipBordersMarginToKeepBordersVisible;
			if (yPrice + twoTooltipsCombinedHeight > this.HeightMinusBottomHscrollbar) {
				yPrice = this.HeightMinusBottomHscrollbar - twoTooltipsCombinedHeight - this.ChartSettings.TooltipBordersMarginToKeepBordersVisible;
				if (yPrice <= 0) yPrice = this.ChartSettings.TooltipBordersMarginToKeepBordersVisible;
			}
			int yPosition = yPrice + this.tooltipPrice.Height + twoTooltipsVerticalDistance;
			
			this.tooltipPriceShowXY(barToPopulate, xPrice, yPrice);
			this.tooltipPositionShowXY(alertArrow, xPosition, yPosition);
		}
コード例 #8
0
ファイル: PanelPrice.cs プロジェクト: xiechun/SquareOne
        private void drawPositionLineForArrow(AlertArrow arrow, Graphics g, bool highlighted = false)
        {
            Position position = arrow.Position;

            if (position.EntryFilledBarIndex == -1)
            {
                return;                                                         // position without EntryFilled shouldn't have a Line
            }
            if (highlighted == false)
            {
                if (this.PositionLineAlreadyDrawnFromOneOfTheEnds.Contains(position))
                {
                    return;
                }
                this.PositionLineAlreadyDrawnFromOneOfTheEnds.Add(position);
            }

            int mouseEndX, mouseEndY, oppositeEndX, oppositeEndY;

            if (arrow.ArrowIsForPositionEntry)
            {
                // Entry
                mouseEndX = base.BarToXshadowBeyondGoInside(position.EntryFilledBarIndex);
                mouseEndY = base.ValueToYinverted(position.EntryFilledPrice);

                if (position.IsExitFilled)
                {
                    // Exit
                    oppositeEndX = base.BarToXshadowBeyondGoInside(position.ExitFilledBarIndex);
                    oppositeEndY = base.ValueToYinverted(position.ExitFilledPrice);
                }
                else
                {
                    // BarStreaming, end up on GutterRight
                    oppositeEndX = this.ChartControl.ChartWidthMinusGutterRightPrice;
                    oppositeEndY = base.ValueToYinverted(position.Bars.BarStreaming.Close);
                }
            }
            else
            {
                // Exit
                mouseEndX = base.BarToXshadowBeyondGoInside(position.ExitFilledBarIndex);
                mouseEndY = base.ValueToYinverted(position.ExitFilledPrice);

                // Entry (must be filled if Arrow was for an Exit)
                oppositeEndX = base.BarToXshadowBeyondGoInside(position.EntryFilledBarIndex);
                oppositeEndY = base.ValueToYinverted(position.EntryFilledPrice);
            }

            Pen penLine = this.ChartControl.ChartSettings.PenPositionLineEntryExitConnectedUnknown;

            if (double.IsNaN(arrow.Position.NetProfit) == false)
            {
                penLine = (arrow.Position.NetProfit > 0)
                                        ? this.ChartControl.ChartSettings.PenPositionLineEntryExitConnectedProfit
                                        : this.ChartControl.ChartSettings.PenPositionLineEntryExitConnectedLoss;
            }

            if (highlighted == false)
            {
                g.DrawLine(penLine, mouseEndX, mouseEndY, oppositeEndX, oppositeEndY);
                return;
            }

            int   alpha = this.ChartControl.ChartSettings.PositionLineHighlightedAlpha;
            int   width = this.ChartControl.ChartSettings.PositionLineHighlightedWidth;
            Color colorLessTransparent = Color.FromArgb(alpha, penLine.Color.R, penLine.Color.G, penLine.Color.B);

            using (Pen penLineHighlighted = new Pen(colorLessTransparent, width)) {
                g.DrawLine(penLineHighlighted, mouseEndX, mouseEndY, oppositeEndX, oppositeEndY);
            };
        }
コード例 #9
0
        public void PopulateTooltip(AlertArrow arrow)
        {
            this.AlertArrow = arrow;
            Position position    = arrow.Position;
            Bars     bars        = position.Bars;
            string   priceFormat = "N" + bars.SymbolInfo.DecimalsPrice;

            if (position.PositionLongShort == PositionLongShort.Long)
            {
                lblEntry.Text = "Long" + position.EntryMarketLimitStop.ToString().Substring(0, 1);
                lblExit.Text  = "Sold" + position.EntryMarketLimitStop.ToString().Substring(0, 1);
            }
            else
            {
                lblEntry.Text = "Short" + position.ExitMarketLimitStop.ToString().Substring(0, 1);
                lblExit.Text  = "Covered" + position.ExitMarketLimitStop.ToString().Substring(0, 1);
            }
            lblEntry.Text += " (" + position.EntryPriceScript.ToString(priceFormat) + ")";
            lblExit.Text  += " (" + position.ExitPriceScript.ToString(priceFormat) + ")";

            this.lblEntrySignalVal.Text = position.EntrySignal;
            this.lblExitSignalVal.Text  = position.ExitSignal;

            string text = "";

            if (bars.IsIntraday)
            {
                //text = text + " " + bars.Date[barNumber].ToShortTimeString();
                //text = text + bars[bar].DateTimeOpen.ToString("HH:mm ");
                text = text + position.EntryDate.ToString("HH:mm ");
            }
            //text = text + bars[bar].DateTimeOpen.ToString("ddd dd-MMM-yyyy");
            text = text + position.EntryDate.ToString("ddd dd-MMM-yyyy");
            this.lblDateVal.Text = text;

            this.lblEntryVal.Text = position.EntryFilledPrice.ToString(priceFormat);
            this.lblExitVal.Text  = position.ExitFilledPrice.ToString(priceFormat);

            double distancePoints = position.DistanceInPoints;

            this.lblDistancePointsVal.Text = distancePoints.ToString(priceFormat);

            this.lblSharesVal.Text = position.Shares.ToString();

            double grossProfit = distancePoints * position.Shares;

            this.lblGrossProfitLossVal.Text = grossProfit.ToString(priceFormat);
            this.lblPoint2DollarVal.Text    = position.Bars.SymbolInfo.Point2Dollar.ToString();
            this.lblNetProfitLossValue.Text = position.NetProfit.ToString(priceFormat);

            double commissions = position.EntryFilledCommission + position.ExitFilledCommission;

            this.lblCommissionVal.Text     = commissions.ToString();
            this.lblPriceLevelSizeVal.Text = position.Bars.SymbolInfo.PriceLevelSizeForBonds.ToString(priceFormat);
            this.lblBasisPriceVal.Text     = position.EntryFilledPrice.ToString(priceFormat);

            Color color = (position.NetProfit > 0.0) ? Color.Green : Color.Red;

            this.lblDistancePoints.ForeColor     = color;
            this.lblDistancePointsVal.ForeColor  = color;
            this.lblNetProfitLoss.ForeColor      = color;
            this.lblNetProfitLossValue.ForeColor = color;
            this.lblGrossProfitLoss.ForeColor    = color;
            this.lblGrossProfitLossVal.ForeColor = color;

            if (position.NetProfit > 0.0)
            {
                this.lblNetProfitLoss.Text   = "Net Profit";
                this.lblGrossProfitLoss.Text = "Grs Profit";
            }
            else
            {
                this.lblNetProfitLoss.Text   = "Net Loss";
                this.lblGrossProfitLoss.Text = "Grs Loss";
            }

            this.lblSlippagesVal.Text = position.EntryFilledSlippage.ToString() + " / " + position.ExitFilledSlippage.ToString();
        }