private List <List <double> > BollingerForRange(DateTime Start, DateTime End, int Period, double[] Multiplies) { //DateTime StartCorrectedForSma = Start.AddDays(-20); List <List <double> > BollingerBands = new List <List <double> >(); double[] PriceArray;// = GetDataForRange(StartCorrectedForSma, End).Select(q => Convert.ToDouble(q.Close)).ToArray(); //get system calculated interval int Interval = GetIntervalFromDateRange(Start, End); int skip = 0; if (Interval > 0) { //small intervalls add the desired amount of time and then skip at the end PriceArray = GetCachedDataForRange(Start.AddSeconds(-(Interval * Period * 2)), End, Interval).Select(q => Convert.ToDouble(q.Close)).ToArray(); if (PriceArray.Length == 0) { return(BollingerBands); } skip = PriceArray.Count() - GetCachedDataForRange(Start, End, Interval).Select(q => Convert.ToDouble(q.Close)).Count(); } else { int ExtendedPeriod = 0; int AddDays = 0; while (ExtendedPeriod <= 20) { AddDays++; ExtendedPeriod = ImperaturGlobal.BusinessDaysUntil(Start.AddDays(-AddDays), Start); } PriceArray = GetDataForRange(Start.AddDays(-AddDays), End).Select(q => Convert.ToDouble(q.Close)).ToArray(); //double[] PriceArray2 = GetDataForRange(Start, End).Select(q => Convert.ToDouble(q.Close)).ToArray(); skip = PriceArray.Count() - GetDataForRange(Start, End).Select(q => Convert.ToDouble(q.Close)).Count(); } //cant compute std on small amounts of data if (PriceArray.Count() < 2) { return(BollingerBands); } double[] CenterLine = Statistics.MovingAverage( PriceArray , Period).ToArray(); double[] CenterLine2 = MymMoving(PriceArray, Period); double[] StandardDevation = GetStandardDeviationPointsOfCenterLine2(PriceArray, Period); BollingerBands.Add(CenterLine.Skip(skip).ToList()); for (int i = 0; i < Multiplies.Length; i++) { BollingerBands.Add(GetExtendedBandOfCenterLine(CenterLine, StandardDevation.ToArray(), Multiplies[i], true).Skip(skip).ToList()); BollingerBands.Add(GetExtendedBandOfCenterLine(CenterLine, StandardDevation.ToArray(), Multiplies[i], false).Skip(skip).ToList()); } return(BollingerBands); }
private void PriceList_ItemSelected(object sender, SelectedItemChangedEventArgs e) { Change.IsVisible = !Confirm.IsVisible; string name = PriceList.SelectedItem.ToString(); if (changer) { for (int x = 0; x < PriceArray.Length; x++) { if (PriceArray.Cast <string>().ToList().ElementAt(x) == name) { select2 = x; minDiam.Text = ((List <PriceRange>)Application.Current.Properties["Prices"]).ElementAt(pickPrice.SelectedIndex).GetBrack().ElementAt(x).Key.ToString(); price.Text = ((List <PriceRange>)Application.Current.Properties["Prices"]).ElementAt(pickPrice.SelectedIndex).GetBrack().ElementAt(x).Value.ToString(); try { maxDiam.Text = ((List <PriceRange>)Application.Current.Properties["Prices"]).ElementAt(pickPrice.SelectedIndex).GetBrack().ElementAt(x + 1).Key.ToString(); } catch { maxDiam.Text = null; } } } } }
private async Task Change_Clicked(EventArgs e) { string name = PriceList.SelectedItem.ToString(); for (int x = 0; x < PriceArray.Length; x++) { if (PriceArray.Cast <string>().ToList().ElementAt(x) == name) { select2 = x; } } MessagingCenter.Subscribe <ChangePrice>(this, "Change", async(sender) => { PopList(pickPrice.SelectedIndex); Pricetitle.Text = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Pricings") + " :" + AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Saved"); SaveAll.GetInstance().SavePricing(); await Task.Delay(5000); Pricetitle.Text = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Pricings"); }); Application.Current.Properties["Priceholder"] = (pickPrice.SelectedIndex, select2); await PopupNavigation.Instance.PushAsync(ChangePrice.GetInstance()); }