Chart layouts contain information such as the number of panes, the formula(s) as well as the template that is applied by each pane. How to create a layout? To create a layout from a chart, right click on that chart, then select "Save layout as...". Type the name for your layout then save. How to apply a layout? To update a chart layout, right click on a chart, select "Change Layout" then select the layout you want to apply. You can also apply a layout to all opened charts by clicking on the button as shown in the picture below then selecting the appropriate layout. You can also switch from one layout to another using the CONTROL+ALT+L hotkey Custom Scripts? The previous hotkey we introduced allows you to move from one layout to the next one. But how to access the previous layout instead of the next one? There is no hotkey for this so we are going to create our own hotkey to do that. You can create a custom script and assigns a shortcut to it with the "Add Shortcut" feature that you can find after selecting "Divers -> List of shortcuts" at the bottom of Alchemcharts. The script should be created using "Tools -> Script Editor". Here is an example: if(!Global.ContainsVariable("layout_index")) { Global.SetVariable("layout_index", 0); } int index = (int)Global.GetVariable("layout_index"); string[] layouts = App.Main.GetLayoutNames(); App.Main.UpdateChartLayout(Charts.GetSelectedChartId(), layouts[index]); index = index - 1; if(index < 0) { index = layouts.Length - 1; } Global.SetVariable("layout_index", index); The idea here is to check the value of the global variable "layout_index" (that we define). Then, we get the list of all layouts, pick the layout given the "layout_index" then subtract one to "layout_index", so that the next time the script is called we will get the previous layout. After you create the script, select "File -> Save As..." then save it under the "Scripts" folder. Now, at the bottom of QuantShare, click on the "Divers" icon then "List of Shortcuts". In the new form, click on "Add Shortcut". Type the name of the shortcut, a description, how to activate it then finally enter the script path. If you named the script "prev_layout" then you should enter there: Scripts\prev_layout.azf Automation Ideas? There are several ways we can use the layout tool. And when combined with custom scripts capabilities, we can further create advanced and creative stuff. Below are some examples of what you can achieve: Update Chart Layout based on Active Time Frame: In this post, we show you how to change the layout of a chart dynamically based on the current chart time frame. Update Chart Layout based on Active Ticker Symbol: In this post, we show you how to change the layout of a chart dynamically based on the current chart symbol. For example, you can display the RSI on the lower pane for stocks and when switching to an index display a market breadth indicator. Update Chart Layout based on Active Ticker Symbol - Part 2: This is the second part of the previous blog post. Here, we explain how to associate a specific layout to a list of symbols so that a specific layout is applied to a chart each time a symbol in a specific list is selected.
|