Rank: Member
Groups: Registered, Registered Users Joined: 2/23/2006(UTC) Posts: 11
|
Hello MetaStock’ers, I have created an external function to read a security’s price
information from the metastock database. The function accepts 3 input data structure members:
- The function uses the MSFL1_ReadDataRec API to read each
price record of the security and adds each record to the MSFLPriceRecord_struct
array.
This seems to work fine, but if I create the MSFLPriceRecord_struct
array using the MSFL_MAX_DATA_RECORDS constant for the size, I get a stack overflow
error. I have decreased the size to 12000 and the function works fine.
I have 15 years worth of data and only seem to be using 5100’ish
members of the array, so the size won’t be a problem for a while but it would
be nice to have a bullet proof, reusable function to read a security populate a MSFLPriceRecord_struct/MSXDataRec
type structure and be able to pass the pointer to different internal functions.
Question 1:
Has anyone written a similar function? Did you fine a way to
get around the stack memory error or did you store the security info in a
different structure?
Question 2:-
When I run this function in daily mode it works fine, when I
run it in weekly the MSFL1_GetSecurityHandle API falls over with message 191 (MSFL_ERR_SECURITY_NOT_FOUND),
has anyone experienced this before? Any suggestions on how to correct this?
Thanks in advance, Shaun
|
|
|
|
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)
|
ArmyofTheLostToys wrote:The function accepts 3 input data structure members:
- security
path
- symbol
- periodicity
And has one output member - security
info (pointer to an array of struct MSFLPriceRecord_struct)
The function uses the MSFL1_ReadDataRec API to read each
price record of the security and adds each record to the MSFLPriceRecord_struct
array. Shaun, I don't quite understand what it is that you are trying to achieve? Can you give a little more information on the goal here? wabbit [:D]
|
|
|
|
Rank: Member
Groups: Registered, Registered Users Joined: 2/23/2006(UTC) Posts: 11
|
Hey Wabbit,
Thanks for getting back to me. My goal is to create an
indicator to perform a relative strength comparison. It will compare the
security displayed on the chart to the ‘compare-to’ security passed to the indicator
e.g. comparing ANGLO to the gold price, or the gold price to the main index.
I had created this function using the metastock formula language
but because I was unable to define the ‘compare-to’ security at runtime (i.e.
the ‘input’ function would not allow me to pass a string) I had to create a new
indicator each time I wanted to change the ‘compare-to’ security.
So I decided to move the indicator to an external C function
and could therefore pass the ‘compare-to’ security to the function (I might
still have create a new metastock indictor/explorer to call the external
function for each different ‘compare-to’ security but at least I wont have to
replicate the relative strength comparison logic).
So the basic logic flow is as follows:-
MetaStock Indicator/Explorer will call the external relative
strength comparison function. This function will then perform the following
steps:-
- The ‘read compare-to security’ function will accept the
security path, symbol, periodicity and a pointer to an array of struct MSFLPriceRecord_struct.
It will then perform the following logic:-
Perform initialization routines e.g. open the
directory, get the handle etc. - API to read the first price record
- array [index]
- Perform secondary read
Perform routines housekeeping e.g. close the
directory, unlock securities etc.
The first problem I have is that if I run this function with
periodicity set to ‘D’ it works great, as soon as I change it to ‘W’ the MSFL1_GetSecurityHandle
API falls over with message 191 (MSFL_ERR_SECURITY_NOT_FOUND).
Also if I create the size of the MSFLPriceRecord_struct type array? What size you create the
array? Or if you did something different?
|
|
|
|
|
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.