Click here to Login

LiveZilla Live Help
LiveZilla Live Help



How to Send Commands to QuantShare from Excel or Other Applications

Updated on 2013-01-22





There are probably tons of reasons, why someone would want to manipulate QuantShare from another application. Here are some examples:

- You have an excel sheet with ticker symbols and some custom data. You would like to display the symbol's chart in QuantShare when clicking on the ticker symbol cell

- Click on a button in excel to instruct QuantShare to do a scan and return a list of symbols that meet your criteria

- You want to get a list of trades from your QuantShare portfolios in your own application


How to send commands to QuantShare from Excel

Let us take the first example described above and implement it.

What we want is that when a user clicks on a button or cell in excel, QuantShare automatically updates the active chart with a specific ticker symbol.

There are several ways to implement this (files, sockets...). We will use here a technique that consists of running "QuantShare.exe" file with some specific arguments. In these arguments, we will define an existing task to execute.

- First, let us open QuantShare and create a script by selecting "Tools -> Script Editor".
- Select "File -> New" then type "ChangeSymbol" as file name
- In the script editor, type the following formula to update the active chart then save the script:

string symbol = (string)Global.GetVariable("newsymbol");
Chart chart = Charts.GetSelectedChart();
if(chart != null)
{
chart.SymbolName = symbol;
}


In the first line, we got the new symbol from a global variable. We will see later how to set that global variable "newsymbol" from excel.

The second step consists of creating a new task:
- Select "Tools -> Task Manager"
- Click on "Click here to add a task"
- Select "App based task" tab (We just need to create a task that is never executed by the application without instructions from us)
- In "Add Task" control and under "Scripts to be executed", click on "Add" then select "ChangeSymbol" script we have just created
- Next to "Task Name", type "ChangeSymbol" then click on "OK" to save the task

The third step would be to open Excel and implement the QuantShare call.

- Open Excel and create a new document
- Create a new button then associate a function to it (click event)

More info can be found here:
Add a button and assign a macro to it

- Type the following code (macro):

res = Shell("E:\Program Files\CTrading\QuantShare5\QuantShare.exe TaskManager ChangeSymbol newsymbol:" + Range("A2"), 1)




Explanation:
- The "Shell" function executes a specific file (QuantShare.exe for instance)
- "TaskManager" is the first argument and it instructs QuantShare to use the task manager plug-in to execute the task specified in the second argument (ChangeSymbol)
- The third argument instructs QuantShare to create a global variable "newsymbol" and set its value with the content of cell A2 (Range function)

Now, you can type a ticker symbol in the cell "A2" and click on the button to update QuantShare's active chart.

Note that you can define several global variables by separating them with a semi-colon. Example:
newsymbol:GOOG;var2:Test

This command instructs QuantShare to create two global variables (newsymbol and var2) and associates them with the following values (GOOG and Test).












one comment (Log in)

QuantShare Blog
QuantShare
Search Posts




QuantShare
Recent Posts 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 2014 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.