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

Notification

Icon
Error

Options
Go to last post Go to first unread
ankur_chops  
#1 Posted : Wednesday, October 10, 2012 3:48:15 AM(UTC)
ankur_chops

Rank: Member

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

Hi Everyone,
I need urgent help on Metastock Explorer.
I want to write a formula in explorer which will give me lowest 10 point of RSI in the last 365 bars , and then to find average of it. If current RSI is equal to or less then the avg , that should be my result.

For example:
if in last 365 days lowest 10 RSI values are: 10,15,22,12,11,13,16,14,16,10 , then if current RSI value is less than or equal to the average of these 10 values, that instrument should be shortlisted.

Many Thanks
Ankur
wabbit  
#2 Posted : Wednesday, October 10, 2012 5:55:28 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)
There are ways to compute the 'n' highest and lowest values in a data array using Mestastock code, where 'n' is a small number (probably less than 10), but this is a hard way to do what is a simple task outside MS (external function).


wabbit [:D]

ankur_chops  
#3 Posted : Thursday, October 11, 2012 2:47:49 AM(UTC)
ankur_chops

Rank: Member

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

A simple way ( not coded ) is to put all the data values in excel , sort them out. Pick 10 lowest ones and get their average.
But can we write a code for this ? specially not for Price , but for Indicator like RSI .

Ankur :)
wabbit  
#4 Posted : Thursday, October 11, 2012 6:17:04 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)
Use the MDK to write an external function, where the required data array is passed to the external function and the value which is returned is the required average.


wabbit [:D]

wabbit  
#5 Posted : Thursday, October 11, 2012 6:27:55 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 also think you're going to have to do a lot ore work with your requirements definition because just returning the average of the ten lowest RSI values is not going to provide a lot information to improve your trading? Recording the "peak and trough" values of the indicator and returning the average the ten lowest troughs might make more sense, but then you'll have to deal with dynamic nature of ZigZag(), Peak() and Trough(). How would you deal with repeated values?

This all reminds me of some work I did many, many years ago on self-levelling indicators (or automatically finding strategic levels for indicators) such as RSI: http://forum.equis.com/forums/thread/13908.aspx
ankur_chops  
#6 Posted : Thursday, October 11, 2012 10:01:16 AM(UTC)
ankur_chops

Rank: Member

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

Thanks wabbit,but still I am not able to proceed further.....
if I reduce my requirement from 10 lowest points to 4-5 lowest points , then will it be possible to write a code for above problem ??

Ankur
wabbit  
#7 Posted : Thursday, October 11, 2012 5:31:30 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)
Trading tip: Don't change your trading to meet the limitations of software or programming; match your software and code to your trading requirements.

You can achieve your original "goal" by writing (or getting written) an external function library which works outside the limitations of the MS formula language.


wabbit [:D]

ankur_chops  
#8 Posted : Friday, October 12, 2012 6:49:04 AM(UTC)
ankur_chops

Rank: Member

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

how to use external functions in metastock ?? is there any tutorial which tells how u use external function in metastock?
one more silly Q : who will provide the function ? [:)]

Ankur

wabbit  
#9 Posted : Friday, October 12, 2012 8:04:52 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)
Look up ExtFml() in your MS User Manual. To write external functions requires a knowledge of programming, and the MetaStock Developer Kit.
wabbit wrote:
For custom MetaStock and DLL programming : http://www.wabbit.com.au
jjstein  
#10 Posted : Friday, October 12, 2012 10:47:52 AM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
SCOTT: Any way to restrict LOWESTSINCE() to the past 250 periods, to accomplish this?
wabbit  
#11 Posted : Friday, October 12, 2012 4:35:38 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)
Dunno. Never thought too much about it. I can imagine a way that would work only for the final 250 bars on the chart by employing a LastValue() with a Cum(1), but that wont provide any backtestable information on anything other than the last bar of the chart. I did write an external variable ValueWhen() for Roy Larsen which could be used to do the trick, but then again, I'd just write a new function for the LowestSince() if I needed it.

In C++, I image the OP project is only about 4 steps; stuff a vector, sort the vector, get the values and average them and return the value, so about 8-10 lines of code (after the rest of the overhead for creating the library as a Win32 DLL)

I've said it too many times before -- the extremely limited nature of the MS scripting language is great for basic functions, but as soon as I have to think about some way to work around these limitations, I don't even bother and open up a proper programming IDE and build an external function in a much more powerful language where we are not hamstrung by those limitations.


wabbit [:D]

MS Support  
#12 Posted : Wednesday, October 24, 2012 2:00:00 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,960

Thanks: 92 times
Was thanked: 155 time(s) in 150 post(s)
Since the MetaStock Formula Language does not have the ability to rank or sort data, I would have to agree with wabbit and suggest an external DLL.
ankur_chops  
#13 Posted : Friday, November 2, 2012 4:14:00 AM(UTC)
ankur_chops

Rank: Member

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

ok..but who can provide me that external dll
does metastock provide that service?? if yes how much it is going to cost me?

Thanks
Ankur
wabbit  
#14 Posted : Friday, November 2, 2012 6:12:03 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)
.
MS Support  
#15 Posted : Tuesday, November 13, 2012 4:51:09 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,960

Thanks: 92 times
Was thanked: 155 time(s) in 150 post(s)
I'm sorry but MetaStock does not create custom DLL's. To get this, you would need a programmer with access to our MetaStock Developer's Kit (MDK). The MDK can be purchased from our Sales department. The programmer you would have to find yourself. Some of the people on the forum can do custom DLL's but I do not know if they have the time. You could also try the computer science department of a nearby college.
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.