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

Re: [EquisMetaStock Group] Stop loss



PureBytes Links

Trading Reference Links

Hi Roy,

I think I've finally got it!  If I have, then its thanks to your 
usual detailed response.

I understand EMA, so the answer hit me as soon as you explained the 
EMA example.  Just to verify that I now understand PREV, could you 
please confirm the following:

New_EMA = alpha*NewValue + (1-alpha)*Old_EMA;

is identical to

New_EMA = alpha*NewValue + (1-alpha)*PREV;

Regards,
Alan



--- In equismetastock@xxxxxxxxxxxxxxx, "Roy Larsen" <rlarsen@xxxx> 
wrote:
> Hi Alan
> 
> > I'll certainly try your ideas.  The only problem is that I don't
> > understand PREV. I submitted an earlier post asking how to 
determine
> > exactly what variable, formula, constant, data array, etc, etc, 
was
> > calculated by PREV.
> 
> PREV calls the previous bars value of the variable currently being 
processed. This allows decisions
> to be made based on current bar values relative to some readily 
defined past event.
> 
> Ref() calls the previous bars value of a data array or variable 
that has been defined PRIOR to the
> current variable being processed. Ref() cannot access a variable 
that has not been defined.
> Therefore you cannot use Ref() to call the current variable if this 
is the first definition of this
> variable. If this is not the first definition of this variable then 
Ref() is allowable, but only to
> call the previous value of the prior defininition, not the previous 
value of the current definition.
> 
> Defining a variable twice is an accepted method of overcomming the 
20 variable name limitation but
> it does not allow Ref() to be used in place of PREV.
> 
> MetaStock processes every bar and every variable in sequence. It 
can't "jump" in the processing
> flow. This makes MS very difficult to to come to grips with for 
programmers but simpler to use for
> non-programmers (up to a point). Think orderly sequence. PREV is a 
function that allows us to make
> processing decisions right now based on current status. Every other 
function can only react to
> things that have already happened in the processing flow, if not on 
a previous bar then in a
> previously processed variable.
> 
> 
> > I got only one response (suggesting I should use Ref() instead), 
so
> > it seems to me that other people also have difficulty in
> > understanding PREV.  Except you, of course :-).
> 
> I have my moments with it too.
> 
> > (As an aside, my inability to understand PREV hinders me in 
trying to
> > understand your Pegasus indicators, which are full of PREVs.  For
> > example:
> > X:=If(Cum(J>0)=1,K,ValueWhen(1,J,PREV)*(1-X)+K*X);
> > )
> 
> This variable is calculating a weekly exponential moving average. 
Somewhere in the User Manual it
> says that an EMA can't be calculated without PREV, and this is 
true. before trying to understand the
> above line you really need to tackle an EMA in a more simple form. 
Examine the following formula in
> conjunction with the EMA description in the manual.
> 
>   {Exponential Moving Average}
> n:=Input("Periods",1,999,7);
> R:=2/(n+1); {ratio of new data added each bar}
> M:=If(Cum(1)=1,C,PREV*(1-R)+C*R);
> M;
> 
> In a 7 period EMA 25% of the current value of CLOSE is added to 75% 
of the previous bars value of
> the EMA.
> 
> How do I arrive at 25%?  2/(7+1).  How do I arrive at 75%? 1 - 2/
(7+1). Change the value of "n" and
> you change the percentages/proportions, OK?
> 
> Now to the 'M' variable with PREV in it. The "If(Cum(1)=1,C," part 
says if this is bar one then
> "seed" the EMA with CLOSE. Failure to seed the variable on bar one 
will essentially force it to
> start with ZERO which is pretty stupid for an MA. Give it 100% of 
CLOSE on the first bar. If you
> think about it the 1 bar average of CLOSE has to be 100% of CLOSE.
> 
> The 'M' variable will not plot on bar one because the PREV function 
needs two bars before it can
> plot - the current bar and a previous bar. However on bar two the 
PREV function looks back to bar
> one and finds that, even though not plotted, the previous value 
of 'M' was CLOSE.
> 
> "PREV*(1-R)" is saying multiply the previous value of 'M' (CLOSE 
only if this is bar two, otherwise
> it is a composite) by 75%.
> "+C*R)" is saying add that to 25% of the current value of CLOSE.
> 
> Bar one sets a starting value for the EMA, and every subsequent bar 
adds a proportion (set by the
> number of period) of new data and retains the balance of the old 
data. The retained old data
> contains some of ALL old data, not just data looking back "n" 
periods.
> 
> PREV is a concept that takes most of us some time to get our heads 
around. Sooner or later you'll
> make the connection.
> 
> Regards
> 
> Roy



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com.  Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/BefplB/TM
---------------------------------------------------------------------~->

 
Yahoo! Groups Links

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

<*> 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/