Using Elexcel on multi instance.. a concept that work

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Using Elexcel on multi instance.. a concept that work

Postby arjfca » 10 Dec 2012

Hello

Anybody when as try to work with Elexcel dll collection to send data to Excel as encounter a problem when trying to use the dll in more than one charts . Inevitably, a failure do occur and the indicator is turned off.

I did find a solution to enable me to send data from up to 8 charts ( could be more) to Excel by using a detour with Global variable. Here is a short description on how I did succeed to do it

1-
Create your indicator in two model
a) a master that include the Elexcel.dll
b) a slave .( no Elexcel include)

2)
Indicator input:
use a unique chartNumber (1) or Chartnumber(2) or .... Chartnumber(8)
Use an unique address for the appropriate data of the data to be placed like( $f$15) each charts will have a different address

3-
In the indicator, compute your number and translate them in a string, If you want to send a collection of data, use a comma between them

From your string of data, add the Excel address + comma to the string
ex: $F$15,1.29030,1.29070,1.29030,1.29060,1.29070,1.28970

Now, Save this string that include your data and Excel address to a uique Global variable like
Value1 = GVSetnamedString("LastbarString" + NumToStr(ChartNum,0), LastBarString)

Using this formula to save on a global variable, each string variable will have a name related to is chart number

Now, in the master indicator
Use a routine that will
a) read each global variable
b) extract the first set of information that is the unique Excel address
c) Send to Excel using the Excel target cell + the remaining of the string
d) to prevent sending same data again and again, once a data is send, save it in a variable and compare it only if a new string is different than the previous one. For that, I did use an array of string

For myself, I have include a more fancy tool where the target cell in Excel is provided by Excel in another Global variable read by MC indicator

A bit complicated to explain, Not an easy task, but it work

Martin

Return to “MultiCharts”