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

Re: Need Help on If Function....



PureBytes Links

Trading Reference Links

Very good Dave !

    Your approch solves an old question : how to display an Expert X on a chart since a certain date and not on ALL the chart.

Merry Christmas to all,







Dave Nadeau a écrit :

> Ong,
>
> YES, you can plot an indicator that starts somewhere in the middle of your chart.
>
> To plot an indicator, Metastock will evaluate all variables within the expression and won't plot anything until each one is defined
> (i.e. "not null").  This can be an advantage or disadvantage, depending on what you are trying to do.  You can see this in action by
> plotting an indicator, say RSI(9) on a chart.  Look at bars 1-9.  There's no graph of the RSI because MetaStock can't calculate RSI(9)
> based on the data yet.
>
> So, in this case, by using a function which is not defined until later in the chart you can begin plotting an indicator anywhere you
> like, depending on how you set the definition of your variables.
>
> Here's an example:
>
> CUSTOM INDICATOR
>
> StartInd:=Cum(1)=50;
> StartPt:=ValueWhen(1,StartInd<>0,1);
> If(StartPt=1,RSI(9),0)
>
> This example uses number of bars to set the starting point.  You can adjust the "StartInd" to be equal to 150 or 300 or any value
> you'd like.
>
> Let's say you want to start the indicator when the close first crosses above 100:
>
> StartInd:=If(Close>100,1,0);
> StartPt:=ValueWhen(1,StartInd<>0,1);
> If(StartPt=1,RSI(9),0)
>
> Try these out on a plot, and you'll see that you can start your indicator anywhere you'd like.
>
> Dave Nadeau
> Fort Collins, CO
>
> Dave Nadeau
> Fort Collins, CO