Пример #1
0
        // TODO:  Disabled for now, need sure recntangels are drawn historically and for all price zones
        private void RenderPriceZoneAreas(ChartControl chartControl, ChartScale chartScale, int barIndex, int plotIndex)
        {
            SharpDX.RectangleF rectangleF = new SharpDX.RectangleF();

            DateTime tm = ChartBars.GetTimeByBarIdx(chartControl, barIndex).Date;

            PriceZone zone = zonesList[tm];


            rectangleF.Top    = chartScale.GetYByValue(zone.ZoneStrong);
            rectangleF.Bottom = chartScale.GetYByValue(zone.ZoneWeak);
            rectangleF.Left   = chartControl.GetXByTime(zone.StartTime);
            rectangleF.Right  = ChartControl.GetXByTime(zone.EndTime);

            Brush tmpBrush = Plots[plotIndex].Brush.Clone();

            tmpBrush.Opacity = .05;
            tmpBrush.Freeze();
            RenderTarget.FillRectangle(rectangleF, tmpBrush.ToDxBrush(RenderTarget));
        }
Пример #2
0
        protected override void OnBarUpdate()
        {
            if (BarsInProgress == 1)
            {
                return;
            }
            if (Bars.IsFirstBarOfSession)
            {
                sessionOpen = Open[0];
                openTime    = Time[0];
                if (CurrentBars[(int)BarsUpdating.Daily] < RangePeriod)
                {
                    return;
                }

                normalAtr  = this.ToTickSize(raphael[0]);
                rangeSplit = this.ToTickSize(normalAtr / 2);
                renet.RecalculateSession(Time[0]);
                foreach (BrushSeries brush in PlotBrushes)
                {
                    brush[0] = Brushes.Transparent;
                }
            }

            if (renet.IsRegularTradingHours(Time[0]))
            {
                DayOpen[0] = sessionOpen;
                // draw rectangle for first 5 minutes maybe? Help try and catch lots of volume on tick chart
                // e.g., -> the wider the rectangle, the more activity in the first 5 minutes.


                if (normalAtr > 0 && rangeSplit > 0)
                {
                    RangeMax[0]  = DayOpen[0] + normalAtr;
                    RangeHigh[0] = RangeMax[0] - rangeSplit;

                    RangeMin[0] = DayOpen[0] - normalAtr;
                    RangeLow[0] = RangeMin[0] + rangeSplit;
                }

                if (!Bars.IsFirstBarOfSession)
                {
                    return;
                }

                double weakAtr     = this.ToTickSize(raphael.atrFromOpen[0]);
                double strongAtr   = this.ToTickSize(raphael.atrFromPriorOpen[0]);
                double weakSplit   = this.ToTickSize(weakAtr / 2);
                double strongSplit = this.ToTickSize(strongAtr / 2);

                priceZoneArray[0] = new PriceZone
                {
                    Name     = "Max Zone",
                    Index    = 0,
                    ZoneHigh = RangeMax[0],
                    ZoneLow  = RangeHigh[0],

                    StartTime = Time[0],
                    EndTime   = renet.CurrentSessionEnd(Time[0]),

                    ZoneStrong = DayOpen[0] + strongAtr,
                    ZoneWeak   = DayOpen[0] + weakAtr,
                };
                priceZoneArray[1] = new PriceZone
                {
                    Name       = "Bull Zone",
                    Index      = 1,
                    ZoneHigh   = RangeHigh[0],
                    ZoneLow    = DayOpen[0],
                    StartTime  = Time[0],
                    EndTime    = renet.CurrentSessionEnd(Time[0]),
                    ZoneStrong = priceZoneArray[0].ZoneStrong - strongSplit,
                    ZoneWeak   = priceZoneArray[0].ZoneWeak - weakSplit,
                };
                // there is *probably* an open zone burried in here somewhere
                // look at Fri Jun 17 2016... tests open - 4 ticks twice
                // ... could there be a weak/strong open?
                priceZoneArray[2] = new PriceZone
                {
                    Name       = "Open Zone",
                    Index      = 2,
                    ZoneHigh   = DayOpen[0],
                    ZoneLow    = DayOpen[0],
                    StartTime  = Time[0],
                    EndTime    = renet.CurrentSessionEnd(Time[0]),
                    ZoneStrong = DayOpen[0] + (4 * TickSize),
                    ZoneWeak   = DayOpen[0] - (4 * TickSize)
                };



                priceZoneArray[3] = new PriceZone
                {
                    Name       = "Bear Zone",
                    Index      = 3,
                    ZoneHigh   = DayOpen[0],
                    ZoneLow    = RangeLow[0],
                    StartTime  = Time[0],
                    EndTime    = renet.CurrentSessionEnd(Time[0]),
                    ZoneWeak   = (DayOpen[0] - weakAtr) + weakSplit,
                    ZoneStrong = (DayOpen[0] - strongAtr) + strongSplit
                };

                priceZoneArray[4] = new PriceZone
                {
                    Name       = "Min Zone",
                    Index      = 4,
                    ZoneHigh   = RangeLow[0],
                    ZoneLow    = RangeMin[0],
                    StartTime  = Time[0],
                    EndTime    = renet.CurrentSessionEnd(Time[0]),
                    ZoneWeak   = DayOpen[0] - weakAtr,
                    ZoneStrong = DayOpen[0] - strongAtr
                };
            }
            else
            {
                DayOpen.Reset();
                RangeMin.Reset();
                RangeMax.Reset();
                RangeLow.Reset();
                RangeHigh.Reset();
            }
            priceZoneSeries[0] = priceZoneArray;
        }