示例#1
0
 // TODO: rewrite
 public static double Value(ISeries input, int index, int length, BarData barData = BarData.Close, RegressionDistanceMode distanceMode = RegressionDistanceMode.Time)
 {
     if (index >= length - 1)
     {
         double num = 0.0;
         double num2 = 0.0;
         double num3 = 0.0;
         double num4 = 0.0;
         if (distanceMode == RegressionDistanceMode.Time)
         {
             double num5 = input.GetDateTime(index).Subtract(input.GetDateTime(index - 1)).Ticks;
             for (int i = index; i > index - length; i--)
             {
                 num += input.GetDateTime(i).Subtract(input.GetDateTime(index - length + 1)).Ticks / num5;
                 num2 += input.GetDateTime(i).Subtract(input.GetDateTime(index - length + 1)).Ticks / num5 * input[i, barData];
                 num3 += input[i, barData];
                 num4 += input.GetDateTime(i).Subtract(input.GetDateTime(index - length + 1)).Ticks / num5 * input.GetDateTime(i).Subtract(input.GetDateTime(index - length + 1)).Ticks / num5;
             }
         }
         else
         {
             for (int j = index; j > index - length; j--)
             {
                 num += j - index + length - 1;
                 num2 += (j - index + length - 1) * input[j, barData];
                 num3 += input[j, barData];
                 num4 += ((j - index + length - 1) * (j - index + length - 1));
             }
         }
         return (length * num2 - num * num3) / (length * num4 - Math.Pow(num, 2.0));
     }
     return double.NaN;
 }
示例#2
0
		/// <summary>
		///   儲存交易報表(CSV格式)
		/// </summary>
		/// <param name="filename">欲儲存的檔案</param>
		/// <param name="symbolId">商品名稱</param>
		/// <param name="positions">商品交易的倉位資訊</param>
		public static void Save(string filename, string symbolId, ISeries<IMarketPosition> positions) {
			if (File.Exists(filename)) {
				File.Delete(filename);
			}

			PositionSeries cPositions = positions as PositionSeries;
			StringBuilder cBuilder = new StringBuilder(1024 * 1024);
			cBuilder.Append("NO.").Append(',').Append("SymbolID").Append(',').Append("Category").Append(',').Append("Action").Append(',').Append("Volume").Append(',').Append("Price").Append(',').Append("Profit").Append(',').Append("Fee").Append(',').Append("Tax").Append(',').Append("Trading time").Append(',').AppendLine("Description");

			int iCount = cPositions.Count;
			for (int i = 0; i < iCount; i++) {
				IMarketPosition cPosition = cPositions[i];
				if (cPosition.Value > 0) {
					List<ITrade> cTrades = cPosition.ClosedTrades;
					foreach (ITrade cTrade in cTrades) {
						ITradeOrder cOpenO = cTrade.EntryOrder;
						ITradeOrder cCloseO = cTrade.ExitOrder;

						cBuilder.Append(cOpenO.Ticket).Append(',').Append(symbolId).Append(',').Append(cOpenO.Category).Append(',').Append(cOpenO.Action).Append(',').Append(cOpenO.Contracts).Append(',').Append(cOpenO.Price).Append(',').Append(string.Empty).Append(',').Append(cOpenO.Fee).Append(',').Append(cOpenO.Tax).Append(',').Append(cOpenO.Time.ToString("yyyy/MM/dd HH:mm:ss")).Append(',').AppendLine(cOpenO.Name);
						cBuilder.Append(cCloseO.Ticket).Append(',').Append(symbolId).Append(',').Append(cCloseO.Category).Append(',').Append(cCloseO.Action).Append(',').Append(cCloseO.Contracts).Append(',').Append(cCloseO.Price).Append(',').Append(cTrade.Profit).Append(',').Append(cCloseO.Fee).Append(',').Append(cCloseO.Tax).Append(',').Append(cCloseO.Time.ToString("yyyy/MM/dd HH:mm:ss")).Append(',').AppendLine(cCloseO.Name);
					}
				}
			}
			File.WriteAllText(filename, cBuilder.ToString(), Encoding.UTF8);
		}
示例#3
0
文件: ENVU.cs 项目: ForTrade/CSharp
		public ENVU(ISeries input, int length, double shift, BarData barData = BarData.Close) : base(input)
		{
			this.length = length;
			this.shift = shift;
			this.barData = barData;
			this.Init();
		}
示例#4
0
 public static double Value(ISeries input, int index, int length)
 {
     return index < length - 1
         ? double.NaN
         : (input[index, BarData.Volume] - input[index - length + 1, BarData.Volume])/
           input[index - length + 1, BarData.Volume]*100;
 }
        private static DataPoint? GetNearestPoint(ISeries s, ScreenPoint point, bool snap, bool pointsOnly)
        {
            if (s == null)
                return null;

            if (snap || pointsOnly)
            {
                ScreenPoint spn;
                DataPoint dpn;
                if (s.GetNearestPoint(point, out dpn, out spn) && snap)
                {
                    if (spn.DistanceTo(point) < 20)
                        return dpn;
                }
            }

            ScreenPoint sp;
            DataPoint dp;

            if (!pointsOnly)
                if (s.GetNearestInterpolatedPoint(point, out dp, out sp))
                    return dp;

            return null;
        }
示例#6
0
 public D_Slow(ISeries input, int length, int order1, int order2) : base(input)
 {
     this.length = length;
     this.order1 = order1;
     this.order2 = order2;
     Init();
 }
示例#7
0
 public DPO1(ISeries series, int length, BarData barData)
     : base(series)
 {
     this.length = length;//长度
     this.option = barData;//bar类型
     this.Name = "DPO";//名称
 }
示例#8
0
 public static double ValueWithLastValue(ISeries input, int index, double last)
 {
     var c = input[index, BarData.Close];
     var lc = input[index - 1, BarData.Close];
     var v = input[index, BarData.Volume];
     return (c - lc)/lc*v + last;
 }
示例#9
0
文件: MFI.cs 项目: ForTrade/CSharp
		public static double Value(ISeries input, int index, int length)
		{
			if (index >= length)
			{
				double num = 0.0;
				double num2 = 0.0;
				for (int i = index; i > index - length; i--)
				{
					double num3 = input[i, BarData.Typical];
					double num4 = input[i - 1, BarData.Typical];
					double num5 = input[i, BarData.Volume];
					double arg_48_0 = input[i - 1, BarData.Volume];
					if (num3 > num4)
					{
						num += num3 * num5;
					}
					else
					{
						num2 += num3 * num5;
					}
				}
				double num6 = num / num2;
				return 100.0 - 100.0 / (1.0 + num6);
			}
			return double.NaN;
		}
示例#10
0
 public HV(ISeries input, int length, double span, BarData barData = BarData.Close) : base(input)
 {
     this.length = length;
     this.span = span;
     this.barData = barData;
     Init();
 }
示例#11
0
 public BBU(ISeries input, int length, double k, BarData barData = BarData.Close) : base(input)
 {
     this.length = length;
     this.k = k;
     this.barData = barData;
     Init();
 }
示例#12
0
文件: AD.cs 项目: ForTrade/CSharp
		public static double Value(ISeries input, int index)
		{
			if (index >= 0)
			{
				double num = input[index, BarData.High];
				double num2 = input[index, BarData.Low];
				double num3 = input[index, BarData.Close];
				double arg_2A_0 = input[index, BarData.Open];
				double num4 = input[index, BarData.Volume];
				double result = 0.0;
				if (index >= 1)
				{
					if (num != num2)
					{
						result = num4 * (num3 - num2 - (num - num3)) / (num - num2) + AD.Value(input, index - 1);
					}
					else
					{
						result = AD.Value(input, index - 1);
					}
				}
				else
				{
					if (index == 0 && num != num2)
					{
						result = num4 * (num3 - num2 - (num - num3)) / (num - num2);
					}
				}
				return result;
			}
			return double.NaN;
		}
示例#13
0
 public RSI(ISeries input, int length, BarData barData = BarData.Close, IndicatorStyle style = IndicatorStyle.QuantStudio):base(input)
 {
     this.length = length;
     this.barData = barData;
     this.style = style;
     Init();
 }
示例#14
0
文件: SAR.cs 项目: ForTrade/CSharp
		public SAR(ISeries input, double upperBound, double step, double initialAcc) : base(input)
		{
			this.upperBound = upperBound;
			this.step = step;
			this.initialAcc = initialAcc;
			this.Init();
		}
示例#15
0
文件: LRS.cs 项目: ForTrade/CSharp
		public LRS(ISeries input, int length, BarData barData = BarData.Close, RegressionDistanceMode distanceMode = RegressionDistanceMode.Time) : base(input)
		{
			this.length = length;
			this.barData = barData;
			this.distanceMode = distanceMode;
			this.Init();
		}
示例#16
0
文件: UltOsc.cs 项目: ForTrade/CSharp
		public UltOsc(ISeries input, int n1, int n2, int n3) : base(input)
		{
			this.n1 = n1;
			this.n2 = n2;
			this.n3 = n3;
			this.Init();
		}
示例#17
0
 public DPO1(ISeries series, int length, BarData barData)
     : base(series)
 {
     this.length = length;
     this.option = barData;
     this.Name = "DPO";
 }
 public RectangleRenderableSeries(ISeries series)
 {
     ResamplingMode = ResamplingMode.None;
     DataSeries = series;
     IsVisible = true;
     base.DataSeries = new DummyDataSeries(series);
 }
示例#19
0
 //TODO: rewrite
 public static double Value(ISeries input, int index, int length, IndicatorStyle style = IndicatorStyle.QuantStudio)
 {
     if (index >= 2 * length)
     {
         double num = 0.0;
         double result;
         if (style == IndicatorStyle.QuantStudio)
         {
             for (int i = index; i > index - length; i--)
             {
                 num += DX.Value(input, i, length, IndicatorStyle.QuantStudio);
             }
             result = num / (double)length;
         }
         else
         {
             for (int j = 2 * length; j > length; j--)
             {
                 num += DX.Value(input, j, length, style);
             }
             num /= (double)length;
             for (int k = 2 * length + 1; k <= index; k++)
             {
                 num = (num * (double)(length - 1) + DX.Value(input, k, length, style)) / (double)length;
             }
             result = num;
         }
         return result;
     }
     return double.NaN;
 }
示例#20
0
文件: PVI.cs 项目: ForTrade/CSharp
		public static double Value(ISeries input, int index)
		{
			if (index >= 1)
			{
				double num = input[index, BarData.Close];
				double num2 = input[index - 1, BarData.Close];
				double num3 = input[index, BarData.Volume];
				double num4 = input[index - 1, BarData.Volume];
				double num5 = PVI.Value(input, index - 1);
				double result;
				if (num3 > num4)
				{
					result = num5 + num5 * (num - num2) / num2;
				}
				else
				{
					result = num5;
				}
				return result;
			}
			if (index == 0)
			{
				return 10000.0;
			}
			return double.NaN;
		}
示例#21
0
文件: PDM.cs 项目: ForTrade/CSharp
		public static double Value(ISeries input, int index)
		{
			if (index < 1)
			{
				return double.NaN;
			}
			double num = input[index, BarData.High];
			double num2 = input[index, BarData.Low];
			double num3 = input[index - 1, BarData.High];
			double num4 = input[index - 1, BarData.Low];
			double num5 = 0.0;
			double num6 = 0.0;
			if (num > num3)
			{
				num5 = num - num3;
			}
			if (num2 < num4)
			{
				num6 = num4 - num2;
			}
			if (num5 > num6)
			{
				return num5;
			}
			return 0.0;
		}
示例#22
0
文件: OSC.cs 项目: ForTrade/CSharp
		public OSC(ISeries input, int length1, int length2, BarData barData = BarData.Close) : base(input)
		{
			this.length1 = length1;
			this.length2 = length2;
			this.barData = barData;
			this.Init();
		}
示例#23
0
文件: WAD.cs 项目: ForTrade/CSharp
		public static double Value(ISeries input, int index)
		{
			double result = 0.0;
			if (index >= 1)
			{
				double val = input[index, BarData.High];
				double val2 = input[index, BarData.Low];
				double num = input[index, BarData.Close];
				double num2 = input[index - 1, BarData.Close];
				double arg_3D_0 = input[index, BarData.Volume];
				if (num > num2)
				{
					result = WAD.Value(input, index - 1) + num - Math.Min(val2, num2);
				}
				if (num < num2)
				{
					result = WAD.Value(input, index - 1) + num - Math.Max(val, num2);
				}
				if (num == num2)
				{
					result = WAD.Value(input, index - 1);
				}
			}
			return result;
		}
示例#24
0
		/// <summary>
		/// Initialize a new instance of the Repair class.
		/// </summary>
		/// <param name="publisher">The publisher.</param>
		/// <param name="series">The series.</param>
		/// <param name="chapter">The chapter.</param>
		/// <param name="comicInfo">The comic information.</param>
		/// <param name="brokenPages">Each broken page.</param>
		public Repair(IPublisher publisher, ISeries series, IChapter chapter, ComicInfo comicInfo, IEnumerable<string> brokenPages) {
			_brokenPages = brokenPages;
			_chapter = chapter;
			_comicInfo = comicInfo;
			_publisher = publisher;
			_series = series;
		}
示例#25
0
文件: SMD.cs 项目: ForTrade/CSharp
		public static double Value(ISeries input, int index, int length, BarData barData = BarData.Close)
		{
			if (index >= length - 1)
			{
				return Math.Sqrt(SMV.Value(input, index, length, barData));
			}
			return double.NaN;
		}
示例#26
0
 public KaufmanAMA(ISeries series, int n, int p, int q)
     : base(series)
 {
     this.n = n;
     this.p = p;
     this.q = q;
     this.Name = string.Format("KaufmanAMA({0},{1},{2})", n, p, q);
 }
示例#27
0
 public static double Value(ISeries input, int index, int length, BarData barData = BarData.Close)
 {
     if (index >= 1)
         return ValueWithLastValue(input, index, length, Value(input, index - 1, length, barData), barData);
     if (index == 0)
         return input[0, barData];
     return double.NaN;
 }
示例#28
0
文件: ROC.cs 项目: ForTrade/CSharp
		public static double Value(ISeries input, int index, int length, BarData barData = BarData.Close)
		{
			if (index >= length)
			{
				return (input[index, barData] - input[index - length, barData]) / input[index - length, barData] * 100.0;
			}
			return double.NaN;
		}
示例#29
0
		/// <summary>
		///   建構子
		/// </summary>
		/// <param name="service">AbstractOrderService 下單服務抽象類別</param>
		/// <param name="args">下單參數</param>
		internal OrderPriced(AbstractOrderService service, SOrderParameters args) {
			this.ID = service.GetOrderID();
			Contracts cContract = args.Lots;
			this.Info = new Order(args.Name, args.Action, OrderCategory.Limit, (cContract.IsDefault) ? service.DefaultContracts : args.Lots, false, args.ExitTypeInfo);

			__cSender = service as IOrderSender;
			__cPositions = service.Positions;
		}
示例#30
0
文件: PCL.cs 项目: ForTrade/CSharp
		public static double Value(ISeries input, int index, int length)
		{
			if (index >= length)
			{
				return input.GetMin(index - length, index - 1, BarData.Low);
			}
			return double.NaN;
		}
示例#31
0
 public Indicators.Range Range(ISeries <double> input)
 {
     return(indicator.Range(input));
 }
示例#32
0
 public Indicators.StdError StdError(ISeries <double> input, int period)
 {
     return(indicator.StdError(input, period));
 }
示例#33
0
 public Indicators.T3 T3(ISeries <double> input, int period, int tCount, double vFactor)
 {
     return(indicator.T3(input, period, tCount, vFactor));
 }
 public Indicators.TextChartInfo TextChartInfo(ISeries <double> input)
 {
     return(indicator.TextChartInfo(input));
 }
示例#35
0
 public Indicators.SpyData SpyData(ISeries <double> input)
 {
     return(indicator.SpyData(input));
 }
示例#36
0
 public Indicators.CalculateValueArea CalculateValueArea(ISeries <double> input, bool inclWeekendVol, string profileType, double pctOfVolumeInVA, int openHour, int openMinute, double sessionLengthInHours)
 {
     return(indicator.CalculateValueArea(input, inclWeekendVol, profileType, pctOfVolumeInVA, openHour, openMinute, sessionLengthInHours));
 }
示例#37
0
 public MDM(ISeries input) : base(input)
 {
     Init();
 }
示例#38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChartPoint"/> class.
 /// </summary>
 /// <param name="chart">The chart.</param>
 /// <param name="series">The series.</param>
 public ChartPoint(IChartView chart, ISeries series)
 {
     Context = new ChartPointContext(chart, series);
 }
示例#39
0
 public WAD(ISeries input) : base(input)
 {
     this.Init();
 }
示例#40
0
 public Indicators.StatsIB StatsIB(ISeries <double> input, DateTime rTHopen, DateTime iB, DateTime rTHclose, double minIB, double minRange, bool currentDayOnly, bool calcIB, bool calcRange, bool calcVolume, Brush backgroundColor, Brush fontColor, Brush outlineColor, SimpleFont noteFont, int backgroundOpacity)
 {
     return(indicator.StatsIB(input, rTHopen, iB, rTHclose, minIB, minRange, currentDayOnly, calcIB, calcRange, calcVolume, backgroundColor, fontColor, outlineColor, noteFont, backgroundOpacity));
 }
示例#41
0
 public Indicators.DMFXCOTFinFut DMFXCOTFinFut(ISeries <double> input, string accountKey, NinjaTrader.NinjaScript.Indicators.DMFXCOTFinFut.ECOTFinCodes cOTCode, int weeksBack, string host)
 {
     return(indicator.DMFXCOTFinFut(input, accountKey, cOTCode, weeksBack, host));
 }
 public Indicators.CumulativeDelta CumulativeDelta(ISeries <double> input, CumulativeDeltaTimeframe resetDeltaOn)
 {
     return(indicator.CumulativeDelta(input, resetDeltaOn));
 }
示例#43
0
 public Indicators.RSS RSS(ISeries <double> input, int eMA1, int eMA2, int length)
 {
     return(indicator.RSS(input, eMA1, eMA2, length));
 }
示例#44
0
 public SMA(ISeries input, int length, BarData barData = BarData.Close) : base(input)
 {
     this.length  = length;
     this.barData = barData;
     this.Init();
 }
示例#45
0
 // Constructor
 public SeriesWatchlistMenu(ISeries seriesRepository, IWatchlist watchlistRepository)
 {
     _seriesRepository    = seriesRepository;
     _watchlistRepository = watchlistRepository;
 }
示例#46
0
 public Indicators.IchimokuCloud IchimokuCloud(ISeries <double> input, bool displayCloudOnly, bool adjustBarMargins, int periodFast, int periodMedium, int periodSlow, int cloudColorOpacity, Brush cloudAreaColorUp, Brush cloudAreaColorDown, int cloudDisplacement)
 {
     return(indicator.IchimokuCloud(input, displayCloudOnly, adjustBarMargins, periodFast, periodMedium, periodSlow, cloudColorOpacity, cloudAreaColorUp, cloudAreaColorDown, cloudDisplacement));
 }
示例#47
0
 public Indicators.EaseOfMovement EaseOfMovement(ISeries <double> input, int smoothing, int volumeDivisor)
 {
     return(indicator.EaseOfMovement(input, smoothing, volumeDivisor));
 }
示例#48
0
 public Indicators.DailyPivots DailyPivots(ISeries <double> input, int strength)
 {
     return(indicator.DailyPivots(input, strength));
 }
示例#49
0
 private void CalculateGD(ISeries <double> input, Series <double> output)
 {
     output[0] = (EMA(input, Period)[0] * (1 + VFactor)) - (EMA(EMA(input, Period), Period)[0] * VFactor);
 }
示例#50
0
        public override void Execute(GrapeCity.Documents.Excel.Workbook workbook)
        {
            IWorksheet worksheet = workbook.Worksheets[0];

            //-----------------------------Set Value------------------------------
            worksheet.Range["B3:C7"].Value = new object[, ]
            {
                { "ITEM", "AMOUNT" },
                { "Income 1", 2500 },
                { "Income 2", 1000 },
                { "Income 3", 250 },
                { "Other", 250 },
            };
            worksheet.Range["B10:C23"].Value = new object[, ]
            {
                { "ITEM", "AMOUNT" },
                { "Rent/mortgage", 800 },
                { "Electric", 120 },
                { "Gas", 50 },
                { "Cell phone", 45 },
                { "Groceries", 500 },
                { "Car payment", 273 },
                { "Auto expenses", 120 },
                { "Student loans", 50 },
                { "Credit cards", 100 },
                { "Auto Insurance", 78 },
                { "Personal care", 50 },
                { "Entertainment", 100 },
                { "Miscellaneous", 50 },
            };

            worksheet.Range["B2:C2"].Merge();
            worksheet.Range["B2"].Value = "MONTHLY INCOME";
            worksheet.Range["B9:C9"].Merge();
            worksheet.Range["B9"].Value = "MONTHLY EXPENSES";
            worksheet.Range["E2:G2"].Merge();
            worksheet.Range["E2"].Value = "PERCENTAGE OF INCOME SPENT";
            worksheet.Range["E5:G5"].Merge();
            worksheet.Range["E5"].Value = "SUMMARY";
            worksheet.Range["E3:F3"].Merge();
            worksheet.Range["E9"].Value = "BALANCE";
            worksheet.Range["E6"].Value = "Total Monthly Income";
            worksheet.Range["E7"].Value = "Total Monthly Expenses";


            //--------------------------------Set Height & Width--------------------------------
            worksheet.StandardHeight = 26.25;
            worksheet.StandardWidth  = 8.43;

            worksheet.Range["2:24"].RowHeight  = 27;
            worksheet.Range["A:A"].ColumnWidth = 2.855;
            worksheet.Range["B:B"].ColumnWidth = 33.285;
            worksheet.Range["C:C"].ColumnWidth = 25.57;
            worksheet.Range["D:D"].ColumnWidth = 1;
            worksheet.Range["E:F"].ColumnWidth = 25.57;
            worksheet.Range["G:G"].ColumnWidth = 14.285;


            //------------------------------Set Table--------------------------------------
            ITable incomeTable = worksheet.Tables.Add(worksheet.Range["B3:C7"], true);

            incomeTable.Name       = "tblIncome";
            incomeTable.TableStyle = workbook.TableStyles["TableStyleMedium4"];
            ITable expensesTable = worksheet.Tables.Add(worksheet.Range["B10:C23"], true);

            expensesTable.Name       = "tblExpenses";
            expensesTable.TableStyle = workbook.TableStyles["TableStyleMedium4"];

            //------------------------------Set Formulas-----------------------------------
            worksheet.Names.Add("TotalMonthlyIncome", "=SUM(tblIncome[AMOUNT])");
            worksheet.Names.Add("TotalMonthlyExpenses", "=SUM(tblExpenses[AMOUNT])");
            worksheet.Range["E3"].Formula = "=TotalMonthlyExpenses";
            worksheet.Range["G3"].Formula = "=TotalMonthlyExpenses/TotalMonthlyIncome";
            worksheet.Range["G6"].Formula = "=TotalMonthlyIncome";
            worksheet.Range["G7"].Formula = "=TotalMonthlyExpenses";
            worksheet.Range["G9"].Formula = "=TotalMonthlyIncome-TotalMonthlyExpenses";

            //----------------------------Set Styles-------------------------
            IStyle currencyStyle = workbook.Styles["Currency"];

            currencyStyle.IncludeAlignment    = true;
            currencyStyle.HorizontalAlignment = HorizontalAlignment.Left;
            currencyStyle.VerticalAlignment   = VerticalAlignment.Bottom;
            currencyStyle.NumberFormat        = "$#,##0.00";

            IStyle heading1Style = workbook.Styles["Heading 1"];

            heading1Style.IncludeAlignment    = true;
            heading1Style.HorizontalAlignment = HorizontalAlignment.Center;
            heading1Style.VerticalAlignment   = VerticalAlignment.Center;
            heading1Style.Font.Name           = "Century Gothic";
            heading1Style.Font.Bold           = true;
            heading1Style.Font.Size           = 11;
            heading1Style.Font.Color          = Color.White;
            heading1Style.IncludeBorder       = false;
            heading1Style.IncludePatterns     = true;
            heading1Style.Interior.Color      = Color.FromArgb(32, 61, 64);

            IStyle percentStyle = workbook.Styles["Percent"];

            percentStyle.IncludeAlignment    = true;
            percentStyle.HorizontalAlignment = HorizontalAlignment.Center;
            percentStyle.IncludeFont         = true;
            percentStyle.Font.Color          = Color.FromArgb(32, 61, 64);
            percentStyle.Font.Name           = "Century Gothic";
            percentStyle.Font.Bold           = true;
            percentStyle.Font.Size           = 14;

            worksheet.SheetView.DisplayGridlines = false;
            worksheet.Range["C4:C7, C11:C23, G6:G7, G9"].Style = currencyStyle;
            worksheet.Range["B2, B9, E2, E5"].Style            = heading1Style;
            worksheet.Range["G3"].Style = percentStyle;

            worksheet.Range["E6:G6"].Borders[BordersIndex.EdgeBottom].LineStyle = BorderLineStyle.Medium;
            worksheet.Range["E6:G6"].Borders[BordersIndex.EdgeBottom].Color     = Color.FromArgb(32, 61, 64);
            worksheet.Range["E7:G7"].Borders[BordersIndex.EdgeBottom].LineStyle = BorderLineStyle.Medium;
            worksheet.Range["E7:G7"].Borders[BordersIndex.EdgeBottom].Color     = Color.FromArgb(32, 61, 64);

            worksheet.Range["E9:G9"].Interior.Color      = Color.FromArgb(32, 61, 64);
            worksheet.Range["E9:G9"].HorizontalAlignment = HorizontalAlignment.Left;
            worksheet.Range["E9:G9"].VerticalAlignment   = VerticalAlignment.Center;
            worksheet.Range["E9:G9"].Font.Name           = "Century Gothic";
            worksheet.Range["E9:G9"].Font.Bold           = true;
            worksheet.Range["E9:G9"].Font.Size           = 11;
            worksheet.Range["E9:G9"].Font.Color          = Color.White;
            worksheet.Range["E3:F3"].Borders.Color       = Color.FromArgb(32, 61, 64);

            //----------------------------Set Conditional Format-------------------------
            IDataBar dataBar = worksheet.Range["E3"].FormatConditions.AddDatabar();

            dataBar.MinPoint.Type  = ConditionValueTypes.Number;
            dataBar.MinPoint.Value = 1;
            dataBar.MaxPoint.Type  = ConditionValueTypes.Number;
            dataBar.MaxPoint.Value = "=TotalMonthlyIncome";
            dataBar.BarFillType    = DataBarFillType.Gradient;
            dataBar.BarColor.Color = Color.Red;
            dataBar.ShowValue      = false;

            //--------------------------------Set Shape--------------------------------
            IShape shape = worksheet.Shapes.AddChart(ChartType.ColumnClustered, 339, 247, 316.5, 346);

            shape.Chart.ChartArea.Format.Line.Transparency = 1;
            shape.Chart.ColumnGroups[0].Overlap            = 0;
            shape.Chart.ColumnGroups[0].GapWidth           = 37;

            IAxis category_axis = shape.Chart.Axes.Item(AxisType.Category);

            category_axis.Format.Line.Color.RGB     = Color.Black;
            category_axis.TickLabels.Font.Size      = 11;
            category_axis.TickLabels.Font.Color.RGB = Color.Black;

            IAxis series_axis = shape.Chart.Axes.Item(AxisType.Value);

            series_axis.Format.Line.Weight        = 1;
            series_axis.Format.Line.Color.RGB     = Color.Black;
            series_axis.TickLabels.NumberFormat   = "$###0";
            series_axis.TickLabels.Font.Size      = 11;
            series_axis.TickLabels.Font.Color.RGB = Color.Black;

            ISeries chartSeries = shape.Chart.SeriesCollection.NewSeries();

            chartSeries.Formula = "=SERIES(\"Simple Budget\",{\"Income\",\"Expenses\"},'Sheet1'!$G$6:$G$7,1)";
            chartSeries.Points[0].Format.Fill.Color.RGB = Color.FromArgb(176, 21, 19);
            chartSeries.Points[1].Format.Fill.Color.RGB = Color.FromArgb(234, 99, 18);
            chartSeries.DataLabels.Font.Size            = 11;
            chartSeries.DataLabels.Font.Color.RGB       = Color.Black;
            chartSeries.DataLabels.ShowValue            = true;
            chartSeries.DataLabels.Position             = DataLabelPosition.OutsideEnd;
        }
示例#51
0
 public Indicators.ConstantLines ConstantLines(ISeries <double> input, double line1Value, double line2Value, double line3Value, double line4Value)
 {
     return(indicator.ConstantLines(input, line1Value, line2Value, line3Value, line4Value));
 }
示例#52
0
 public Indicators.CamarillaPivots CamarillaPivots(ISeries <double> input, PivotRange pivotRangeType, HLCCalculationMode priorDayHlc, double userDefinedClose, double userDefinedHigh, double userDefinedLow, int width)
 {
     return(indicator.CamarillaPivots(input, pivotRangeType, priorDayHlc, userDefinedClose, userDefinedHigh, userDefinedLow, width));
 }
        public override void Execute(GrapeCity.Documents.Excel.Workbook workbook)
        {
            IWorksheet worksheet = workbook.Worksheets[0];

            //-------------------------Set RowHeight & Width-----------------------------------
            worksheet.StandardHeight = 30;
            worksheet.StandardWidth  = 8.43;

            worksheet.Range["1:1"].RowHeight   = 278.25;
            worksheet.Range["2:4"].RowHeight   = 30.25;
            worksheet.Range["8:8"].RowHeight   = 55.5;
            worksheet.Range["9:30"].RowHeight  = 30.25;
            worksheet.Range["33:33"].RowHeight = 55.5;
            worksheet.Range["34:44"].RowHeight = 43.5;
            worksheet.Range["A:A"].ColumnWidth = 2.777;
            worksheet.Range["B:B"].ColumnWidth = 32.887;
            worksheet.Range["C:C"].ColumnWidth = 24.219;
            worksheet.Range["D:D"].ColumnWidth = 10.109;
            worksheet.Range["E:E"].ColumnWidth = 61.332;
            worksheet.Range["F:F"].ColumnWidth = 2.777;


            //-------------------------Set Table Value & Formulas-------------------------------
            ITable assetsTable = worksheet.Tables.Add(worksheet.Range["B9:D30"], true);

            assetsTable.Name                = "Assets";
            worksheet.Range["B8"].Value     = "Assets";
            worksheet.Range["B9:D30"].Value = new object[, ]
            {
                { "Category", "Item", "Value" },
                { "Real Estate", "Home", 560000 },
                { "Real Estate", "Other", 255000 },
                { "Investments", "Retirement accounts", 98000 },
                { "Investments", "Stocks", 53000 },
                { "Investments", "Bonds", 25000 },
                { "Investments", "Mutual funds", 33000 },
                { "Investments", "CDs", 74000 },
                { "Investments", "Bullion", 20000 },
                { "Investments", "Trust funds", 250000 },
                { "Investments", "Health savings account", 18000 },
                { "Investments", "Face value of life insurance policy", 85000 },
                { "Investments", "Other", 20000 },
                { "Cash", "Checking accounts", 14500 },
                { "Cash", "Savings accounts", 5000 },
                { "Cash", "Other", 2000 },
                { "Personal Property", "Cars", 55000 },
                { "Personal Property", "Other vehicles", 85000 },
                { "Personal Property", "Furnishings", 100000 },
                { "Personal Property", "Collectibles", 50000 },
                { "Personal Property", "Jewelry", 60000 },
                { "Personal Property", "Other luxury goods", 40000 },
            };

            ITable debtsTable = worksheet.Tables.Add(worksheet.Range["B34:C44"], true);

            debtsTable.Name = "Debts";
            worksheet.Range["B33"].Value     = "Debts";
            worksheet.Range["B34:C44"].Value = new object[, ]
            {
                { "Category", "Value" },
                { "Mortgages", 400000 },
                { "Home equity loans", 50000 },
                { "Car loans", 30000 },
                { "Personal loans", 0 },
                { "Credit cards", 0 },
                { "Student loans", 10000 },
                { "Loans against investments", 20000 },
                { "Life insurance loans", 5000 },
                { "Other installment loans", 10000 },
                { "Other debts", 50000 },
            };

            worksheet.Range["B1:C1"].Merge();
            worksheet.Range["B1"].Value   = "Personal\r\nNet\r\nWorth";
            worksheet.Range["B2"].Formula = "=\"Total \"&TotalAssetsLabel";
            worksheet.Range["B3"].Formula = "=\"Total \"&TotalDebtsLabel";
            worksheet.Range["B4"].Formula = "=NetWorthLabel";
            worksheet.Range["C2"].Formula = "=TotalAssets";
            worksheet.Range["C3"].Formula = "=TotalDebts";
            worksheet.Range["C4"].Formula = "=NetWorth";

            worksheet.Names.Add("TotalAssets", "=SUM(Assets[Value])");
            worksheet.Names.Add("TotalDebts", "=SUM(Debts[Value])");
            worksheet.Names.Add("NetWorth", "=TotalAssets-TotalDebts");
            worksheet.Names.Add("TotalAssetsLabel", "=Sheet1!$B$8");
            worksheet.Names.Add("TotalDebtsLabel", "=Sheet1!$B$33");
            worksheet.Names.Add("NetWorthLabel", "=\"Net Worth\"");


            //---------------------------Set Table Style---------------------------
            ITableStyle assetsTableStyle = workbook.TableStyles.Add("Assets");

            workbook.DefaultTableStyle = "Assets";
            assetsTableStyle.TableStyleElements[TableStyleElementType.WholeTable].Font.Color    = Color.FromRGB(64, 64, 64);
            assetsTableStyle.TableStyleElements[TableStyleElementType.WholeTable].Borders.Color = Color.FromRGB(128, 128, 128);
            assetsTableStyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.InsideHorizontal].LineStyle = BorderLineStyle.Dotted;
            assetsTableStyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeBottom].LineStyle       = BorderLineStyle.Thin;
            assetsTableStyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeTop].LineStyle          = BorderLineStyle.None;
            assetsTableStyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeLeft].LineStyle         = BorderLineStyle.None;
            assetsTableStyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeRight].LineStyle        = BorderLineStyle.None;
            assetsTableStyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.InsideVertical].LineStyle   = BorderLineStyle.None;

            assetsTableStyle.TableStyleElements[TableStyleElementType.SecondRowStripe].Interior.Color = Color.White;
            assetsTableStyle.TableStyleElements[TableStyleElementType.SecondRowStripe].StripeSize     = 1;

            assetsTableStyle.TableStyleElements[TableStyleElementType.LastColumn].Font.Bold      = true;
            assetsTableStyle.TableStyleElements[TableStyleElementType.LastColumn].Font.Color     = Color.FromRGB(61, 125, 137);
            assetsTableStyle.TableStyleElements[TableStyleElementType.LastColumn].Interior.Color = Color.White;

            assetsTableStyle.TableStyleElements[TableStyleElementType.HeaderRow].Interior.Color = Color.FromRGB(61, 125, 137);


            ITableStyle debtsTableStyle = workbook.TableStyles.Add("Debts");

            debtsTableStyle.TableStyleElements[TableStyleElementType.WholeTable].Font.Color    = Color.FromRGB(64, 64, 64);
            debtsTableStyle.TableStyleElements[TableStyleElementType.WholeTable].Borders.Color = Color.FromRGB(128, 128, 128);
            debtsTableStyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.InsideHorizontal].LineStyle = BorderLineStyle.Dotted;
            debtsTableStyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeBottom].LineStyle       = BorderLineStyle.Thin;
            debtsTableStyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeTop].LineStyle          = BorderLineStyle.None;
            debtsTableStyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeLeft].LineStyle         = BorderLineStyle.None;
            debtsTableStyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.EdgeRight].LineStyle        = BorderLineStyle.None;
            debtsTableStyle.TableStyleElements[TableStyleElementType.WholeTable].Borders[BordersIndex.InsideVertical].LineStyle   = BorderLineStyle.None;

            debtsTableStyle.TableStyleElements[TableStyleElementType.SecondRowStripe].Interior.Color = Color.White;
            debtsTableStyle.TableStyleElements[TableStyleElementType.SecondRowStripe].StripeSize     = 1;

            debtsTableStyle.TableStyleElements[TableStyleElementType.LastColumn].Font.Bold      = true;
            debtsTableStyle.TableStyleElements[TableStyleElementType.LastColumn].Font.Color     = Color.FromRGB(146, 75, 12);
            debtsTableStyle.TableStyleElements[TableStyleElementType.LastColumn].Interior.Color = Color.White;

            debtsTableStyle.TableStyleElements[TableStyleElementType.HeaderRow].Interior.Color = Color.FromRGB(218, 113, 18);


            //----------------------------Set Named Styles-------------------------
            IStyle normalStyle = workbook.Styles["Normal"];

            normalStyle.Font.Name             = "Century Gothic";
            normalStyle.Font.Size             = 12;
            normalStyle.Font.Color            = Color.FromRGB(64, 64, 64);
            normalStyle.Interior.Color        = Color.FromRGB(243, 243, 236);
            normalStyle.Interior.PatternColor = Color.FromRGB(243, 243, 236);
            normalStyle.HorizontalAlignment   = HorizontalAlignment.Left;
            normalStyle.IndentLevel           = 1;
            normalStyle.VerticalAlignment     = VerticalAlignment.Center;
            normalStyle.WrapText = true;

            IStyle titleStyle = workbook.Styles["Title"];

            titleStyle.IncludeAlignment  = true;
            titleStyle.VerticalAlignment = VerticalAlignment.Center;
            titleStyle.WrapText          = true;
            titleStyle.Font.Name         = "Century Gothic";
            titleStyle.Font.Size         = 66;
            titleStyle.Font.Color        = Color.FromRGB(64, 64, 64);
            titleStyle.IncludePatterns   = true;
            titleStyle.Interior.Color    = Color.FromRGB(243, 243, 236);

            IStyle heading1Style = workbook.Styles["Heading 1"];

            heading1Style.IncludeAlignment    = true;
            heading1Style.HorizontalAlignment = HorizontalAlignment.Left;
            heading1Style.IndentLevel         = 4;
            heading1Style.VerticalAlignment   = VerticalAlignment.Center;
            heading1Style.Font.Name           = "Century Gothic";
            heading1Style.Font.Bold           = false;
            heading1Style.Font.Size           = 16;
            heading1Style.Font.Color          = Color.FromRGB(64, 64, 64);
            heading1Style.IncludeBorder       = false;
            heading1Style.IncludePatterns     = true;
            heading1Style.Interior.Color      = Color.FromRGB(243, 243, 236);

            IStyle heading2Style = workbook.Styles["Heading 2"];

            heading2Style.IncludeNumber       = true;
            heading2Style.NumberFormat        = "$#,##0";
            heading2Style.IncludeAlignment    = true;
            heading2Style.HorizontalAlignment = HorizontalAlignment.Right;
            heading2Style.IndentLevel         = 2;
            heading2Style.VerticalAlignment   = VerticalAlignment.Center;
            heading2Style.Font.Name           = "Century Gothic";
            heading2Style.Font.Size           = 16;
            heading2Style.Font.Color          = Color.FromRGB(64, 64, 64);
            heading2Style.IncludeBorder       = false;
            heading2Style.IncludePatterns     = true;
            heading2Style.Interior.Color      = Color.FromRGB(243, 243, 236);

            IStyle heading3Style = workbook.Styles["Heading 3"];

            heading3Style.IncludeAlignment    = true;
            heading3Style.HorizontalAlignment = HorizontalAlignment.Left;
            heading3Style.VerticalAlignment   = VerticalAlignment.Bottom;
            heading3Style.IncludeBorder       = false;
            heading3Style.Font.Name           = "Century Gothic";
            heading3Style.Font.Bold           = false;
            heading3Style.Font.Size           = 27;
            heading3Style.Font.Color          = Color.FromRGB(64, 64, 64);
            heading3Style.IncludePatterns     = true;
            heading3Style.Interior.Color      = Color.FromRGB(243, 243, 236);

            IStyle heading4Style = workbook.Styles["Heading 4"];

            heading4Style.Font.Name  = "Century Gothic";
            heading4Style.Font.Size  = 16;
            heading4Style.Font.Color = Color.White;
            heading4Style.Font.Bold  = false;

            IStyle currencyStyle = workbook.Styles["Currency"];

            currencyStyle.NumberFormat        = "$#,##0";
            currencyStyle.IncludeAlignment    = true;
            currencyStyle.HorizontalAlignment = HorizontalAlignment.Right;
            currencyStyle.IndentLevel         = 1;
            currencyStyle.VerticalAlignment   = VerticalAlignment.Center;
            currencyStyle.IncludeFont         = true;
            currencyStyle.Font.Bold           = true;
            currencyStyle.Font.Name           = "Century Gothic";
            currencyStyle.Font.Size           = 12;


            //----------------------------------Use Style---------------------------
            assetsTable.TableStyle = assetsTableStyle;
            debtsTable.TableStyle  = debtsTableStyle;

            worksheet.SheetView.DisplayGridlines  = false;
            worksheet.Range["B2:B4"].Style        = heading1Style;
            worksheet.Range["C2:C4"].Style        = heading2Style;
            worksheet.Range["B9:D9"].Style        = heading4Style;
            worksheet.Range["D10:D30"].Style      = currencyStyle;
            worksheet.Range["D10:D30"].Font.Color = Color.FromRGB(61, 125, 137);

            worksheet.Range["B34:C34"].Style      = heading4Style;
            worksheet.Range["C35:C44"].Style      = currencyStyle;
            worksheet.Range["C35:C44"].Font.Color = Color.FromRGB(218, 113, 18);
            worksheet.Range["B1"].Style           = titleStyle;
            worksheet.Range["B8"].Style           = heading3Style;
            worksheet.Range["B33"].Style          = heading3Style;

            worksheet.Range["B3:C3"].Borders[BordersIndex.EdgeTop].LineStyle    = BorderLineStyle.Hair;
            worksheet.Range["B3:C3"].Borders[BordersIndex.EdgeTop].Color        = Color.FromRGB(128, 128, 128);
            worksheet.Range["B3:C3"].Borders[BordersIndex.EdgeBottom].LineStyle = BorderLineStyle.Hair;
            worksheet.Range["B3:C3"].Borders[BordersIndex.EdgeBottom].Color     = Color.FromRGB(128, 128, 128);


            //--------------------------------Add Shape--------------------------------
            IShape recShape1 = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, 17.81, 282.75, 20.963, 21.75);

            recShape1.Line.Color.ColorType = SolidColorType.None;
            recShape1.Fill.Color.RGB       = Color.FromRGB(60, 126, 138);
            IShape recShape2 = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, 17.81, 312.75, 20.963, 21.75);

            recShape2.Line.Color.ColorType = SolidColorType.None;
            recShape2.Fill.Color.RGB       = Color.FromRGB(218, 118, 13);
            IShape recShape3 = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, 17.81, 342.75, 20.963, 21.75);

            recShape3.Line.Color.ColorType = SolidColorType.None;
            recShape3.Fill.Color.RGB       = Color.FromRGB(84, 138, 57);

            IShape pieShape = worksheet.Shapes.AddChart(ChartType.Pie, 442.5, 26.25, 346, 350.25);

            pieShape.Chart.HasLegend = false;
            pieShape.Chart.HasTitle  = false;
            pieShape.Chart.ChartGroups[0].FirstSliceAngle = 180;
            pieShape.Placement = Placement.Move;

            IChartArea chartArea = pieShape.Chart.ChartArea;

            chartArea.Format.Fill.Transparency = 1;
            chartArea.Format.Line.Transparency = 1;

            ISeries chartSeries = pieShape.Chart.SeriesCollection.NewSeries();

            chartSeries.Formula = "=SERIES('Sheet1'!$B$2:$B$4,,'Sheet1'!$C$2:$C$4,1)";

            chartSeries.HasDataLabels             = true;
            chartSeries.DataLabels.Font.Name      = "Century Gothic";
            chartSeries.DataLabels.Font.Size      = 20;
            chartSeries.DataLabels.Font.Bold      = true;
            chartSeries.DataLabels.Font.Color.RGB = Color.White;
            chartSeries.DataLabels.ShowValue      = false;
            chartSeries.DataLabels.ShowPercentage = true;
            chartSeries.DataLabels.Position       = DataLabelPosition.Center;

            chartSeries.Points[0].Format.Fill.Color.RGB = Color.FromRGB(60, 126, 138);
            chartSeries.Points[1].Format.Fill.Color.RGB = Color.FromRGB(218, 118, 13);
            chartSeries.Points[2].Format.Fill.Color.RGB = Color.FromRGB(84, 138, 57);
            chartSeries.Explosion = 1;
        }
示例#54
0
 internal SeriesTreeItem(ISeries series, IStudyTreeItem parent)
 {
     _series      = series;
     _parentStudy = parent;
 }
示例#55
0
 public Indicators.FastPivotFinder FastPivotFinder(ISeries <double> input, bool plotCount, bool colorBars, int minBarsToLastSwing, double swingPct, int minPlotCount)
 {
     return(indicator.FastPivotFinder(input, plotCount, colorBars, minBarsToLastSwing, swingPct, minPlotCount));
 }
 protected override void StartCalc()
 {
     SX_Condition =
         new Lambda <Boolean>(
             _bb => PublicFunctions.DoubleGreater(Bars.Close[_bb], Bars.Open[_bb]));
 }
示例#57
0
 public Indicators.FisherTransform FisherTransform(ISeries <double> input, int period)
 {
     return(indicator.FisherTransform(input, period));
 }
示例#58
0
 public Indicators.GIRocHedger GIRocHedger(ISeries <double> input, int period)
 {
     return(indicator.GIRocHedger(input, period));
 }
 public Indicators.TextConstant TextConstant(ISeries <double> input, string line1, string line2, string line3, string line4)
 {
     return(indicator.TextConstant(input, line1, line2, line3, line4));
 }
        public override void Execute(GrapeCity.Documents.Excel.Workbook workbook)
        {
            object[,] data = new object[, ] {
                { null, "[Segment Name]", "[Segment Name]", "[Segment Name]", "Overall" },
                { "Customer Activity:", null, null, null, null },
                { "Number of active customers—Beginning of period", 5, 8, 8, null },
                { "Number of customers added", 2, 4, 4, null },
                { "Number of customers lost/terminated", -1, -2, -2, null },
                { "Number of active customers—End of period", null, null, null, null },
                { null, null, null, null, null },
                { "Profitability Analysis:", null, null, null, null },
                { "Revenue per segment", 1500000, 1800000, 2500000, null },
                { "Weighting", null, null, null, null },
                { null, null, null, null, null },
                { "Cost of sales:", null, null, null, null },
                { "Ongoing service and support costs", 1000000, 1400000, 1400000, null },
                { "Other direct customer costs", 200000, 100000, 100000, null },
                { "Total cost of sales", null, null, null, null },
                { "Gross margin", null, null, null, null },
                { "Weighting", null, null, null, null },
                { null, null, null, null, null },
                { "Other costs:", null, null, null, null },
                { "Customer acquisition", 105000, 120000, 235000, null },
                { "Customer marketing", 150000, 125000, 275000, null },
                { "Customer termination", 80000, 190000, 140000, null },
                { "Total other customer costs", null, null, null, null },
                { "Customer profit by segment", null, null, null, null },
                { "Weighting", null, null, null, null },
                { null, null, null, null, null },
                { "Summary Metrics:", "[Segment Name]", "[Segment Name]", "[Segment Name]", "Trend" },
                { "Average cost per acquired customer", null, null, null, null },
                { "Average cost per terminated customer", null, null, null, null },
                { "Average marketing cost per active customer", null, null, null, null },
                { "Average profit (loss) per customer", null, null, null, null },
            };

            IWorksheet worksheet = workbook.Worksheets[0];

            worksheet.Name     = "Customer Profitability";
            worksheet.TabColor = Color.FromRGB(131, 172, 121);
            worksheet.SheetView.DisplayGridlines = false;

            //Set Value.
            worksheet.Range["B2"].Value     = "[Company Name]";
            worksheet.Range["B3"].Value     = "Customer Profitability Analysis";
            worksheet.Range["B4"].Value     = "[Date]";
            worksheet.Range["B6"].Value     = "Gray cells will be calculated for you. You do not need to enter anything into them.";
            worksheet.Range["B7:F37"].Value = data;

            //Set formula.
            worksheet.Range["F9:F11"].Formula  = "=SUM(C9:E9)";
            worksheet.Range["C12:F12"].Formula = "=SUM(C9:C11)";

            worksheet.Range["C16:E16"].Formula = "=+C15/$F$15";
            worksheet.Range["F15:F16"].Formula = "=SUM(C15:E15)";

            worksheet.Range["F19:F20"].Formula = "=SUM(C19:E19)";
            worksheet.Range["C21:F21"].Formula = "=SUM(C19:C20)";
            worksheet.Range["C22:F22"].Formula = "=+C15-C21";
            worksheet.Range["C23:E23"].Formula = "=MAX(0, MIN(1,C22/$F$22))";
            worksheet.Range["F23"].Formula     = "=SUM(C23:E23)";

            worksheet.Range["F26:F28"].Formula = "=SUM(C26:E26)";
            worksheet.Range["C29:F29"].Formula = "=SUM(C26:C28)";
            worksheet.Range["C30:E30"].Formula = "=+C22-C29";
            worksheet.Range["C31:E31"].Formula = "=MAX(0,MIN(1, C30/$F$30))";
            worksheet.Range["F30:F31"].Formula = "=SUM(C30:E30)";

            worksheet.Range["C34:E34"].Formula = "=+C26/C10";
            worksheet.Range["C35:E35"].Formula = "=-C28/C11";
            worksheet.Range["C36:E36"].Formula = "=+C27/C12";
            worksheet.Range["C37:E37"].Formula = "=+C30/C12";

            //Change the range's RowHeight and ColumnWidth.
            worksheet.StandardHeight     = 15;
            worksheet.StandardWidth      = 9.140625;
            worksheet.Rows[0].RowHeight  = 9.95;
            worksheet.Rows[1].RowHeight  = 33;
            worksheet.Rows[2].RowHeight  = 27;
            worksheet.Rows[3].RowHeight  = 19.5;
            worksheet.Rows[4].RowHeight  = 9;
            worksheet.Rows[5].RowHeight  = 19.5;
            worksheet.Rows[6].RowHeight  = 18;
            worksheet.Rows[12].RowHeight = 9;
            worksheet.Rows[16].RowHeight = 9;
            worksheet.Rows[23].RowHeight = 9;
            worksheet.Rows[31].RowHeight = 9;

            worksheet.Columns[0].ColumnWidth = 1.85546875;
            worksheet.Columns[1].ColumnWidth = 46.7109375;
            worksheet.Columns[2].ColumnWidth = 16.42578125;
            worksheet.Columns[3].ColumnWidth = 16.42578125;
            worksheet.Columns[4].ColumnWidth = 16.42578125;
            worksheet.Columns[5].ColumnWidth = 16.42578125;

            //Modify the build in name styles.
            var nameStyle_Normal = workbook.Styles["Normal"];

            nameStyle_Normal.VerticalAlignment = VerticalAlignment.Center;
            nameStyle_Normal.Font.ThemeColor   = ThemeColor.Dark1;
            nameStyle_Normal.Font.TintAndShade = 0.249946592608417;
            nameStyle_Normal.Font.Size         = 10;

            var nameStyle_Heading_1 = workbook.Styles["Heading 1"];

            nameStyle_Heading_1.HorizontalAlignment = HorizontalAlignment.Left;
            nameStyle_Heading_1.VerticalAlignment   = VerticalAlignment.Center;
            nameStyle_Heading_1.Font.ThemeFont      = ThemeFont.Major;
            nameStyle_Heading_1.Font.Bold           = false;
            nameStyle_Heading_1.Font.Size           = 24;
            nameStyle_Heading_1.Font.ThemeColor     = ThemeColor.Dark1;
            nameStyle_Heading_1.Font.TintAndShade   = 0.249946592608417;
            nameStyle_Heading_1.Borders[BordersIndex.EdgeBottom].LineStyle = BorderLineStyle.None;
            nameStyle_Heading_1.IncludeAlignment = true;

            var nameStyle_Heading_2 = workbook.Styles["Heading 2"];

            nameStyle_Heading_2.HorizontalAlignment = HorizontalAlignment.Left;
            nameStyle_Heading_2.VerticalAlignment   = VerticalAlignment.Center;
            nameStyle_Heading_2.Font.ThemeFont      = ThemeFont.Major;
            nameStyle_Heading_2.Font.Bold           = false;
            nameStyle_Heading_2.Font.Size           = 20;
            nameStyle_Heading_2.Font.ThemeColor     = ThemeColor.Dark1;
            nameStyle_Heading_2.Font.TintAndShade   = 0.249946592608417;
            nameStyle_Heading_2.Borders[BordersIndex.EdgeBottom].LineStyle = BorderLineStyle.None;
            nameStyle_Heading_2.Interior.ThemeColor   = ThemeColor.Accent3;
            nameStyle_Heading_2.Interior.TintAndShade = 0.39994506668294322;
            nameStyle_Heading_2.IncludeNumber         = true;
            nameStyle_Heading_2.IncludePatterns       = true;

            var nameStyle_Heading_3 = workbook.Styles["Heading 3"];

            nameStyle_Heading_3.HorizontalAlignment = HorizontalAlignment.Left;
            nameStyle_Heading_3.VerticalAlignment   = VerticalAlignment.Center;
            nameStyle_Heading_3.Font.ThemeFont      = ThemeFont.Major;
            nameStyle_Heading_3.Font.Bold           = false;
            nameStyle_Heading_3.Font.Size           = 14;
            nameStyle_Heading_3.Font.ThemeColor     = ThemeColor.Dark1;
            nameStyle_Heading_3.Font.TintAndShade   = 0.249946592608417;
            nameStyle_Heading_3.Borders[BordersIndex.EdgeBottom].LineStyle = BorderLineStyle.None;
            nameStyle_Heading_3.IncludeAlignment = true;
            nameStyle_Heading_3.IncludePatterns  = true;

            var nameStyle_Heading_4 = workbook.Styles["Heading 4"];

            nameStyle_Heading_4.HorizontalAlignment = HorizontalAlignment.Left;
            nameStyle_Heading_4.VerticalAlignment   = VerticalAlignment.Center;
            nameStyle_Heading_4.Font.ThemeFont      = ThemeFont.Major;
            nameStyle_Heading_4.Font.Bold           = true;
            nameStyle_Heading_4.Font.Size           = 10;
            nameStyle_Heading_4.Font.ThemeColor     = ThemeColor.Light1;
            nameStyle_Heading_4.Font.TintAndShade   = -0.0499893185216834;
            nameStyle_Heading_4.Borders[BordersIndex.EdgeBottom].LineStyle = BorderLineStyle.None;
            nameStyle_Heading_4.Interior.ThemeColor   = ThemeColor.Accent3;
            nameStyle_Heading_4.Interior.TintAndShade = -0.249946592608417;
            nameStyle_Heading_4.IncludeAlignment      = true;
            nameStyle_Heading_4.IncludeBorder         = true;
            nameStyle_Heading_4.IncludePatterns       = true;

            //Apply the above name styles on ranges.
            worksheet.Range["B2:F2"].Style   = workbook.Styles["Heading 1"];
            worksheet.Range["B3:F3"].Style   = workbook.Styles["Heading 2"];
            worksheet.Range["B4:F4"].Style   = workbook.Styles["Heading 3"];
            worksheet.Range["B8:F8"].Style   = workbook.Styles["Heading 4"];
            worksheet.Range["B14:F14"].Style = workbook.Styles["Heading 4"];
            worksheet.Range["B18:F18"].Style = workbook.Styles["Heading 4"];
            worksheet.Range["B25:F25"].Style = workbook.Styles["Heading 4"];
            worksheet.Range["B33:F33"].Style = workbook.Styles["Heading 4"];

            //Set NumberFormat.
            worksheet.Range["C9:F12"].NumberFormat  = "0_);[Red](0)";
            worksheet.Range["C15:F15"].NumberFormat = "\"$\"#,##0.00_);[Red](\"$\"#,##0.00)";
            worksheet.Range["C16:F16"].NumberFormat = "0%";
            worksheet.Range["C19:F22"].NumberFormat = "\"$\"#,##0.00_);[Red](\"$\"#,##0.00)";
            worksheet.Range["C23:F23"].NumberFormat = "0%";
            worksheet.Range["C26:F30"].NumberFormat = "\"$\"#,##0.00_);[Red](\"$\"#,##0.00)";
            worksheet.Range["C31:F31"].NumberFormat = "0%";
            worksheet.Range["C34:F37"].NumberFormat = "\"$\"#,##0.00_);[Red](\"$\"#,##0.00)";

            //Set range's font style.
            worksheet.Range["B6"].Font.TintAndShade      = 0.34998626667073579;
            worksheet.Range["B6"].Font.Size              = 8;
            worksheet.Range["B6"].Font.Italic            = true;
            worksheet.Range["C7:F7"].Font.TintAndShade   = 0;
            worksheet.Range["B9:F12"].Font.TintAndShade  = 0;
            worksheet.Range["B15:F16"].Font.TintAndShade = 0;
            worksheet.Range["B19:F23"].Font.TintAndShade = 0;
            worksheet.Range["B26:F31"].Font.TintAndShade = 0;
            worksheet.Range["B34:F37"].Font.TintAndShade = 0;
            worksheet.Range["C33:F33"].Font.Bold         = false;

            //Set range's alignment.
            worksheet.Range["C7:F7"].HorizontalAlignment   = HorizontalAlignment.Center;
            worksheet.Range["C33:F33"].HorizontalAlignment = HorizontalAlignment.Center;

            //Set range's border
            worksheet.Range["B9:F12"].Borders.LineStyle    = BorderLineStyle.Thin;
            worksheet.Range["B9:F12"].Borders.ThemeColor   = ThemeColor.Accent3;
            worksheet.Range["B9:F12"].Borders.TintAndShade = 0.39994506668294322;

            worksheet.Range["B15:F16"].Borders.LineStyle    = BorderLineStyle.Thin;
            worksheet.Range["B15:F16"].Borders.ThemeColor   = ThemeColor.Accent3;
            worksheet.Range["B15:F16"].Borders.TintAndShade = 0.39994506668294322;

            worksheet.Range["B19:F23"].Borders.LineStyle    = BorderLineStyle.Thin;
            worksheet.Range["B19:F23"].Borders.ThemeColor   = ThemeColor.Accent3;
            worksheet.Range["B19:F23"].Borders.TintAndShade = 0.39994506668294322;

            worksheet.Range["B26:F31"].Borders.LineStyle    = BorderLineStyle.Thin;
            worksheet.Range["B26:F31"].Borders.ThemeColor   = ThemeColor.Accent3;
            worksheet.Range["B26:F31"].Borders.TintAndShade = 0.39994506668294322;

            worksheet.Range["B34:F37"].Borders.LineStyle    = BorderLineStyle.Thin;
            worksheet.Range["B34:F37"].Borders.ThemeColor   = ThemeColor.Accent3;
            worksheet.Range["B34:F37"].Borders.TintAndShade = 0.39994506668294322;

            //Set range's fill.
            worksheet.Range["F9:F12"].Interior.ThemeColor    = ThemeColor.Light1;
            worksheet.Range["F9:F12"].Interior.TintAndShade  = -0.0499893185216834;
            worksheet.Range["C12:E12"].Interior.ThemeColor   = ThemeColor.Light1;
            worksheet.Range["C12:E12"].Interior.TintAndShade = -0.0499893185216834;
            worksheet.Range["F15:F16"].Interior.ThemeColor   = ThemeColor.Light1;
            worksheet.Range["F15:F16"].Interior.TintAndShade = -0.0499893185216834;
            worksheet.Range["C16:E16"].Interior.ThemeColor   = ThemeColor.Light1;
            worksheet.Range["C16:E16"].Interior.TintAndShade = -0.0499893185216834;
            worksheet.Range["F19:F23"].Interior.ThemeColor   = ThemeColor.Light1;
            worksheet.Range["F19:F23"].Interior.TintAndShade = -0.0499893185216834;
            worksheet.Range["C21:E23"].Interior.ThemeColor   = ThemeColor.Light1;
            worksheet.Range["C21:E23"].Interior.TintAndShade = -0.0499893185216834;
            worksheet.Range["F26:F31"].Interior.ThemeColor   = ThemeColor.Light1;
            worksheet.Range["F26:F31"].Interior.TintAndShade = -0.0499893185216834;
            worksheet.Range["C29:E31"].Interior.ThemeColor   = ThemeColor.Light1;
            worksheet.Range["C29:E31"].Interior.TintAndShade = -0.0499893185216834;
            worksheet.Range["C34:E37"].Interior.ThemeColor   = ThemeColor.Light1;
            worksheet.Range["C34:E37"].Interior.TintAndShade = -0.0499893185216834;

            //create a new group of sparklines.
            ISparklineGroup sparklineGroup = worksheet.Range["F34:F37"].SparklineGroups.Add(SparkType.Line, "C34:E37");

            sparklineGroup.SeriesColor.ThemeColor               = ThemeColor.Accent3;
            sparklineGroup.SeriesColor.TintAndShade             = -0.249977111117893;
            sparklineGroup.Points.Negative.Color.ThemeColor     = ThemeColor.Accent4;
            sparklineGroup.Points.Markers.Color.ThemeColor      = ThemeColor.Accent4;
            sparklineGroup.Points.Markers.Color.TintAndShade    = -0.249977111117893;
            sparklineGroup.Points.Highpoint.Color.ThemeColor    = ThemeColor.Accent4;
            sparklineGroup.Points.Highpoint.Color.TintAndShade  = -0.249977111117893;
            sparklineGroup.Points.Lowpoint.Color.ThemeColor     = ThemeColor.Accent4;
            sparklineGroup.Points.Lowpoint.Color.TintAndShade   = -0.249977111117893;
            sparklineGroup.Points.Firstpoint.Color.ThemeColor   = ThemeColor.Accent4;
            sparklineGroup.Points.Firstpoint.Color.TintAndShade = -0.249977111117893;
            sparklineGroup.Points.Lastpoint.Color.ThemeColor    = ThemeColor.Accent4;
            sparklineGroup.Points.Lastpoint.Color.TintAndShade  = -0.249977111117893;
            sparklineGroup.Points.Negative.Visible              = false;
            sparklineGroup.Points.Firstpoint.Visible            = false;
            sparklineGroup.Points.Lastpoint.Visible             = false;

            //Add chart.
            IShape shape = worksheet.Shapes.AddChart(ChartType.ColumnClustered, 9.75, 576.95, 590.25, 237);

            shape.Name = "Chart 3";

            //Add Series.
            ISeries series1 = shape.Chart.SeriesCollection.NewSeries();

            series1.Formula = "=SERIES('Customer Profitability'!$B$34,'Customer Profitability'!$C$33:$E$33,'Customer Profitability'!$C$34:$E$34,1)";
            series1.Format.Fill.Color.ObjectThemeColor = ThemeColor.Accent2;

            ISeries series2 = shape.Chart.SeriesCollection.NewSeries();

            series2.Formula = "=SERIES('Customer Profitability'!$B$35,'Customer Profitability'!$C$33:$E$33,'Customer Profitability'!$C$35:$E$35,2)";
            series2.Format.Fill.Color.ObjectThemeColor = ThemeColor.Accent4;

            ISeries series3 = shape.Chart.SeriesCollection.NewSeries();

            series3.Formula = "=SERIES('Customer Profitability'!$B$36,'Customer Profitability'!$C$33:$E$33,'Customer Profitability'!$C$36:$E$36,3)";
            series3.Format.Fill.Color.ObjectThemeColor = ThemeColor.Accent3;

            ISeries series4 = shape.Chart.SeriesCollection.NewSeries();

            series4.Formula = "=SERIES('Customer Profitability'!$B$37,'Customer Profitability'!$C$33:$E$33,'Customer Profitability'!$C$37:$E$37,4)";
            series4.Format.Fill.Color.ObjectThemeColor = ThemeColor.Accent5;

            //Set the char group's Overlap and GapWidth.
            shape.Chart.ColumnGroups[0].Overlap  = 0;
            shape.Chart.ColumnGroups[0].GapWidth = 199;

            //Set the chart's title format.
            var chartTitle = shape.Chart.ChartTitle;

            chartTitle.Text           = "Summary Metrics per Customer Segment";
            chartTitle.Font.ThemeFont = ThemeFont.Major;
            chartTitle.Font.Color.ObjectThemeColor = ThemeColor.Dark1;
            chartTitle.Font.Size = 20;

            //Set the chart legend's position.
            shape.Chart.Legend.Position = LegendPosition.Top;

            //Set category axis format.
            IAxis category_axis = shape.Chart.Axes.Item(AxisType.Category);

            category_axis.HasTitle                 = true;
            category_axis.AxisTitle.Text           = "SEGMENT";
            category_axis.AxisTitle.Font.Size      = 9;
            category_axis.AxisTitle.Font.ThemeFont = ThemeFont.Minor;

            //Set value axis format.
            IAxis value_axis = shape.Chart.Axes.Item(AxisType.Value);

            value_axis.CrossesAt         = -200000;
            value_axis.HasMinorGridlines = true;
            value_axis.MinorGridlines.Format.Line.Color.ObjectThemeColor = ThemeColor.Dark1;
            value_axis.MinorGridlines.Format.Line.Color.Brightness       = 0.95;

            //Create customize theme.
            Themes themes = new Themes();
            ITheme theme  = themes.Add("test");

            theme.ThemeColorScheme[ThemeColor.Dark1].RGB              = Color.FromRGB(0, 0, 0);
            theme.ThemeColorScheme[ThemeColor.Light1].RGB             = Color.FromRGB(255, 255, 255);
            theme.ThemeColorScheme[ThemeColor.Dark2].RGB              = Color.FromRGB(77, 70, 70);
            theme.ThemeColorScheme[ThemeColor.Light2].RGB             = Color.FromRGB(255, 251, 239);
            theme.ThemeColorScheme[ThemeColor.Accent1].RGB            = Color.FromRGB(255, 225, 132);
            theme.ThemeColorScheme[ThemeColor.Accent2].RGB            = Color.FromRGB(102, 173, 166);
            theme.ThemeColorScheme[ThemeColor.Accent3].RGB            = Color.FromRGB(131, 172, 121);
            theme.ThemeColorScheme[ThemeColor.Accent4].RGB            = Color.FromRGB(254, 191, 102);
            theme.ThemeColorScheme[ThemeColor.Accent5].RGB            = Color.FromRGB(219, 112, 87);
            theme.ThemeColorScheme[ThemeColor.Accent6].RGB            = Color.FromRGB(165, 115, 137);
            theme.ThemeColorScheme[ThemeColor.Hyperlink].RGB          = Color.FromRGB(102, 173, 166);
            theme.ThemeColorScheme[ThemeColor.FollowedHyperlink].RGB  = Color.FromRGB(165, 115, 137);
            theme.ThemeFontScheme.Major[FontLanguageIndex.Latin].Name = "Marion";
            theme.ThemeFontScheme.Minor[FontLanguageIndex.Latin].Name = "Marion";

            //Apply the above custom theme.
            workbook.Theme = theme;

            //Set active cell.
            worksheet.Range["B7"].Activate();
        }