Пример #1
0
        private IInteractiveLine GetInteractiveLine(IGraphPane pane, IReadOnlyList <IDataBar> bars)
        {
            var minDate              = bars.First().Date;
            var maxDate              = bars.Last().Date;
            var interactiveLine      = (IInteractiveLine)pane.GetInteractiveObject(VariableId);
            var intColor             = ColorParser.Parse(Color);
            var firstMarketPosition  = new MarketPoint(FirstDateTime.Value, FirstValue.Value);
            var secondMarketPosition = new MarketPoint(SecondDateTime.Value, SecondValue.Value);

            if (interactiveLine != null)
            {
                interactiveLine.ExecutionDataBars = bars;
                CorrectMarketPointsEx(ref firstMarketPosition, ref secondMarketPosition, minDate, maxDate);

                if (interactiveLine.PaneSides == PaneSide && interactiveLine.Color == intColor && interactiveLine.Mode == Mode)
                {
                    pane.AddUnremovableInteractiveObjectId(VariableId);
                    interactiveLine.Thickness = Thickness;
                    interactiveLine.FirstPoint.MarketPosition  = firstMarketPosition;
                    interactiveLine.SecondPoint.MarketPosition = secondMarketPosition;
                    return(m_interactiveLine = interactiveLine);
                }
                pane.RemoveInteractiveObject(VariableId);
            }
            else
            {
                CorrectMarketPointsEx(ref firstMarketPosition, ref secondMarketPosition, minDate, maxDate);
            }

            m_interactiveLine                   = pane.AddInteractiveLine(VariableId, PaneSide, false, intColor, Mode, firstMarketPosition, secondMarketPosition);
            m_interactiveLine.Thickness         = Thickness;
            m_interactiveLine.ExecutionDataBars = bars;
            return(m_interactiveLine);
        }
Пример #2
0
        private void InitInteractiveSimpleLine(IGraphPane pane)
        {
            var id = Value.Data.GetId();

            m_interactiveSimpleLine = (IInteractiveSimpleLine)pane.GetInteractiveObject(id);
            var         intColor = ColorParser.Parse(Color);
            MarketPoint marketPosition;

            if (m_interactiveSimpleLine != null)
            {
                marketPosition = new MarketPoint(m_interactiveSimpleLine.MarketPosition.X, Value.Value);
                if (m_interactiveSimpleLine.PaneSides == PaneSide && m_interactiveSimpleLine.Color == intColor)
                {
                    m_interactiveSimpleLine.Thickness      = Thickness;
                    m_interactiveSimpleLine.MarketPosition = marketPosition;
                    pane.AddUnremovableInteractiveObjectId(id);
                    return;
                }
                pane.RemoveInteractiveObject(id);
            }
            else
            {
                marketPosition = new MarketPoint(DateTime.UtcNow, Value.Value);
            }

            m_interactiveSimpleLine           = pane.AddInteractiveSimpleLine(id, PaneSide, false, intColor, InteractiveSimpleLineMode.Horizontal, marketPosition);
            m_interactiveSimpleLine.Thickness = Thickness;
        }
    private void Update()
    {
        var obj = Physics2D.OverlapBox((Vector2)transform.position - hitOffset, hitBoxSize, 0, collLayer);

        if (obj && collChanged)
        {
            collChanged = false;

            onPickPoint = obj.CompareTag("PickPoint");
            if (onPickPoint)
            {
                pickPoint = obj.GetComponent <PickPoint>();
            }
            onMarketPoint = obj.CompareTag("MarketPoint");
            if (onMarketPoint)
            {
                marketPoint = obj.GetComponent <MarketPoint>();
            }
            onLvPoint = obj.CompareTag("LvPoint");
        }
        if (!obj && !collChanged)
        {
            collChanged   = true;
            onPickPoint   = false;
            onMarketPoint = false;
            onLvPoint     = false;
        }

        onCollider = onPickPoint || onMarketPoint || onLvPoint;
    }
Пример #4
0
 private void CorrectMarketPointsEx(ref MarketPoint firstMarketPosition, ref MarketPoint secondMarketPosition, DateTime minDate, DateTime maxDate)
 {
     CorrectMarketPoints(ref firstMarketPosition, ref secondMarketPosition, minDate, maxDate);
     SetValue(FirstDateTime, firstMarketPosition.X);
     SetValue(FirstValue, firstMarketPosition.Y);
     SetValue(SecondDateTime, secondMarketPosition.X);
     SetValue(SecondValue, secondMarketPosition.Y);
 }
Пример #5
0
 private void OnSecondDateTimePropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == nameof(IOptimPropertyBase.Value))
     {
         SecondUnsubscribe();
         var dateTimeOptimProperty = (DateTimeOptimProperty)sender;
         var firstMarketPosition   = m_interactiveLine.FirstPoint.MarketPosition;
         var secondMarketPosition  = new MarketPoint(dateTimeOptimProperty.Value, m_interactiveLine.SecondPoint.MarketPosition.Y);
         CorrectMarketPointsEx(ref firstMarketPosition, ref secondMarketPosition, m_bars.First().Date, m_bars.Last().Date);
         SetValue(dateTimeOptimProperty, secondMarketPosition.X);
         SetValue(SecondValue, secondMarketPosition.Y);
         m_interactiveLine.SecondPoint.MarketPosition = secondMarketPosition;
         SecondSubscribe();
     }
 }
Пример #6
0
        public void Paint(Context context)
        {
            var pane1 = context.CreateGraphPane(sec.ToString(), "Инструмент (основной таймфрейм)");
            var color = SystemColor.Green;

            pane1.AddList(sec.ToString(), security, CandleStyles.BAR_CANDLE, color, PaneSides.RIGHT);
            //if (id == 0) pane1.ClearInteractiveObjects();
            pane1.ClearInteractiveObjects();
            color = SystemColor.Blue;
            DateTime    x;
            double      y;
            MarketPoint position;

            var lows = pivotPointsIndicator.GetLows(security.BarNumber);

            foreach (var low in lows)
            {
                x = security.GetBarDateTime(low.BarNumber);
                //y = low.Value - 50;
                y        = low.Value - 50;
                position = new MarketPoint(x, y);
                var id = low.BarNumber.ToString() + " " + x.ToLongTimeString() + " " + low.Value.ToString();
                //Logger.Log("id: " + id.ToString());
                pane1.AddInteractivePoint(id, PaneSides.RIGHT, false, color, position);
            }

            var highs = pivotPointsIndicator.GetHighs(security.BarNumber);

            foreach (var high in highs)
            {
                x = security.GetBarDateTime(high.BarNumber);
                //y = high.Value + 50;
                y        = high.Value + 50;
                position = new MarketPoint(x, y);
                var id = high.BarNumber.ToString() + " " + x.ToLongTimeString() + " " + high.Value.ToString();
                //Logger.Log("id: " + id.ToString());
                pane1.AddInteractivePoint(id, PaneSides.RIGHT, false, color, position);
            }

            //pane1.AddList("EMA", ema, CandleStyles.BAR_CANDLE, color, PaneSides.RIGHT);
            pane1.AddList("EMA", ema, color, PaneSides.RIGHT);

            //var pane2 = context.CreateGraphPane(sec.ToString(), "Equity");
        }
Пример #7
0
        public void AddInteractivePoint(string id, PaneSides side, bool isRemovable, SystemColor color, MarketPoint position)
        {
            var colorTSlab = new TsLabColor(color.ToArgb());

            pane.AddInteractivePoint(id, side, isRemovable, colorTSlab, position);
        }
Пример #8
0
        public void Paint(Context context)
        {
            var pane1 = context.CreateGraphPane("Инструмент (о. т.)", "Инструмент (основной таймфрейм)");
            var color = SystemColor.Green;

            pane1.AddList(sec.ToString(), security, CandleStyles.BAR_CANDLE, color, PaneSides.RIGHT);

            var pane2 = context.CreateGraphPane("Инструмент  (с. т.)", "Инструмент (средний таймфрейм)");

            pane2.AddList(compressedSecurity.ToString(), compressedSecurity, CandleStyles.BAR_CANDLE, color, PaneSides.RIGHT);

            pane1.ClearInteractiveObjects();
            pane2.ClearInteractiveObjects();

            color = SystemColor.Blue;
            DateTime    x;
            double      y;
            MarketPoint position;
            int         id = 0;

            var lows = pivotPointsIndicator.GetLows(security.BarNumber);

            foreach (var low in lows)
            {
                x        = security.GetBarDateTime(low.BarNumber);
                y        = low.Value - 50;
                position = new MarketPoint(x, y);
                pane1.AddInteractivePoint(id.ToString(), PaneSides.RIGHT, false, color, position);
                id++;
            }

            var highs = pivotPointsIndicator.GetHighs(security.BarNumber);

            foreach (var high in highs)
            {
                x        = security.GetBarDateTime(high.BarNumber);
                y        = high.Value + 50;
                position = new MarketPoint(x, y);
                pane1.AddInteractivePoint(id.ToString(), PaneSides.RIGHT, false, color, position);
                id++;
            }

            var filterBarNumber = compressedSecurity.GetBarCompressedNumberFromBarBaseNumber(security.BarNumber);

            lows = pivotPointsIndicatorFilter.GetLows(filterBarNumber);

            foreach (var low in lows)
            {
                x        = compressedSecurity.GetBarDateTime(low.BarNumber);
                y        = low.Value - 50;
                position = new MarketPoint(x, y);
                pane2.AddInteractivePoint(id.ToString(), PaneSides.RIGHT, false, color, position);
                id++;
            }

            highs = pivotPointsIndicatorFilter.GetHighs(filterBarNumber);

            foreach (var high in highs)
            {
                x        = compressedSecurity.GetBarDateTime(high.BarNumber);
                y        = high.Value + 50;
                position = new MarketPoint(x, y);
                pane2.AddInteractivePoint(id.ToString(), PaneSides.RIGHT, false, color, position);
                id++;
            }
        }
Пример #9
0
        private static void CorrectMarketPoints(ref MarketPoint firstMarketPosition, ref MarketPoint secondMarketPosition, DateTime minDate, DateTime maxDate)
        {
            var firstDate  = firstMarketPosition.X;
            var secondDate = secondMarketPosition.X;

            if (firstDate < secondDate)
            {
                if (firstDate < minDate || firstDate >= maxDate)
                {
                    firstDate = minDate;
                }

                if (secondDate <= minDate || secondDate > maxDate)
                {
                    secondDate = maxDate;
                }
            }
            else if (firstDate > secondDate)
            {
                if (secondDate < minDate || secondDate >= maxDate)
                {
                    secondDate = minDate;
                }

                if (firstDate <= minDate || firstDate > maxDate)
                {
                    firstDate = maxDate;
                }
            }
            else
            {
                firstDate  = minDate;
                secondDate = maxDate;
            }
            if (double.IsNaN(firstMarketPosition.Y) && double.IsNaN(secondMarketPosition.Y))
            {
                firstMarketPosition  = new MarketPoint(firstMarketPosition.X, 0);
                secondMarketPosition = new MarketPoint(secondMarketPosition.X, 0);
            }
            else if (double.IsNaN(firstMarketPosition.Y))
            {
                firstMarketPosition = new MarketPoint(firstMarketPosition.X, secondMarketPosition.Y);
            }
            else if (double.IsNaN(secondMarketPosition.Y))
            {
                secondMarketPosition = new MarketPoint(secondMarketPosition.X, firstMarketPosition.Y);
            }

            if (firstMarketPosition.X != firstDate || secondMarketPosition.X != secondDate)
            {
                var a = (secondMarketPosition.Y - firstMarketPosition.Y) / (secondMarketPosition.X.Ticks - firstMarketPosition.X.Ticks);
                var b = firstMarketPosition.Y - a * firstMarketPosition.X.Ticks;

                if (firstMarketPosition.X != firstDate)
                {
                    firstMarketPosition = new MarketPoint(firstDate, a * firstDate.Ticks + b);
                }

                if (secondMarketPosition.X != secondDate)
                {
                    secondMarketPosition = new MarketPoint(secondDate, a * secondDate.Ticks + b);
                }
            }
        }