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

Notification

Icon
Error

Options
Go to last post Go to first unread
btconnolly  
#1 Posted : Saturday, April 4, 2015 10:06:09 PM(UTC)
btconnolly

Rank: Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/25/2005(UTC)
Posts: 12

Is it possible for a chart indicator to appear right side up or upside down automatically, based on a formula? Two possibilities:

#1) Somehow invert the y axis scale of an indicator based on the outcome of a formula or

#2) Somehow affect ALL previous values in that indicator based on a formula. 

An example of #2 might be:

FormulaZ:=If(Correl(formulaA, C, 15, 0)<0, multiply ALL (or x#of) previous values in formulaA*-1,FormulaA);

Is either #1 or #2 possible?  Thanks

 

 

 

 

 

 

mstt  
#2 Posted : Sunday, April 5, 2015 7:17:10 AM(UTC)
mstt

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 bt The short answer is yes, but quite possibly not the way you are thinking. The first thing I think you need to understand is the purely sequential nature of the MetaStock Formula Language (MFL). With the possible exception of the PREV function a series of MS functions can only proceed from first to last. There is no Jump, Branch or other functions that allow the execution order of a series of functions or commands to take a different or alternative route. The If() function allows some decisions to be made, but the result cannot affect the instruction sequence prior to the current point of execution. This same sequence applies to indicators, data bars, securities or whatever. PREV does allow for an interruption to the bar sequence, but it cannot direct the sequence or flow of instructions back beyond the PREVious bar. So what you need to do is incorporate your two indicators into one so that the second series of instructions (or functions etc.) can invert or otherwise modify the first series of instructions. Put another way, you probably need to create the two alternative or inverse results, and then with the third section of code make a selection between the two (or more) alternatives. You cannot change the result of one indicator by a subsequent action, but you can prepare the subsequent action decision by first creating the two alternatives results and then make the decision as to which course to take. As a MetaStock user for over 15 years the two most important things I've discovered are that 1. Everything in MetaStock (apart from PREV) is purely sequential, and 2. most often there is more than one solution to every problem. If you have the ability to write DLLs then you can create solutions that are way beyond the ordinary user. For the rest of us, however, we must forget what we think we know about other programming languages, and then focus on what can be done with MetaStock rather than what can't. So pack your code into 1, 2 or however many indicators you need and figure out how to get your sequence of functions into its proper order. Roy
btconnolly  
#3 Posted : Sunday, April 5, 2015 12:42:51 PM(UTC)
btconnolly

Rank: Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/25/2005(UTC)
Posts: 12

Thanks for your thorough answer.  So I can get my head around it....

I think what you are saying in my option #2 example is I must make my formula choose whether to multiply by -1 or not as each bar is built going forward.  In other words, within a (non-DLL) formula, there's no way to multiply all previous values by -1 or +1 on any given day so the line representing a formula appears on a chart as inverted or not?

And this is also not possible by referencing one indicator formula to affect the entire set of values of another indicator?

I'm assuming also that 'axis inversion' must be done manually and cannot be adjusted with formula language?  Thanks.

Edited by user Sunday, April 5, 2015 1:03:59 PM(UTC)  | Reason: Not specified

mstt  
#4 Posted : Sunday, April 5, 2015 8:47:36 PM(UTC)
mstt

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 nt I'm not clear on what you're trying to achieve with "axis inversion", but lets suppose that your indicator generates a signal that swings between extremes of +100 and -100 (and all areas in between). You cannot then somehow go back and modify the indicator so that it inverts itself and then plots negative rather than positive at certain points, or vice versa. What you can do is call that indicator using the Fml() function (in a new indicator), and then use the new indicator to invert the value of the original indicator by applying appropriate logic. Or you can build the reversing element into the original indicator once the basic result has been created. As far as I'm aware there's no way to invert the Y axis of any chart, or for that matter reverse the X axis. But you do have control over your custom indicators. Try flow-charting the steps that your procedure needs to take. Such a chart cannot loop back on itself, but decisions to take a different path towards a final result are allowed. Branches back to an earlier point in the sequence, however, are not possible. I'm not sure if this all this is helpful as I'm struggling to understand the situation you're trying to work through. Roy
btconnolly  
#5 Posted : Wednesday, April 8, 2015 1:32:37 PM(UTC)
btconnolly

Rank: Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/25/2005(UTC)
Posts: 12

Using look-back formulas to change another formula on a going-forward basis sometimes creates an artificial result that I was trying to avoid.

I simply want to view the original formula right side up/down based on today's 15 day positive/negative correlation.  

There's a reason why MS has the "Invert Scale" feature in the Y Axis properties.  I was hoping I could trigger that with formula language instead of manually.  Or by applying an inversion formula on a 'going backward' basis (appliying the inversion to the last 15 days or for the entire chart).  

Sounds like no but many thanks for all your help. 
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.