logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
tengfei932  
#1 Posted : Thursday, May 7, 2009 11:13:15 PM(UTC)
tengfei932

Rank: Newbie

Groups: Registered, Registered Users
Joined: 5/8/2009(UTC)
Posts: 5

Hi,

I need help in Metastock Developers Kit (MDK). I copied forum.dll and I try this code and it works:
prd:=PeakBars(1,C,5)-1;
data:=ExtFml("Forum20.Ref",C,prd);


But if I try to make my own code with my own function then it show error "This variable or expression must contain only constant data." for "prd" :
prd:=PeakBars(1,C,5)-1;
data:=ExtFml("MyCode.Ref",C,prd);

I try to make the function just like they have in the example CSampleDLL.cpp. But it still showing me same error. What mistake am I doing. Why my function only accept constant and not the calculate "prd".?

Please Please help. I am going mad solving this. title=

Thank You
Teng Fei
wabbit  
#2 Posted : Thursday, May 7, 2009 11:59:04 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Hi Teng,

Welcome to the Forum.

In your code, you'll probably have a line which looks similar to:
Code:
case x:
a_psFuncArgDef->iArgType = MSXNumeric;
strcpy(a_psFuncArgDef->szArgName, "prd");
etc...


when the argument type should be an array i.e.
Code:
a_psFuncArgDef->iArgType = MSXDataArray;

strcpy(a_psFuncArgDef->szArgName, "prd");





wabbit [:D]


tengfei932  
#3 Posted : Wednesday, May 13, 2009 11:54:31 PM(UTC)
tengfei932

Rank: Newbie

Groups: Registered, Registered Users
Joined: 5/8/2009(UTC)
Posts: 5

Thank You Wabbit.

I put late response as I wanted to solve problem by myself. I do as you say and my code work fine with MSXTest. But when I run the code as function from metastock it do not work.

My code is:

const MSXDataInfoRec *myData;

myData = a_psDataInfoArgs->psDataInfoRecs[0];

sprintf(Ctestingdata,"%4f",a_psDataInfoArgs->iNRecs);
strcat(Ctestingdata," ");
sprintf(Ct,"%4f",myData->pfValue[1]);
strcat(Ctestingdata,Ct);

MessageBox(NULL,Ctestingdata,"Test",MB_OK);

My result are:
Input: const = 1;
Output MSXTest: iNRecs is 0, myData->pfValue[1] = 1;
Output call dll from Metastock: iNRecs = 0; myData->pfValue[1] = first "open" in the stock data.

I want to get the output fomr dll call from metastock to give the const that i am inputting.

How can i get this?

wabbit  
#4 Posted : Thursday, May 14, 2009 3:42:09 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
How did you call the function from MS?


a_psDataInfoArgs->iNRecs is an integer, so you could use %d or %i instead of %4f in the sprintf(), but I am curious why this is returning 0? If you have passed a valid data array to the function this value should be 1, regardless of integer to float casting?


wabbit [:D]

tengfei932  
#5 Posted : Friday, May 15, 2009 1:02:29 AM(UTC)
tengfei932

Rank: Newbie

Groups: Registered, Registered Users
Joined: 5/8/2009(UTC)
Posts: 5

>Dear Wabbit,<br><br> I call function this way from latch:<br><br>LE:=Fml(LX:=Fml("[censored]tfbuyclose_algo");
SE:=Fml("[censored]TFOpenSell");
SX:=Fml("[censored]tfsellclose_algo");

Z:=ExtFml("forum20.Latch",LE,LX,SE,SX);

EnterLong:=((Z = 1) AND (Ref(Z,-1) <> 1));
ExitLong:=((Z = 0) AND (Ref(Z,-1) = 1));
EnterShort:=((Z = -1) AND (Ref(Z,-1) <> -1));
ExitShort:=((Z = 0) AND (Ref(Z,-1) = -1));

EnterLong:=If(EnterLong,1,0);
ExitLong:=If(ExitLong,2,0);
EnterShort:=If(EnterShort,3,0);
ExitShort:=If(ExitShort,4,0);

If(EnterLong=1,ExtFml("delete.SumArrays4",EnterLong,"Buy","Open"),0);
If(ExitLong=1,ExtFml("delete.SumArrays4",ExitLong,"Buy","Close"),0);
If(EnterShort=1,ExtFml("delete.SumArrays4",EnterShort,"Sell","Open"),0);
If(ExitShort=1,ExtFml("delete.SumArrays4",ExitShort,"Sell","Close"),0);
EnterLong;
ExitLong;
EnterShort;
ExitShort;

When I see value in chart, it show value in EnterLong/Short and ExitLong/Short , but the message pop just show 0.0000 value passed on.

The code is fine on MSXTest.

Thank You,
Teng Fei

wabbit  
#6 Posted : Sunday, May 31, 2009 8:27:29 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
I must have missed this one... Did you get the problem sorted out?

If so, what was the problem?

If not, please send me the entire library code and if I have some time I shall have a look.


wabbit [:D]

tengfei932  
#7 Posted : Monday, June 22, 2009 5:51:53 AM(UTC)
tengfei932

Rank: Newbie

Groups: Registered, Registered Users
Joined: 5/8/2009(UTC)
Posts: 5

Dear Wabbit,

I thank you for help and sorry for putting late response. I was away for few days. I find the error in the code. I use pfValue[0] instead of pfValue[iLastValid] to get value. It work in MSXtest as iLastValid same as 0 value. But it not work in actual code.

Thank You,
Teng Fei
wabbit  
#8 Posted : Monday, June 22, 2009 6:24:45 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
wabbit wrote:
If not, please send me the entire library code and if I have some time I shall have a look.



wabbit [:D]

Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.