Discussions
»
Product and Service Development
»
Formula Assistance
»
Stuck in a Complex indicator requiring different bands
Rank: Newbie
Groups: Registered, Registered Users Joined: 3/16/2013(UTC) Posts: 2
|
Hello everyone I am not finding any way I can code this part of a new indicator I am thinking of. I want to - add a band of 5 period moving average to price ROC. But the problem is that I want only the positive values of ROC to be taken into account while calculating the upper band (positive band) and only negative values of ROC to be taken into account while calculating the lower band (negative band). And, whenever a negative value of ROC is there, upper band will remain constant until a positive value of ROC occurs. Similar for the lower band. This looks like a comples problem for me. I am not sure if it can be coded in Metastock. Please Help. Thanks in advance. :)
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi Miks
I'm quite certain that what you're asking for can be done. You don't mention what form of MA you plan to use, and from your description I don't get a clear picture of what your indicator display will look like. I don't think even the Forum.Mov DLL function can manage an SMA that will meet your needs, so you may have to use discrete MetaStock code to create and control the SMA. The Forum Mov and MSTT EMA functions can both hold a value constant for as long as required, and with a little supporting code either one could probably get the job done.
The Forum DLL Mov(E) function doesn't actually hold the output at exactly the same value, but for your purposes it would be more than accurate enough. The trick is to set the Periods parameter to 5 while accepting ROC input, and then switch the Periods parameter to a very large number when you require the EMA to remain constant. Power(10,10) is a large enough number to hold an EMA output (from the Forum DLL) constant to 4 decimal places for as much data as you're ever likely to load.
What you may not realize is that (in my opinion) the best way to learn about the MetaStock Formula Language is to solve your own problems just one step at a time. Sure, this will be time-consuming and very frustrating at times, but you will learn. Having someone else solve each problem won't teach nearly as much or as quickly. So give it a try and let us know how you get on.
Roy
|
|
|
|
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'd be looking to jam some ValueWhen() functions together, and a couple of PREVs. Shouldn't be too much of a task???
wabbit [:D]
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi Wabbit
I didn't know you were a PREV fan :-)
Roy
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 3/16/2013(UTC) Posts: 2
|
Thanks a lot guys.Finally I made it with a help of if,valuewhen and (as wabbit suggested) a couple of prevs :) Couldn't have done without your help, Wabbit and Msttt.. @MSTT.. Thanks a lot for the encouragement to do my stuff myself. Actualy, I tried doing it myself for a couple of days but I was missing this 'valuewhen' function. @Wabbit.. Yeah, Wasn't much of a tasak and just a one line code- very different from what I thought of the code. Thanks.
|
|
|
|
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)
|
Good work. Well done.
wabbit [:D]
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Product and Service Development
»
Formula Assistance
»
Stuck in a Complex indicator requiring different bands
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.