in Search

MDK Need help in function parameter!

Last post 06-22-2009, 6:24 by wabbit. 7 replies.
Sort Posts: Previous Next
  •  05-07-2009, 23:13 29679

    MDK Need help in function parameter!

    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.

    Thank You
    Teng Fei
  •  05-07-2009, 23:59 29680 in reply to 29679

    Re: MDK Need help in function parameter!

    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 Big Smile [:D]



    "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
    Edsgar W. Dijkstra

     

    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status :
    My SkyPE account : wabbit.com.au

  •  05-13-2009, 23:54 29709 in reply to 29680

    Re: MDK Need help in function parameter!

    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?

  •  05-14-2009, 3:42 29711 in reply to 29709

    Re: MDK Need help in function parameter!

    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 Big Smile [:D]


    "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
    Edsgar W. Dijkstra

     

    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status :
    My SkyPE account : wabbit.com.au

  •  05-15-2009, 1:02 29723 in reply to 29711

    Re: MDK Need help in function parameter!

    Dear Wabbit,

     I call function this way from latch:

    LE:=Fml("XXXTFOpenBuy");
    LX:=Fml("XXXtfbuyclose_algo");
    SE:=Fml("XXXTFOpenSell");
    SX:=Fml("XXXtfsellclose_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

  •  05-31-2009, 8:27 29834 in reply to 29723

    Re: MDK Need help in function parameter!

    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 Big Smile [:D]


    "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
    Edsgar W. Dijkstra

     

    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status :
    My SkyPE account : wabbit.com.au

  •  06-22-2009, 5:51 29959 in reply to 29834

    Re: MDK Need help in function parameter!

    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
  •  06-22-2009, 6:24 29960 in reply to 29834

    Re: MDK Need help in function parameter!

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



    wabbit Big Smile [:D]


    "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
    Edsgar W. Dijkstra

     

    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status :
    My SkyPE account : wabbit.com.au

View as RSS news feed in XML