Global scripts not only allow you to get information about the active chart forms, it also let you manipulate and update them dynamically. To create a new script, select "Tools" then "Script Editor". Create a new file, type your script code (in C# or JScript.Net), then click on "Execute". Of course the hard part (In fact, it is not so hard) is the implementation of the script. The most important thing you need to know is the CONTROL+SPACE shortcut that will display the list of available variables you can use in the script. When executing this shortcut you can see variables such as App, Charts, Downloader, Global, Quotes. Click on a variable and you will see a brief description of it. How to access and update charts "Charts" variable contains all the properties and functions needed to access and update charts. To get the list of open charts, for example, you have to execute the following method/function: Charts.GetAllCharts(). This function returns an array of "Chart" objects. The "Chart" object contains variables and functions to manipulate a single chart. Type the below example, but don’t be surprised if the active chart disappear. Chart chart = Charts.GetSelectedChart(); chart.Close(); The above code instructs QS trading software to get the current active/selected chart and close it. Just after typing "chart.", the variables contained within the "Chart" class and the functions supported by this class are displayed in a list. There are about 30 variables/functions in the "Chart" class. You can create/remove panes, add formulas, move/translate/resize the chart, increase/decrease the number of displayed bars, refresh the chart (example: after data is downloaded), change the time frame or the displayed stock/security... Another Charting Script Example while(true) { Chart chart = Charts.GetSelectedChart(); chart.Refresh(); App.Main.Sleep(10000); // 10 * 1000 milliseconds } The script loops indefinitely (unless you stop it by clicking on "Cancel") and updates the active chart every 10 seconds. This script is very useful if for example at the same time you have another script that automatically imports or downloads data every few seconds or minutes. By using the "GetAllCharts" function instead of the "GetSelectedChart" method, you can instruct the application to refresh all charts. Chart[] charts = Charts.GetAllCharts(); for(int i=0;i < charts.Length;i++) { charts[i].Refresh(); }
|