Esempio n. 1
0
        public void PartialProfitEnable(bool exit)
        {
            if (IsAlternativeLine)
            {
                _strategy.RemoveDrawObject(AlternativeRay);
                IsAlternativeLine = false;
            }
            ClosingHalf = true;
            //Distance we will count from profit Ray
            double distance;

            //to Made it between price and entry line
            //				= (_tpDot.Y - _strategy._currentPrice) / 2;
            //			if (!exit)
            distance = (_tpDot.Y - _eDot.Y) / 2;
            //Drawing the ray
            HalfCloseRay = _strategy.DrawRay("HalfClose", false,
                                             (ProfitTargetRay.Anchor1BarsAgo),
                                             (ProfitTargetRay.Anchor1Y - distance),
                                             (ProfitTargetRay.Anchor2BarsAgo),
                                             (ProfitTargetRay.Anchor2Y - distance),
                                             HcColor, DashStyle.Dash, 2);

            Update();
            HalfCloseRay.Locked = false;
        }
Esempio n. 2
0
        public RayContainer(MarketPosition marketPosition, IRay ray, ChartSlopeTrader strategy, bool isCloseHalf, bool isDts)
        {
            //Initialization global variables
            _strategy         = strategy;
            PositionType      = marketPosition;
            Distance          = strategy.ProportionalDistance < _strategy.TickSize * 3 ? 3 * strategy.TickSize : strategy.ProportionalDistance;
            IsAlternativeLine = false;

            //Set some local variables
            double distance = Distance;

            //Setting  up down if we are in the long
            if (marketPosition == MarketPosition.Long)
            {
                distance *= -1;
            }

            //Crating the lines
            OriginRay = ray;

            EntryRay = strategy.DrawRay("Enter", false,
                                        ray.Anchor1BarsAgo, ray.Anchor1Y + (distance * .3), ray.Anchor2BarsAgo, ray.Anchor2Y + (distance * .3),
                                        EnterColor, DashStyle.Solid, 2);

            StopRay = strategy.DrawRay("Stop", false,
                                       ray.Anchor1BarsAgo, ray.Anchor1Y + distance, ray.Anchor2BarsAgo, ray.Anchor2Y + distance,
                                       StopColor, DashStyle.Dash, 2);

            ProfitTargetRay = strategy.DrawRay("TakeProfit", false,
                                               ray.Anchor1BarsAgo, ray.Anchor1Y - distance, ray.Anchor2BarsAgo, ray.Anchor2Y - distance,
                                               TpColor, DashStyle.Dash, 2);

            if (isDts)
            {
                MadeStopRayHorizontal();
            }
            if (isCloseHalf)
            {
                PartialProfitEnable(false);
            }
            //Unlocking those rays if want to make them clear
            EntryRay.Locked        = false;
            StopRay.Locked         = false;
            ProfitTargetRay.Locked = false;
        }
        public void UpdateSlopeLine(Slope slope)
        {
            double price = _strategy.Instrument.MasterInstrument.Round2TickSize(slope.Price);

            _ray  = _strategy.DrawRay("Slope", false, slope.Bar, price, slope.Bar - 3, price, SlopeLineColor, DashStyle.Solid, 2);
            _dot  = _strategy.DrawDot("slopeDot", false, 0, price, Color.Black);
            _text = _strategy.DrawText("SlopeText", TextForma(price), 0, price, Color.Black);
            _strategy.ChartControl.ChartPanel.Invalidate();
        }