Example #1
0
        public int DrawArrow(ArrowDirection direction, Color color, float size, int bar, double price)
        {
            ChartArrow chartArrow = CreateArrow(direction, color, size, bar, price);

            objectId++;
            graphObjs.Add(objectId, chartArrow);
            return(objectId);
        }
Example #2
0
        /// <summary>
        /// Draws a trade and annotateg with hover message if possible.
        /// </summary>
        /// <param name="order"></param>
        /// <param name="fillPrice"></param>
        /// <param name="resultingPosition"></param>
        /// <returns></returns>
        public int DrawTrade(LogicalOrder order, double fillPrice, double resultingPosition)
        {
            Color          color     = Color.Empty;
            ArrowDirection direction = ArrowDirection.Up;

            switch (order.Type)
            {
            case OrderType.BuyLimit:
            case OrderType.BuyStop:
            case OrderType.BuyMarket:
                color     = Color.Green;
                direction = ArrowDirection.Up;
                break;

            case OrderType.SellLimit:
            case OrderType.SellStop:
            case OrderType.SellMarket:
                color     = Color.Red;
                direction = ArrowDirection.Down;
                break;

            default:
                throw new ApplicationException("Unknown OrderType " + order.Type + " for drawing a trade.");
            }
            if (order.TradeDirection == TradeDirection.Exit ||
                order.TradeDirection == TradeDirection.ExitStrategy)
            {
                color = Color.Black;
            }
            // One ticket open on tickzoom is to draw arrows to scale based
            // on the price range of the chart. This numbers for size and position
            // were hard code, calibrated to Forex prices.
            ChartArrow chartArrow = CreateArrow(direction, color, 12.5f, ChartBars.BarCount, fillPrice);
            var        sb         = new StringBuilder();

            if (order.Tag != null)
            {
                sb.AppendLine(order.Tag.ToString());
            }
            sb.Append(order.TradeDirection);
            sb.Append(" ");
            sb.AppendLine(order.Type.ToString());
            if (order.Price > 0)
            {
                sb.Append("at ");
                sb.AppendLine(order.Price.ToString());
            }
            sb.Append("size ");
            sb.AppendLine(order.Position.ToString());
            sb.Append("filled ");
            sb.AppendLine(fillPrice.ToString());
            sb.Append("new positions ");
            sb.AppendLine(resultingPosition.ToString());
            chartArrow.Tag = sb.ToString();
            objectId++;
            graphObjs.Add(objectId, chartArrow);
            return(objectId);
        }
Example #3
0
        private ChartArrow CreateArrow(ArrowDirection direction, Color color, float size, int bar, double price)
        {
            double tipPrice = price;
            int    tipBar   = bar;

            switch (direction)
            {
            case ArrowDirection.Up:
                price -= symbol.MinimumTick;
                break;

            case ArrowDirection.Down:
                price += symbol.MinimumTick;
                break;
            }
            var chartArrow = new ChartArrow(color, size, bar, price, tipBar, tipPrice);

            return(chartArrow);
        }