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

Re: attention maths gurus



PureBytes Links

Trading Reference Links

Cameron,

>Here is my problem , i am backtesting a new system , but i need to calculate
>the closing price of tomorrow that would make the close of tomorrow be under
>the average close of two days ago.

Easy.  The maximum close of tomorrow is simply the close of
yesterday.  If tomorrow closes at yesterday's close, the
2-day average will be the same.  The formula you want is
MaxTomorrowClose=Close[1].

Generalizing, averages are the same as sums (only difference is a
scaling factor 1/N).  You want the sum of the last N closes to be
the same as the sum of the last N-1 closes plus the next close.
The only difference between sum(close,N) and sum(close,N-1) is
close[N-1].  So naturally if you remove close[N-1] from your average
(in your case N=2), then to get the same average you have to add
it back in.  So your future close is simply the one you removed,
close[N-1].

To use your example:

>close[3] = 1000
>close[2] = 1010
>close[1] = 1020
>close today = 1030
>
>what would be the close of tomorrow to make the close of tomorrow <
>average(close,2) ?

Average(close,2) is 1025,  that is 0.5*(1020+1030).

N=2 so close[N-1] = close[1] = 1020.

This is the maximum next close that you want.  If it closes there,
then average(close,2) will still be 1025.


-- 
  ,|___    Alex Matulich -- alex@xxxxxxxxxxxxxx
 // +__>   Director of Research and Development
 //  \ 
 // __)    Unicorn Research Corporation -- http://unicorn.us.com