Click here to Login




Charting & Scripts - Manage stock charts using the global script

Updated on 2011-05-10





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();
}











no comments (Log in)

QuantShare Blog
QuantShare
Search Posts




QuantShare
Recent Posts

Lock, Link and Undock your Charts
Posted 409 days ago

QuantShare
Previous Posts

More Posts

Back







QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2019 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.