private List <PriceZone> GeneratePriceZones(Arrangement arrangement, List <Seat> allSeats)
        {
            var priceZones = new List <PriceZone>();

            foreach (var sector in arrangement.Sectors)
            {
                Price regularPrice    = GetRegularPriceLevels()[sector.DataQuality];
                var   discoundedPrice = GetDiscoundedPriceLevels()[sector.DataQuality];

                var priceZone = new PriceZone
                {
                    ScenePriceZoneId = sector.PriceZoneId,
                    Name             = sector.Name,
                    Seats            = allSeats.Where(x => sector.Seats.Any(s => s.Id == x.SceneSeatId)).ToList(),
                    Options          = new List <PriceOption>
                    {
                        new PriceOption {
                            Name = "Regular", Price = regularPrice
                        },
                        new PriceOption {
                            Name = "Discounted", Price = discoundedPrice
                        },
                    }
                };

                priceZones.Add(priceZone);
            }

            return(priceZones);
        }
示例#2
0
        /// <summary>
        /// Returns if the price bar touched one of our buy zones.
        /// </summary>
        /// <param name="lowPrice">Low of the bar to check</param>
        /// <param name="highPrice">High of the bar to check</param>
        /// <param name="barNum">Bar for the price</param>
        /// <returns>True if the bar touched a zone</returns>
        public bool DidBarTouchZone(double lowPrice, double highPrice, int barNum)
        {
            List <PriceZone> zones = GetZones(barNum);

            // Get a list of all the zones with more than 2 points and if there are
            // any that these are the better zones to use.
            //List<PriceZone> betterZones = zones.Where(z => z.NumberOfPoints > 2).ToList();
            //if (betterZones.Count > 0)
            //{
            //	zones = betterZones;
            //}

            for (int i = 0; i < zones.Count; i++)
            {
                PriceZone zone = zones[i];
                if ((highPrice >= zone.High && lowPrice <= zone.Low) ||
                    (highPrice >= zone.Low && lowPrice <= zone.High))
                {
                    HitZone[barNum] = zone;
                    return(true);
                }
            }

            return(false);
        }
示例#3
0
        /// <summary>
        /// Checks if the price for this bar falls in a retracement price zone.
        /// </summary>
        /// <param name="currentBar">Bar to check</param>
        /// <returns>True if the price has touched one of the zones</returns>
        private bool IsBarInZone(int currentBar)
        {
            PriceRetracements retracements = (PriceRetracements)_dependents[1];

            // Get the retracement zones first.
            List <PriceZone> zones  = new List <PriceZone>();
            List <double>    points = new List <double>();

            points.Add(retracements.External[(int)PriceRetracements.ExternalType._127][currentBar]);
            points.Add(retracements.External[(int)PriceRetracements.ExternalType._162][currentBar]);
            points.Add(retracements.Alternate[(int)PriceRetracements.AlternateType._100Wave1][currentBar]);
            points.Add(retracements.Alternate[(int)PriceRetracements.AlternateType._100Wave3][currentBar]);
            points.Add(retracements.Alternate[(int)PriceRetracements.AlternateType._38][currentBar]);
            points.Add(retracements.Alternate[(int)PriceRetracements.AlternateType._62][currentBar]);

            ComboSet <double>     comboSet = new ComboSet <double>(points);
            List <List <double> > combos   = comboSet.GetSet(2);

            for (int i = 0; i < combos.Count; i++)
            {
                if (AreAllPointsClose(combos[i]) == true)
                {
                    double high = combos[i].Max();
                    double low  = combos[i].Min();
                    zones.Add(new PriceZone()
                    {
                        High = high, Low = low, NumberOfPoints = combos[i].Count
                    });
                }
            }

            // The one with the most similar points is the best. See if it lands there first.
            zones.Sort((a, b) => a.NumberOfPoints.CompareTo(b.NumberOfPoints));

            for (int i = 0; i < zones.Count; i++)
            {
                PriceZone zone = zones[i];
                if ((Data.High[currentBar] >= zone.High && Data.Low[currentBar] <= zone.Low) ||
                    (Data.High[currentBar] >= zone.Low && Data.Low[currentBar] <= zone.High))
                {
                    return(true);
                }
            }

            return(false);
        }