IEasyLanguageObject C++ question

Questions about MultiCharts and user contributed studies.
simon007
Posts: 50
Joined: 12 Apr 2007
Has thanked: 5 times
Been thanked: 1 time

IEasyLanguageObject C++ question

Postby simon007 » 03 Feb 2013

Hi @,

I want to convert the array that is contained in the IEasylanguage property Close MD to a vector containing the last 50 values.

Right now I use this;

Code: Select all

  vector<double> sig;

  for (int i = 0; i < 50; i++)
    {
       sig.push_back(pELObj->CloseMD[data1]->AsDouble[ i ]);
    }


Is there a better way of doing this without iterating through the data and copying it on every bar?

Thanks,

Simon

User avatar
TJ
Posts: 6583
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: IEasyLanguageObject C++ question

Postby TJ » 04 Feb 2013

simon007 wrote:Hi @,
I want to convert the array that is contained in the IEasylanguage property Close MD to a vector containing the last 50 values.
Right now I use this;

Code: Select all

  vector<double> sig;
  for (int i = 0; i < 50; i++)
    {
       sig.push_back(pELObj->CloseMD[data1]->AsDouble[ i ]);
    }
Is there a better way of doing this without iterating through the data and copying it on every bar?
Thanks,
Simon

Maybe add a ring buffer?

simon007
Posts: 50
Joined: 12 Apr 2007
Has thanked: 5 times
Been thanked: 1 time

Re: IEasyLanguageObject C++ question

Postby simon007 » 04 Feb 2013

Hi TJ,

Somebody else gave me that tip too

This is what I acme up with.

Code: Select all

static vector<double> sig;

sig.push_back(pELObj->CloseMD[data1]->AsDouble[0]);
sig.reserve(50);



Thanks,

Simon

faschim
Posts: 36
Joined: 14 Jul 2009
Has thanked: 2 times

Re: IEasyLanguageObject C++ question

Postby faschim » 05 Feb 2013

Would a dll with this code be threadsafe? I know a dll is only mapped once into the process space. Does making the vector sig a static variable give each process using the dll its own copy of sig?

simon007
Posts: 50
Joined: 12 Apr 2007
Has thanked: 5 times
Been thanked: 1 time

Re: IEasyLanguageObject C++ question

Postby simon007 » 05 Feb 2013

faschim wrote:Would a dll with this code be threadsafe? I know a dll is only mapped once into the process space. Does making the vector sig a static variable give each process using the dll its own copy of sig?


That's a good question...

In another dll I use I created an array of a specific object and I use a number in the easylanguage function to indentify which object in the array belongs to which multicharts window. It's a bit crude, but it works.

I read somewhere that you are suppose to use a singleton or a LIFO(last in first out) stack, but that's for advanced C++ programmers which I'm not :-(

faschim
Posts: 36
Joined: 14 Jul 2009
Has thanked: 2 times

Re: IEasyLanguageObject C++ question

Postby faschim » 05 Feb 2013

In another dll I use I created an array of a specific object and I use a number in the easylanguage function to indentify which object in the array belongs to which multicharts window. It's a bit crude, but it works.

This is in fact the same thing I do. It is indeed crude. Would be nice to have a simpler cleaner methodology. Perhaps someone from Multicharts support could chime in here. If I am not mistaken all studies are compiled into dll's. So obviously they know how to do it and be threadsafe.


Return to “MultiCharts”