private void CalculateFiveBasicValues() { var sixtyEightLowLimit = StdDevResults.Where(t => t.ZScore <= (Decimal)(-1.0) && t.ZScore > (Decimal)(-2.0)).OrderByDescending(t => t.ZScore).FirstOrDefault(); var sixtyEightLowLimitPrice = sixtyEightLowLimit.StdDev * sixtyEightLowLimit.ZScore + sixtyEightLowLimit.Mean; var sixtyEightHighLimit = StdDevResults.Where(t => t.ZScore <= (Decimal)1.0 && t.ZScore > (Decimal)(0)).OrderByDescending(t => t.ZScore).FirstOrDefault(); var sixtyEightHighLimitPrice = sixtyEightHighLimit.StdDev * sixtyEightHighLimit.ZScore + sixtyEightHighLimit.Mean; var ninetyLowLimit = StdDevResults.Where(t => t.ZScore > (Decimal)(-2.0) && t.ZScore < (Decimal)(-1.0)).OrderBy(t => t.ZScore).FirstOrDefault(); var ninetyLowLimitPrice = ninetyLowLimit.StdDev * ninetyLowLimit.ZScore + ninetyLowLimit.Mean; var ninetyHighLimit = StdDevResults.Where(t => t.ZScore <= (Decimal)2.0 && t.ZScore > (Decimal)1.0).OrderByDescending(t => t.ZScore).FirstOrDefault(); var ninetynineHighLimitPrice = HistoricalQuotes.Max(q => q.Close); var mean = StdDevResults.Where(t => t.ZScore <(Decimal)(0) && t.ZScore>(Decimal)(-1)).OrderByDescending(t => t.ZScore).FirstOrDefault(); var meanPrice = mean.StdDev * mean.ZScore + mean.Mean; var List = new List <decimal> { sixtyEightLowLimitPrice.Value, sixtyEightHighLimitPrice.Value, meanPrice.Value, ninetynineHighLimitPrice, ninetyLowLimitPrice.Value }; var sorted = List.OrderBy(t => t).ToList(); FiveBasicNumber = new FiveBasicNumberValue { NinetyLow = sorted[0], SixtyEightLow = sorted[1], Mean = sorted[2], SixtyEightHigh = sorted[3], NinetyNineHigh = sorted[4] * ((decimal)1.1) }; }
public AlertMgr(string currentSticker) { CurrentSticker = currentSticker; GetQuoteAndStdIndicator(); Factory = new AlertFactory(StdDevResults, HistoricalQuotes); CurrentQuote = HistoricalQuotes.OrderByDescending(q => q.Date).FirstOrDefault(); RsiResults = new List <StochResult>(); ChaikinOscResults = new List <ChaikinOscResult>(); }
private bool SendHighLimit() { var quoteAveragePrice = HistoricalQuotes.Average(s => s.Close); var currentQuotePrice = HistoricalQuotes .Where(q => q.Date.Date <= DateTime.Now.Date) .OrderByDescending(q => q.Date) .FirstOrDefault(); var inHighRange = currentQuotePrice != null && currentQuotePrice.Close >= quoteAveragePrice; return(inHighRange); }
private void CaculateLowLimitResult(AlertInfo stdLowAlertInfo) { var maxStickerQuote = HistoricalQuotes.Max(s => s.High); var minStickerQuote = HistoricalQuotes.Min(s => s.Low); var currentPrice = HistoricalQuotes.OrderByDescending(q => q.Date).FirstOrDefault(); CalculateHighAndLowLimitPriceForLowAlertInfo(stdLowAlertInfo, maxStickerQuote, minStickerQuote); if (currentPrice?.Close <= stdLowAlertInfo.HighLimit) { ToAlertToBuy = true; } }
public void Execute(object parameter) { ChartMouseEventArgs e = parameter as ChartMouseEventArgs; ChartPoint cp = e.Segment.CorrespondingPoints[0].DataPoint as ChartPoint; HistoricalQuotes hq = cp.Tag as HistoricalQuotes; DateTime dt = hq.Date.Value; viewmodel.Date = dt.ToShortDateString(); viewmodel.Open = e.Segment.CorrespondingPoints[0].DataPoint.Values[0].ToString(); viewmodel.Close = e.Segment.CorrespondingPoints[0].DataPoint.Values[1].ToString(); viewmodel.High = e.Segment.CorrespondingPoints[0].DataPoint.Values[2].ToString(); viewmodel.Low = e.Segment.CorrespondingPoints[0].DataPoint.Values[3].ToString(); viewmodel.IsOpen = true; viewmodel.OffsetX = (e.MouseEventArgs.GetPosition(e.Segment.Series.Area)).X + 10; viewmodel.OffsetY = (e.MouseEventArgs.GetPosition(e.Segment.Series.Area)).Y + 15; e.Segment.Interior = Brushes.Gold; }
private void CalculateSuggestionPrices(AlertInfo stdHighAlertInfo, AlertInfo stdLowAlertInfo) { var maxStickerQuote = HistoricalQuotes.Max(s => s.High); var minStickerQuote = HistoricalQuotes.Min(s => s.Low); CalculateHighAndLowLimitPriceForLowAlertInfo(stdLowAlertInfo, maxStickerQuote, minStickerQuote); CalculateHighAndLowLimitPriceForHighRangeAlertInfo(stdHighAlertInfo, maxStickerQuote, maxStickerQuote); if (stdHighAlertInfo.HighLimit > stdLowAlertInfo.HighLimit) { MakeSuggestions(stdHighAlertInfo, stdLowAlertInfo); } else { MakeSuggestions(stdLowAlertInfo, stdHighAlertInfo); } }
private SuggestedAction CheckForAlert() { var currentPrice = HistoricalQuotes.OrderByDescending(q => q.Date).FirstOrDefault(); if (currentPrice?.Close >= Factory.Calculator.SellingSuggestion.LowLimit) { return(SuggestedAction.Sell); } else if (currentPrice?.Close < Factory.Calculator.SellingSuggestion.LowLimit && SendHighLimit()) { return(SuggestedAction.WaitToSell); } else if (Factory.Calculator.BuyingSuggestion.HighLimit >= currentPrice?.Close) { return(SuggestedAction.Buy); } else if (Factory.Calculator.BuyingSuggestion.HighLimit < currentPrice?.Close && !SendHighLimit()) { return(SuggestedAction.WaitToBuy); } return(SuggestedAction.Wait); }
private SuggestedAction CheckForSecondAlert() { var currentPrice = HistoricalQuotes.OrderByDescending(q => q.Date).FirstOrDefault(); if (currentPrice?.Close <= Factory.SecondCalculator.SellingSuggestion.LowLimit) { return(SuggestedAction.BuyTheDip); } else if (currentPrice?.Close >= Factory.SecondCalculator.SellingSuggestion.HighLimit) { return(SuggestedAction.Sell); } else if (currentPrice?.Close >= Factory.SecondCalculator.HoldOrSellSuggestion.LowLimit && currentPrice?.Close < Factory.SecondCalculator.HoldOrSellSuggestion.HighLimit) { return(SuggestedAction.HoldPriceCouldGoUp); } else if (Factory.SecondCalculator.HoldOrBuySuggestion.HighLimit >= currentPrice?.Close && currentPrice?.Close > Factory.SecondCalculator.HoldOrBuySuggestion.LowLimit) { return(SuggestedAction.HoldPriceCouldGoDown); } else if (Factory.SecondCalculator.BuyingSuggestion.HighLimit >= currentPrice?.Close && Factory.SecondCalculator.BuyingSuggestion.LowLimit < currentPrice?.Close) { if (currentPrice?.Close < Factory.SecondCalculator.FiveBasicNumber.Mean) { return(SuggestedAction.StrongBuy); } return(SuggestedAction.Buy); } else { return(SuggestedAction.Wait); } }
public StoreHistoricalQuotesRequest(string symbol, EnumPeriod period, HistoricalQuotes data) : base(symbol, period) { Data = data; }