PLKIT GetAsDouble can not reference past values of variable!

Questions about MultiCharts and user contributed studies.
radekj
Posts: 113
Joined: 28 Apr 2008
Has thanked: 20 times
Been thanked: 1 time

PLKIT GetAsDouble can not reference past values of variable!

Postby radekj » 07 Oct 2010

You can not reference past value of variable via
IEasyLanguageVariable interface ! BUG !

Exampel:

void __stdcall mycalc( IEasyLanguageObject *pEL, ...
{
IEasyLanguageVariable *pVar = pEL->Variables["mydata"];
myvalue = pVar->GetAsDouble[0]; //return current value of variable "mydata"
myvalue1 = pVar->GetAsDouble[1]; //return still current value and not value of mydata[1], <- BUG !!!;

ciao
radekj

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 489 times

Re: PLKIT GetAsDouble can not reference past values of varia

Postby Dave Masalov » 11 Oct 2010

Dear radekj,

Everything works fine on our end. Here is the example of the code:

Code: Select all

external: "c:\mcdll.dll", void, "mycalc", IEasyLanguageObject, string, double ;
var:
mydata(0);

value1 = mydata[10];
mycalc( self, "mydata", 200 ) ;

Plot1(mydata[1]);
And DLL file:

void __stdcall mycalc(IEasyLanguageObject* pEL, LPCSTR varName, double newprice)
{
IEasyLanguageVariable *pVar = pEL->Variables[ varName ] ;
if ( pVar )
pVar->AsDouble[1] = newprice;
}

Please come to our Live Chat between 6:30AM and 12AM EST so we can connect to your computer remotely and analyze the situation.

radekj
Posts: 113
Joined: 28 Apr 2008
Has thanked: 20 times
Been thanked: 1 time

Re: PLKIT GetAsDouble can not reference past values of varia

Postby radekj » 17 Oct 2010

"pVar->AsDouble[1]" points to value of "pVar->AsDouble[0]"

and NOT of pVar->AsDouble[1] !

ciao
radekj

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 489 times

Re: PLKIT GetAsDouble can not reference past values of varia

Postby Dave Masalov » 27 Oct 2010

Dear radekj,

Please find attached the archive showing that it is working fine.

Please note that only serial variables may have different previous values. For simple variables previous value is equal to current value.

Code: Select all

// C++ code

double __stdcall GetPrevValue(IEasyLanguageObject* pEL, LPCSTR varName)
{
double res = 0;
IEasyLanguageVariable *pVar = pEL->Variables[ varName ] ;
if ( pVar )
res = pVar->AsDouble[1];
return res;
}

//------------------------
// PL Script

external: "mcdll.dll", double, "GetPrevValue", IEasyLanguageObject, string;
var:
mydata(0);

value2 = mydata[1]; // make variable mydata serial.

mydata = close;
value1 = GetPrevValue( self, "mydata");

if currentbar > 1 then
begin
Plot1(mydata);
Plot2(value1);
end;
Screenshot and pla archive:

screen.PNG
arhive.pla
Attachments
PrevValues.zip
(126.65 KiB) Downloaded 140 times


Return to “MultiCharts”