Build 4.0.0.85 of xlsgen makes it possible to add more than one trendline to a series of data. Before this build, for 3 series of data there could be at most 3 trendlines attached to them, so up to 6 lines in total.
One series of data and 4 trendlines attached to it (moving averages with different parameters)This works for XLS and XLSX/XLSB files.
And here is how to code it :
xlsgen::IXlsWorkbookPtr wbk = engine->Open( L"input\\EURUSD1.csv", L"multiple_trendlines.xlsx" );
xlsgen::IXlsChartPtr chart = wbk->WorksheetByIndex[1]->NewChart(xlsgen::charttype_line2D,
1, //row1
2, //col1
28, //row2
15 //col2
);
xlsgen::IXlsChartDynamicDataSourcePtr datasource001s0 = chart->DynamicDataSource;
xlsgen::IXlsChartDynamicDataSourceSeriesPtr serie001s0ss0 = datasource001s0->AddSerie();
serie001s0ss0->SeriesValuesFormula = L"=R1C3:R100C3";
chart->SeriesByIndex[1]->TrendLines[1]->Show = xlsgen::charttrendline_movingaverage;
chart->SeriesByIndex[1]->TrendLines[1]->MovingAveragePeriods = 5;
chart->SeriesByIndex[1]->TrendLines[1]->Options->Type = xlsgen::chartbordertype_custom;
chart->SeriesByIndex[1]->TrendLines[1]->Options->Color = 0x4040C0;
chart->SeriesByIndex[1]->TrendLines[2]->Show = xlsgen::charttrendline_movingaverage;
chart->SeriesByIndex[1]->TrendLines[2]->MovingAveragePeriods = 10;
chart->SeriesByIndex[1]->TrendLines[2]->Options->Type = xlsgen::chartbordertype_custom;
chart->SeriesByIndex[1]->TrendLines[2]->Options->Color = 0xC04040;
chart->SeriesByIndex[1]->TrendLines[3]->Show = xlsgen::charttrendline_movingaverage;
chart->SeriesByIndex[1]->TrendLines[3]->MovingAveragePeriods = 20;
chart->SeriesByIndex[1]->TrendLines[3]->Options->Type = xlsgen::chartbordertype_custom;
chart->SeriesByIndex[1]->TrendLines[3]->Options->Color = 0x40C040;
chart->SeriesByIndex[1]->TrendLines[4]->Show = xlsgen::charttrendline_movingaverage;
chart->SeriesByIndex[1]->TrendLines[4]->MovingAveragePeriods = 40;
chart->SeriesByIndex[1]->TrendLines[4]->Options->Type = xlsgen::chartbordertype_custom;
chart->SeriesByIndex[1]->TrendLines[4]->Options->Color = 0xA040A0;
chart->XAxis[xlsgen::chartaxis_primary]->Scale->ItemsBetweenTickMarkLabels = 10;
wbk->Close();