[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EquisMetaStock Group] Re: Stuck In The Mud


  • Date: Mon, 14 Dec 2009 20:21:13 -0000
  • From: pumrysh <no_reply@xxxxxxxxxxxxxxx>
  • Subject: [EquisMetaStock Group] Re: Stuck In The Mud

PureBytes Links

Trading Reference Links

distinque,

Remember that the help file has tons of information. You can find it at the top left when your program is opened under the "help" icon.

Here's what it says about the If function:

The if() function is used to create conditional (i.e., "if-then") statements.  It is perhaps the most used function in the MetaStock formula language.  It contains three parameters as shown in the following example.
if( close > mov(c,10,s), rsi(9), rsi(14) )
The above "if" statement reads (in English) as follows:  If today's close is greater than today's 10-day simple moving average of the close, then plot a 9-day RSI, otherwise, plot a 14-day RSI.

The next formula plots "positive volume" if the close is greater than the median price.  Otherwise, "negative volume" is plotted.

if( CLOSE > (HIGH+LOW)/2, +V, -V )

A good example of the if() function can be found in the On Balance Volume example (see On Balance Volume).

If you simply want an expression to be evaluated as either true or false, it can be done without the use of the if() function.  The following formula will result in either a 1 (true) or a 0 (false).

rsi(14) > 70

If the 14-period RSI is greater than 70, then this formula will evaluate to "true" and return the number 1.  If it is below 70, the formula will evaluate to "false" and return the number 0.  This is done without the if() function being used.  The formula below uses the if() function and will return the same results, but it is longer.

if(rsi(14) > 70, 1, 0 )

------------------------------------------


So the syntax is If(condition,then,else)


Something like this works 

A:= HHV(HIGH,10);
If(a > Ref(a,-1),a,PREV)

or

A:= HHV(HIGH,10);
If(a > Ref(a,-1),a,Ref(a,-1));


but I don't know what you are using for Var1 or Var2 so I really have no way of telling if this is what you are looking for.

Also, using the prev function is really not the way to go as it slows down the calculation process. 

Hope this helps,

Preston





--- In equismetastock@xxxxxxxxxxxxxxx, "distinque" <distinque@xxx> wrote:
>
> I am working on bringing some of my MT4 code over to Metastock and have hit a snag (aka - Slow brain cell).
> 
> I need to reference a preceding varible value.  Current code is:
> 
> DSRR:=If(Ref(Var1, -1) > Ref(Var2, -1) AND Var1 < Var2, Var3 = HHV(HIGH,10),Problem Here);
> 
> I have tried
> Var3=PREV
> AND
> Var3 = Ref(Var3,-1)
> 
> Neither work.  I have also tried assigning a value before the if statement.  Does not work properly.
> 
> What I would like is to create a straight line the is based on the HHV for 10 days.  When the if statement fails I want the previous value of a rolling window which has the HHV for 10 days.  Basicly this should create a flat line that runs until the if statement is true and a new line level is set.
> 
> Thanks
>




------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/equismetastock/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/equismetastock/join
    (Yahoo! ID required)

<*> To change settings via email:
    equismetastock-digest@xxxxxxxxxxxxxxx 
    equismetastock-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    equismetastock-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/