The ChartTemplates collection and ChartTemplate objects allow you to programmatically save, manage and apply chart templates, without having to deal with manual configurations. This functionality is useful for:
Traders who want algorithms to configure and handle consistent chart layouts, smooth template switching, setup capturing and storage, monitoring and more.
Developers who need repeatable chart environments for advanced analysis, monitoring, debugging or deployment of helper indicators and cBots across many charts.
Core concepts
A single ChartTemplate exposes:
template.Apply(Chart) to apply a template to a target chart.
template.Indicators to add or remove indicators, access their parameters.
template.Robots to add or remove cBots.
template.ColorSettings to work with chart or theme colours
template.DisplaySettings to work with chart type, zoom and various toggles, including positions, orders, grid, sentiment and more.
The ChartTemplates object, a built-in collection, provides:
foreach (var t in ChartTemplates) ... for enumeratation.
ChartTemplates.Get(name), ChartTemplates.Contains(name) for querying.
ChartTemplates.Create(name) for creating empty templates.
ChartTemplates.Create(name, Chart) for capturing the current chart configuration.
ChartTemplates.Duplicate(newName, sourceTemplate) for duplicating templates.
ChartTemplates.Remove(template) for removing templates.
ChartTemplates.DefaultTemplate for applying the default template (get or set).
It also exposes events:
ChartTemplates.Added += ...
ChartTemplates.Removed += ...
The table below provides a summary of standard operations.
Operation
Examples
Template lifecycle
Create an empty template Create a template from the current chart Duplicate a template Remove a template
Template discovery
List templates and show data Check if a template exists React to a template being added or removed
Applying templates
Apply a template to a chart Change default template
Template composition
Add or remove an indicator Modify the parameters of an indicator Add or remove a cBot
Layout and visualisation settings
Set the chart colours Enable or disable the chart display options Change the chart type Adjust the zoom level
Consider a Chart Templates Manager cBot, which when added and started on a chart, displays a menu for performing various tasks with chart templates.
usingSystem;usingcAlgo.API;usingcAlgo.API.Collections;usingcAlgo.API.Indicators;usingcAlgo.API.Internals;usingSystem.Linq;namespacecAlgo.Robots{[Robot(AccessRights = AccessRights.None, AddIndicators = true)]publicclassChartTemplatesManager:Robot{protectedoverridevoidOnStart(){vartemplatesComboBox=newComboBox();templatesComboBox.AddItem("Click to view available templates");templatesComboBox.SelectedItem="Click to view available templates";foreach(vartemplateinChartTemplates){templatesComboBox.AddItem(template.Name);}ChartTemplates.Added+=args=>{templatesComboBox.AddItem(args.ChartTemplate.Name);Print($"A new template was added: {args.ChartTemplate.Name}");};ChartTemplates.Removed+=args=>{templatesComboBox.RemoveItem(args.ChartTemplate.Name);Print($"A template was removed: {args.ChartTemplate.Name}");};varshowTemplateInfoButton=newButton{Text="Show the template information"};showTemplateInfoButton.Click+=args=>{if(string.IsNullOrWhiteSpace(templatesComboBox.SelectedItem)){Print("No template is selected.");return;}vartemplate=ChartTemplates.Get(templatesComboBox.SelectedItem);Print($"Name: {template.Name} | Bots #: {template.Robots.Count} | Indicators #: {template.Indicators.Count}");};varshowDefaultTemplateInfoButton=newButton{Text="Show the default template information"};showDefaultTemplateInfoButton.Click+=args=>{Print($"Name: {ChartTemplates.DefaultTemplate.Name} | Bots #: {ChartTemplates.DefaultTemplate.Robots.Count} | Indicators #: {ChartTemplates.DefaultTemplate.Indicators.Count}");};varremoveTemplateButton=newButton{Text="Remove the selected template"};removeTemplateButton.Click+=_=>ChartTemplates.Remove(ChartTemplates.Get(templatesComboBox.SelectedItem));varapplyTemplateButton=newButton{Text="Apply the selected template"};applyTemplateButton.Click+=_=>ChartTemplates.Get(templatesComboBox.SelectedItem).Apply(Chart);varduplicateTemplateButton=newButton{Text="Duplicate the selected template"};duplicateTemplateButton.Click+=_=>ChartTemplates.Duplicate($"{templatesComboBox.SelectedItem} Duplicate",ChartTemplates.Get(templatesComboBox.SelectedItem));varcreateTemplateTextBox=newTextBox{Text="Click to type in a template name"};varcreateEmptyTemplateButton=newButton{Text="Create an empty template"};createEmptyTemplateButton.Click+=_=>ChartTemplates.Create(createTemplateTextBox.Text);varcreateTemplateBasedOnChartButton=newButton{Text="Create a template from the current chart"};createTemplateBasedOnChartButton.Click+=_=>ChartTemplates.Create(createTemplateTextBox.Text,Chart);varchangeDefaultTemplateToSelectedButton=newButton{Text="Set the selected template as the default"};changeDefaultTemplateToSelectedButton.Click+=_=>ChartTemplates.DefaultTemplate=ChartTemplates.Get(templatesComboBox.SelectedItem);varcheckSelectedTemplateExistsButton=newButton{Text="Check whether the selected template exists"};checkSelectedTemplateExistsButton.Click+=_=>Print($"The template '{templatesComboBox.SelectedItem}' exists: {ChartTemplates.Contains(templatesComboBox.SelectedItem)}");varremoveSelectedTemplateIndicator=newButton{Text="Remove an indicator from the selected template"};removeSelectedTemplateIndicator.Click+=_=>{if(string.IsNullOrWhiteSpace(templatesComboBox.SelectedItem)){Print("No template is selected.");return;}vartemplate=ChartTemplates.Get(templatesComboBox.SelectedItem);if(template.Indicators.Count==0)return;Print($"Removal result: {template.Indicators.Remove(template.Indicators.First())}");};varremoveSelectedTemplateBot=newButton{Text="Remove a cBot from the selected template"};removeSelectedTemplateBot.Click+=_=>{if(string.IsNullOrWhiteSpace(templatesComboBox.SelectedItem)){Print("No template is selected.");return;}vartemplate=ChartTemplates.Get(templatesComboBox.SelectedItem);if(template.Robots.Count==0)return;Print($"Removal result: {template.Robots.Remove(template.Robots.First())}");};varindicatorsCombobox=newComboBox();indicatorsCombobox.AddItem("Click to select an indicator");indicatorsCombobox.SelectedItem="Click to select an indicator";foreach(varindicatorinAlgoRegistry.Indicators.OrderBy(i=>i.Name)){indicatorsCombobox.AddItem(indicator.Name);}varaddIndicatorWithDefaultParametersToSelectedTemplate=newButton{Text="Add the selected indicator to the selected template using default parameters"};addIndicatorWithDefaultParametersToSelectedTemplate.Click+=_=>{if(string.IsNullOrWhiteSpace(templatesComboBox.SelectedItem)){Print("No template is selected.");return;}vartemplate=ChartTemplates.Get(templatesComboBox.SelectedItem);if(string.IsNullOrWhiteSpace(indicatorsCombobox.SelectedItem)){Print("No indicator is selected.");return;}Print($"Added the indicator {indicatorsCombobox.SelectedItem}.");template.Indicators.Add(indicatorsCombobox.SelectedItem);};varrobotsCombobox=newComboBox();robotsCombobox.AddItem("Click to select a cBot");robotsCombobox.SelectedItem="Click to select a cBot";foreach(varrobotinAlgoRegistry.Robots.OrderBy(i=>i.Name)){robotsCombobox.AddItem(robot.Name);}varaddRobotWithDefaultParametersToSelectedTemplate=newButton{Text="Add the selected cBot to the selected template using default parameters"};addRobotWithDefaultParametersToSelectedTemplate.Click+=_=>{if(string.IsNullOrWhiteSpace(templatesComboBox.SelectedItem)){Print("No template is selected.");return;}vartemplate=ChartTemplates.Get(templatesComboBox.SelectedItem);if(string.IsNullOrWhiteSpace(robotsCombobox.SelectedItem)){Print("No cBot is selected.");return;}Print($"Added the cBot {robotsCombobox.SelectedItem}.");template.Robots.Add(robotsCombobox.SelectedItem);};varaddEmaIndicatorWithDifferentParametersToSelectedTemplate=newButton{Text="Add an EMA indicator to the selected template using custom parameters"};addEmaIndicatorWithDifferentParametersToSelectedTemplate.Click+=_=>{if(string.IsNullOrWhiteSpace(templatesComboBox.SelectedItem)){Print("No template is selected.");return;}vartemplate=ChartTemplates.Get(templatesComboBox.SelectedItem);varemaType=AlgoRegistry.Get("Exponential Moving Average",AlgoKind.StandardIndicator)asIndicatorType;Print($"Added the indicator {emaType.Name} with a period of 100.");template.Indicators.Add(emaType,Bars.OpenPrices,100);};varchangeEmaIndicatorParametersForSelectedTemplate=newButton{Text="Change the EMA indicator parameters in the selected template"};changeEmaIndicatorParametersForSelectedTemplate.Click+=_=>{if(string.IsNullOrWhiteSpace(templatesComboBox.SelectedItem)){Print("No template is selected.");return;}vartemplate=ChartTemplates.Get(templatesComboBox.SelectedItem);varemaType=AlgoRegistry.Get("Exponential Moving Average",AlgoKind.StandardIndicator)asIndicatorType;if(template.Indicators.FirstOrDefault(i=>i.Type==emaType)isnot{}templateIndicator){Print($"The EMA indicator was not found in the template '{template.Name}'.");return;}Print($"Changing the indicator {emaType.Name} period to 200.");templateIndicator.Parameters["Periods"].Value=200;};varsetAllColorSettingsToRedForSelectedTemplate=newButton{Text="Set all colour settings to red for the selected template"};setAllColorSettingsToRedForSelectedTemplate.Click+=_=>{if(string.IsNullOrWhiteSpace(templatesComboBox.SelectedItem)){Print("No template is selected.");return;}vartemplate=ChartTemplates.Get(templatesComboBox.SelectedItem);template.ColorSettings.AskPriceLineColor=Color.Red;template.ColorSettings.BidPriceLineColor=Color.Red;template.ColorSettings.BackgroundColor=Color.Red;template.ColorSettings.BearFillColor=Color.Red;template.ColorSettings.BearOutlineColor=Color.Red;template.ColorSettings.BullFillColor=Color.Red;template.ColorSettings.BullOutlineColor=Color.Red;template.ColorSettings.BuyColor=Color.Red;template.ColorSettings.ForegroundColor=Color.Red;template.ColorSettings.GridLinesColor=Color.Red;template.ColorSettings.LosingDealColor=Color.Red;template.ColorSettings.PeriodSeparatorColor=Color.Red;template.ColorSettings.SellColor=Color.Red;template.ColorSettings.TickVolumeColor=Color.Red;template.ColorSettings.WinningDealColor=Color.Red;template.ColorSettings.AreaFillColor=Color.Red;};varenableAllDisplayOptionsForSelectedTemplate=newButton{Text="Enable all display options for the selected template"};enableAllDisplayOptionsForSelectedTemplate.Click+=_=>{if(string.IsNullOrWhiteSpace(templatesComboBox.SelectedItem)){Print("No template is selected.");return;}vartemplate=ChartTemplates.Get(templatesComboBox.SelectedItem);template.DisplaySettings.AskPriceLine=true;template.DisplaySettings.Bars=true;template.DisplaySettings.BidPriceLine=true;template.DisplaySettings.ChartScale=true;template.DisplaySettings.DealMap=true;template.DisplaySettings.Grid=true;template.DisplaySettings.IndicatorTitles=true;template.DisplaySettings.MarketSentiment=true;template.DisplaySettings.Orders=true;template.DisplaySettings.PeriodSeparators=true;template.DisplaySettings.Positions=true;template.DisplaySettings.PriceAlerts=true;template.DisplaySettings.PriceAxisOverlayButtons=true;template.DisplaySettings.QuickTradeButtons=true;template.DisplaySettings.Targets=true;template.DisplaySettings.TickVolume=true;template.DisplaySettings.AddRobotButton=true;};vardisableAllDisplayOptionsForSelectedTemplate=newButton{Text="Disable all display options for the selected template"};disableAllDisplayOptionsForSelectedTemplate.Click+=_=>{if(string.IsNullOrWhiteSpace(templatesComboBox.SelectedItem)){Print("No template is selected.");return;}vartemplate=ChartTemplates.Get(templatesComboBox.SelectedItem);template.DisplaySettings.AskPriceLine=false;template.DisplaySettings.Bars=false;template.DisplaySettings.BidPriceLine=false;template.DisplaySettings.ChartScale=false;template.DisplaySettings.DealMap=false;template.DisplaySettings.Grid=false;template.DisplaySettings.IndicatorTitles=false;template.DisplaySettings.MarketSentiment=false;template.DisplaySettings.Orders=false;template.DisplaySettings.PeriodSeparators=false;template.DisplaySettings.Positions=false;template.DisplaySettings.PriceAlerts=false;template.DisplaySettings.PriceAxisOverlayButtons=false;template.DisplaySettings.QuickTradeButtons=false;template.DisplaySettings.Targets=false;template.DisplaySettings.TickVolume=false;template.DisplaySettings.AddRobotButton=false;};varchangeChartTypeForSelectedTemplate=newButton{Text="Change the chart type for the selected template"};changeChartTypeForSelectedTemplate.Click+=_=>{if(string.IsNullOrWhiteSpace(templatesComboBox.SelectedItem)){Print("No template is selected.");return;}vartemplate=ChartTemplates.Get(templatesComboBox.SelectedItem);template.DisplaySettings.ChartType=template.DisplaySettings.ChartTypeswitch{ChartType.Area=>ChartType.Bars,ChartType.Bars=>ChartType.Candlesticks,ChartType.Candlesticks=>ChartType.Dots,ChartType.Dots=>ChartType.Hlc,ChartType.Hlc=>ChartType.Line,_=>ChartType.Area};Print($"Changed the template '{template.Name}' chart type to '{template.DisplaySettings.ChartType}'.");};varchangeZoomeLevelForSelectedTemplate=newButton{Text="Change the zoom level for the selected template"};changeZoomeLevelForSelectedTemplate.Click+=_=>{if(string.IsNullOrWhiteSpace(templatesComboBox.SelectedItem)){Print("No template is selected.");return;}vartemplate=ChartTemplates.Get(templatesComboBox.SelectedItem);template.DisplaySettings.ZoomLevel=template.DisplaySettings.ZoomLevelswitch{5=>400,400=>5,_=>5};Print($"Changed the template '{template.Name}' zoom level to '{template.DisplaySettings.ZoomLevel}'.");};varpanel=newStackPanel{Orientation=Orientation.Vertical,HorizontalAlignment=HorizontalAlignment.Center,VerticalAlignment=VerticalAlignment.Center};panel.AddChild(templatesComboBox);panel.AddChild(showTemplateInfoButton);panel.AddChild(showDefaultTemplateInfoButton);panel.AddChild(removeTemplateButton);panel.AddChild(applyTemplateButton);panel.AddChild(duplicateTemplateButton);panel.AddChild(createTemplateTextBox);panel.AddChild(createEmptyTemplateButton);panel.AddChild(createTemplateBasedOnChartButton);panel.AddChild(changeDefaultTemplateToSelectedButton);panel.AddChild(checkSelectedTemplateExistsButton);panel.AddChild(removeSelectedTemplateIndicator);panel.AddChild(removeSelectedTemplateBot);panel.AddChild(indicatorsCombobox);panel.AddChild(addIndicatorWithDefaultParametersToSelectedTemplate);panel.AddChild(robotsCombobox);panel.AddChild(addRobotWithDefaultParametersToSelectedTemplate);panel.AddChild(addEmaIndicatorWithDifferentParametersToSelectedTemplate);panel.AddChild(changeEmaIndicatorParametersForSelectedTemplate);panel.AddChild(setAllColorSettingsToRedForSelectedTemplate);panel.AddChild(enableAllDisplayOptionsForSelectedTemplate);panel.AddChild(disableAllDisplayOptionsForSelectedTemplate);panel.AddChild(changeChartTypeForSelectedTemplate);panel.AddChild(changeZoomeLevelForSelectedTemplate);Chart.AddControl(panel);}}}
Practical applications
Capture the current setup
Develop algorithms that programmatically capture a chart's settings, including indicators, parameters, colours and others, and store them as a template. This allows you to automatically preserve a working setup during any phase of algo trading and apply it to any other charts.
This C# code demonstrates a cBot that captures and stores the template of a chart:
usingSystem;usingcAlgo.API;usingcAlgo.API.Collections;usingcAlgo.API.Indicators;usingcAlgo.API.Internals;usingSystem.Linq;namespacecAlgo.Robots{[Robot(AccessRights = AccessRights.None)]publicclassCaptureChartAsTemplate:Robot{[Parameter("Template Name", DefaultValue = "My Golden Layout")]publicstringTemplateName{get;set;}protectedoverridevoidOnStart(){// If you want "overwrite", remove first (safe pattern).if(ChartTemplates.Contains(TemplateName)){varexisting=ChartTemplates.Get(TemplateName);ChartTemplates.Remove(existing);Print($"Removed existing template '{TemplateName}' to recapture.");}// Capture everything from the CURRENT chart (indicators/robots/colors/display settings).varcreated=ChartTemplates.Create(TemplateName,Chart);Print($"Captured template '{created.Name}' from current chart. "+$"Indicators={created.Indicators.Count}, Robots={created.Robots.Count}");}}}
Create distinct workspaces
Structure your discretionary workflow into three dedicated chart layouts and switch between them instantly. A common discretionary workflow is:
Scan – minimal chart, fast loading, clean candles, no clutter.
Confirm – indicators and context overlays, such as trend/volatility filters.
Execute – show orders/positions/targets and quick trade buttons, hide anything distracting.
You typically rely on three core elements when trading trends: a trend filter such as an EMA, a momentum or overbought-oversold measure such as RSI and a clean candlestick chart with stable colours and readable overlays. You can save this configuration as a single template and apply it to any symbol or timeframe you open.
A standardised setup helps you avoid parameter inconsistencies, reduce setup errors and ensure that every chart follows the same decision framework.
When trading mean reversion, you often rely on more indicator context, but you still want a clean and controlled chart. Use templates to decide exactly what remains visible during analysis.
Turn off quick trade buttons to prevent accidental entries. Hide the sentiment panel if it distracts you. Keep the grid and key levels visible for precise positioning. Choose the chart type that matches your approach, whether candlesticks for structure or a line chart for clarity.
When you are in a trade, your priorities change. You need clear visibility of open positions, pending orders and target levels, along with a stable and consistent chart view. Keep your zoom level fixed, ensure price lines are clearly displayed and remove indicators that do not directly support management decisions.
If you work within a team or follow a defined workstation style, use templates to standardise elements such as background colour, bull and bear candle colours, grid visibility and line styling. Apply the same template across all charts to ensure a uniform visual structure, reduce confusion and improve communication.
This setup becomes especially important when you share screenshots, conduct strategy reviews or hand off decisions.
When volatility shifts, your execution and analysis needs change. Create templates to define two distinct workspaces and switch between them as conditions evolve:
In the low volatility template, use a tighter zoom, reduce overlays and maintain a clean view suited for range trading.
In the high volatility template, use a wider zoom, clearer price lines, enable the grid and display positions and orders for tighter execution control.
You often use different indicator parameters, zoom levels and visual preferences depending on whether you are scalping or swing trading. Instead of manually adjusting settings every time you switch timeframes, create dedicated templates for each view.
For example, define M1-Scalp for fast execution and tighter zoom, M15-Intraday for structured session trading and H1-Swing for broader context and smoother overlays.
If you trade multiple strategy families, consider defining a dedicated template for each playbook. For example, you can:
Use a breakout playbook template with the grid enabled, orders and positions visible, a wider zoom and clean price lines for execution clarity.
Use a pullback playbook template with EMA and RSI applied, a normal zoom level and indicator titles visible.
Use a reversal playbook template with additional context indicators and a candle type that highlights wicks and structure.
With each playbook encoded as a template, you can switch environments based on signal type and keep your execution aligned with the strategy you are applying.