private static List <Chart_Indicator> GetSymbolIndicators(ctaCOMMON.Charts.Symbol symbol, int indicatorsCount, bool initializeFromDatabase, CandelRange candelRange, out bool indicatorUpdate) { List <Chart_Indicator> indicators = new List <Chart_Indicator>(); indicatorUpdate = false; using (ctaDBEntities entities = new ctaDBEntities()) { entities.Database.Connection.Open(); var indicators_entities = entities.Portfolio_Stock_Indicator.Where(psi => psi.portfolio_id == symbol.Portfolio_ID && psi.stock_id == symbol.Symbol_ID); if (indicators_entities.Count() != indicatorsCount) { indicatorUpdate = true; foreach (var indicator_entitie in indicators_entities) { Chart_Indicator indicator = Chart_Indicator_Builder.BuildIndicatorInstance(indicator_entitie.Indicator.name); indicator.ID = indicator_entitie.Id; if (initializeFromDatabase) { indicator.InitializeFromDataBaseValues(symbol.Quotes, indicator_entitie.param1, indicator_entitie.color1, indicator_entitie.param2, indicator_entitie.color2, indicator_entitie.param3, indicator_entitie.color3, candelRange); } indicators.Add(indicator); } } entities.Database.Connection.Close(); } return(indicators); }
public static Serie GetIndicatorTooltip(Chart_Indicator indicator) { Serie serie = new Serie(); for (int j = 0; j < indicator.Series[0].Data.Count; j++) { string datestr = indicator.Series[0].Data[j].Date.ToString("MMMM", CultureInfo.CreateSpecificCulture("es")).Substring(0, 3).ToUpper() + " " + indicator.Series[0].Data[j].Date.Day + ", " + indicator.Series[0].Data[j].Date.Year; string border_color = "#797979"; string tooltip_content = ""; string tooltip = "<div style='padding:5px;width:100%;border: 3px solid !!border_color!!;'><strong>!!datestr!!</strong>!!content!!</div>"; for (int i = 0; i < indicator.Series.Count; i++) { Serie current_serie = indicator.Series[i]; SerieValue current_serievalue = indicator.Series[i].Data[j]; tooltip_content += "<br/><span style='font-size:10px;color:" + current_serie.Color + ";'>" + current_serie.Column_Data_Label + ": " + "</span><span><strong>" + current_serievalue.Value.ToString("0.00") + "</strong></span>"; } tooltip = tooltip.Replace("!!datestr!!", datestr).Replace("!!border_color!!", border_color).Replace("!!content!!", tooltip_content); serie.Data.Add(new SerieValue() { Date = indicator.Series[0].Data[j].Date, Tooltip = tooltip }); } serie.IsTooltip = true; return(serie); }