Discussions
»
Special Interest Groups
»
Advanced Coding Techniques
»
How to retrieve the security name in Explorer or System Tester?
Rank: Newbie
Groups: Registered, Registered Users Joined: 12/28/2006(UTC) Posts: 8
|
Hi,
Explorer runs through once for each security in a given list of securities. Does anyone know how to test which security is being used on a given run?
For example I'm trying to find something like SECURITYNAME used below -
{declare a variable and use a default of 20} t := 20;
{override the default for a list of specific securities} t := if(SECURITYNAME = "BHP", 17, t); t := if(SECURITYNAME = "MSFT", 14, t); {etc etc}
{return a 1 if the RSI is below our threshold} if(RSI(C,2) < t, 1, 0)
Thanks,
Stewart
|
|
|
|
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 Stewart, This can best be achieved using a simple external function. You can either test the name of the current stock and return a true false answer, or you can create lists of different stocks ans test to see which list the current stock is in. The other way to do it is long, ugly and slow; it involves using the Security() function to compare the prices in the current open data file with the prices as described in the Security() function, if they match exactly there is a good chance (but no guarantee) you have found the right stock ticker. You don't necessarily need to define every data item (O,H,L,C,V,OI) but it is the surest way to find an exact match; use as many criteria as you actually need, CLOSE and VOLUME might be sufficient? Code:threshold:=20;
otherDataC:=security(path to BHP,C);
otherDataV:=security(path to BHP,V);
test:=lastvalue(cum((C-otherDataC)<>0)+((V-otherDataV)<>0))=0;
threshold:=if(test,17,threshold);
otherDataC:=security(path to MSFT,C);
otherDataV:=security(path to MSFT,V);
test:=lastvalue(cum((C-otherDataC)<>0)+((V-otherDataV)<>0))=0;
threshold:=if(test,14,threshold);
{etc etc etc.... ugly and slow}
{return}
RSI(C,2)<threshold;
This method is not guaranteed to return the right results... for example, disparities between data files in multiple directories will return erroneous results. wabbit [:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 12/28/2006(UTC) Posts: 8
|
Hi Wabbit,
Thanks so much for your reply. You listed two possible solutions. I was going to use your second technique (ie the one you've listed) if I couldn't find a better one. I don't fully understand your first suggestion though - ie how to use a "simple external function" to "test the name of the current stock and return a true false answer".
Is a "simple external function" going to be contained in a dll that I'm going to have to code myself in C++ or whatever else, or is it a function that I'd write in MetaStock's Function Builder?
I look forward to your response.
Stewart
|
|
|
|
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 again,
The first solutions involve using external functions, aka add-ons, plug-ins or .dlls. You can either write these yourself in C/C++, PowerBasic or PASCAL, if you have the MDK (you only need compare the current data symbol with a user provided argument) or have someone do this for you. This is by far, the best solution.
Using the MSFL code like shown in a previous post is much slower and if you need to define different levels for an entire exchange, this solution is impractical (and you will probably run out of room to write the whole code anyway!).
A third solution would be to re-distribute your data in accordance with the required values for the threshold. If you have a decent data vendor, this would not be too much of an issue, but it means that you will have to maintain multiple lists of stocks which, in my opinion, causes more problems than it solves.
wabbit [:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 6/3/2008(UTC) Posts: 1
|
Hi Wabbit (and others),
I've been looking around for something similar also and rather than re-inventing the wheel, I was wondering if you are aware of any existing addons that have this kind of functionality included?
Thanks
Drums
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Special Interest Groups
»
Advanced Coding Techniques
»
How to retrieve the security name in Explorer or System Tester?
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.