in Search

Using MSFL.dll in C# 2005

Last post 08-06-2007, 10:10 by carot. 4 replies.
Sort Posts: Previous Next
  •  07-08-2007, 15:23 24635

    Using MSFL.dll in C# 2005

    Hi all

    Not sure if solution already exists on this site but I've managed to implement use of the MSFL.dll using C# 2005. Basically I've converted the c++ msfl.h file into a C# compatible form and have used Platform Invoke to call methods on the msfl.dll.

    I can make the msfl.cs source code freely available to anyone who wants it.

    Regards

    Craig

  •  07-08-2007, 18:07 24636 in reply to 24635

    Re: Using MSFL.dll in C# 2005

    Craig,

    I, for one, would like a copy of the code, and maybe a sample function?

    Are there any benefits to compiling a C# app over a non-.NET app?  I never got onboard with the whole .NET thing and didn't like the direction Microsoft was going with its program environments, but if there are benefits to be had, then I had better take another look?



    wabbit Big Smile [:D]



    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 : wabbit.com.au SkyPE online status
    My SkyPE account : wabbit.com.au

  •  07-10-2007, 7:41 24653 in reply to 24636

    Re: Using MSFL.dll in C# 2005

    Hi Scott

    I'll upload the code to my website when I get home tonight. I have a sample function which uses the MSFL1_GetDataRec() function to retrive all price data for a particular security.

    Unfortunately the MSFL2_GetMultipleDataRecs() function doesn't work. So I have to make multiple calls to MSFL1_GetDataRec(), but the performance isn't noticably different. 

    I'm not sure why MSFL2_GetMultipleDataRecs() doesn't work. I pass the function an array of price record structs but it doesn't populate them.

    Brandan - Not sure if you have come across this problem in your dealings with .NET?

    ----------------------------

    As for benefits to compling a C# app instead of C++6, where do I start! Smile [:)]

    Its main benefits are that it is very simple to write in (comparable with Visual Basic) and the code runs almost as fast as C++ (approx 1.1 seconds for every 1 second in C++).

    For me, writing a function of medium complexity in C++ would take 4 times longer than in C# purely as C# environment is so much easier to use and bug handling/fixing is a dream compared to C++. I now spend more time thinking about trading logic rather than technical programming issues.

    I was sceptical of .NET before, it looked like there were lots of incompatibility issues with unmanaged code. However I've found that not to be the case.

    C# / .NET has a namespace called InteropServices which allows you to call C# dlls from C++  code.

    I use a C++ MSX dll wrapper so that my C# dll can interface with Metastock.

    Regards

    Craig

  •  07-10-2007, 12:15 24658 in reply to 24653

    Re: Using MSFL.dll in C# 2005

    Administrator has moderated this post.

    It is in violation of the Equis Software license agreement to distribute the MDK source code in this manner.

  •  08-06-2007, 10:10 24948 in reply to 24653

    Re: Using MSFL.dll in C# 2005

    I have write this code, and it return -170 from MSFL1_AddSecurity function, means MSFL_ERR_INVALID_FIELD_ORDER , can anyone help me fix this. Thanks in advance.

    private void CreateCK()
            {
                string folder = txtDesPath.Text;
                int iErr;
                byte nDirNum=0;
                iErr = MSFL.MSFL1_OpenDirectory(folder,ref nDirNum,MSFL.MSFL_DIR_FORCE_USER_IN);
                if(iErr == 1)
                {
                    iErr = MSFL.MSFL1_BuildMetaStockDirectory(nDirNum);
                }
                int iDate;
                iDate = DateTime.Now.Year * 10000 + DateTime.Now.Month * 100 + DateTime.Now.Day;
                // create CK
                MSFLSecurityInfo_struct objSec = new MSFLSecurityInfo_struct();
                //MSFLSecurityInfo_struct8 objSec = new MSFLSecurityInfo_struct8();
                objSec.dwTotalSize = MSFL.MSFL_SEC_INFO_SIZE;
                objSec.szName = "VCD";//item[0].ToString();
                objSec.szSymbol = "VCD";//item[0].ToString();
                objSec.bCompositel = MSFL.MSFL_FALSE; // not a composite
                objSec.cPeriodicity = 73; // daily
                objSec.wInterval = 0; //not know
                objSec.ucDisplayUnits = 0; // not know
                //Set the available data
                objSec.wDataAvailable = MSFL.MSFL_DATA_DATE + MSFL.MSFL_DATA_CLOSE + MSFL.MSFL_DATA_VOLUME + MSFL.MSFL_DATA_TIME;
                //objSec.wDataAvailable = MSFL.MSFL_DATA_DATE + MSFL.MSFL_DATA_CLOSE + MSFL.MSFL_DATA_HIGH + MSFL.MSFL_DATA_LOW + MSFL.MSFL_DATA_OPEN + MSFL.MSFL_DATA_VOLUME;
                /*objSec.wDataAvailable = MSFL.MSFL_DATA_DATE + MSFL.MSFL_DATA_CLOSE +
                        MSFL.MSFL_DATA_VOLUME + MSFL.MSFL_DATA_HIGH + MSFL.MSFL_DATA_LOW +
                        MSFL.MSFL_DATA_OPEN;*/
                objSec.lFirstDate = iDate;
                objSec.lLastDate = iDate;

                iErr = MSFL.MSFL1_AddSecurity(nDirNum,ref objSec,0);

                if(iErr == 0)
                {
                    MessageBox.Show("OK");
                }
            }
View as RSS news feed in XML