Click here to Login




Display several stock market charts with one click

Updated on 2012-02-21





In this post, I will show you how to create a script that displays several stock market charts (or charts of any other securities - ETFs, Forex, Futures...) and automatically arrange them.

The script is implemented using the script editor tool of QuantShare


Create a New Script

In QuantShare, a global script allows you to manage and manipulate different application tools. It allows you to access database data (historical, intraday, tick and custom), manipulate charts, automate the downloading process, access different plug-ins...

To create a new global script:

- In the main menu, select "Tools" then "Script Editor"
- In the new form, select "File" then "New"
- Type "6 Charts" then click on "OK" to create a new tab that will contain the code of our stock market charts script

To get information about the different variables and functions you can use in the global script, click on the "Help" button.
To display the list of available variables/functions, click on the text editor then use CONTROL+SPACE shortcut.


Stock Market Charts Script

Our script will perform the following actions:

- Close all open charts (optional)
- Open 6 stock charts (historical or intraday)
- Arrange those 6 charts


Close all open charts

The "Charts" object contains all the necessary functions to add, remove, update or even draw on a chart.

To close open charts, we must first get a reference of each one of them then invoke the "Close" member of each "Chart" object. The "Chart" object contains functions and properties to manipulate a single chart.

Chart[] myCharts = Charts.GetAllCharts();

The above instruction is implemented in C# and it calls "GetAllCharts" function to return an array containing the "Chart" object of each open chart.

The next step consists of looping through all these charts and calling the "Close" function for each one.

for(int i=0;i < myCharts.Length; i++)
{
myCharts[i].Close();
}


Note:
- "myCharts.Length" returns the number of elements in the "myCharts" array. In other words, it returns the number of open charts.
- "myCharts[i]" access the chart object located at index "i" (i vary from 0 to myCharts.Length)


Open six stock charts

To open six stock charts, we simply call the "Charts.OpenChart" function six times.

for(int i=0;i < 6; i++)
{
Charts.OpenChart(null, null, null);
}


"OpenChart" function gets three parameters:
Symbol: The ticker symbol of the security associated with the chart
Formula Name: A formula name
Formula: A formula to apply to the graph/chart

Set "null" to instruct QuantShare to get the default value.


Arrange charts

Arranging charts is the easiest task because it involves calling a single function "Charts.Arrange()"

Charts.Arrange();


This will automatically arrange your charts. You can specify the number of rows and columns by calling for example:

Charts.Arrange(4, 4);


Here is the complete stock market charts script:

Chart[] myCharts = Charts.GetAllCharts();
for(int i=0;i < myCharts.Length; i++)
{
myCharts[i].Close();
}

for(int i=0;i < 6; i++)
{
Charts.OpenChart(null, null, null);
}

Charts.Arrange();



Displaying Stock Market Charts

Now that we have completed the implementation of our stock market charts script, we want to execute it and see it in action.

To do this, click on "Execute" button.

A more convenient way to execute scripts is by adding them to the bookmark panel (What is the Bookmark Panel?).

In the bookmark panel, double click on the script to execute it.


Update Chart Symbols using a Watchlist

Your stock charts are opened and arranged. You want to specify a different stock symbol for each one of them and you want to do it quickly, right?

Here is how:

- Select "Tools" then "Watchlist"
- Select or create a watchlist that contains the stocks for which you want to display charts
- Click on the left or right arrows next to "Browse" (located at the bottom of the watchlist control)











no comments (Log in)

QuantShare Blog
QuantShare
Search Posts




QuantShare
Recent Posts

Create Graphs using the Grid Tool
Posted 1480 days ago

Profile Graphs
Posted 1585 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 © 2024 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.