Distance between current global max and local min

  • Thread starter Thread starter Stan Bauer
  • Start date Start date
S

Stan Bauer

May I please ask for your kind help?

I need to calculate the difference between
the current global maximum and the current Local minimum
that occurs After the global maximum.

If I have the data in column A, I need the answer in
column B to look the following way:


Row A B Comments
1 1
2 5
3 7
4 10 <- 10=Current Global Maximum [C.G.Max]
5 9
6 6 4 <- 6=C.G. Minimum
7 9
8 17
9 21 <- 21=New C.G. Max, but columnB is
not equal to (21-6)! The minimum must occur After the
Current Global maximum.

10 14
11 11
12 10
13 9 12 <- 9=New Current local min
14 10

Are there any Excel functions that could help me solve
this problem?

Thank you! I would truly appreciate any suggestions about
this problem.

Regards


Stan
 
If you could please explain more clearly the exact logic
you are trying to execute, I'd be happy to help.. I love a
good puzzle...
 
Hello Rob
If you could please explain more clearly the exact logic
you are trying to execute, I'd be happy to help..

Thank you!
I love a good puzzle...

So do I, but I just can't figure this one out.

I am a grad student. For my research, I need to obtain
the simulated distribution of the *Maximum retracement*
from the
maximum of a stochastic process. So, given a series of
numbers
[the first number is located in A1 and the last number is
located
in column A, row T], at every time t [every row t], we
need to calculate the
maximum of cells ($A$1 : A(T) {A(T) is my notation for the
cell in row t, column A}).

Suppose that at time t*, we observe a "Global Maximum" {in
cell A(t*)}.
This means that if t>t*, all values in the range A(1):A
(t* - 1)
AND the values in the range A(t* + 1):A(t) are smaller
than the value
in cell A(t*). Thus, on day t, the value in A(t*) gives
us the
maximum "up until now" [=day t].

Since we are interested in the retracement, we need to
find a Minimum that
takes place AFTER the day/row t*. Let X = max(A(1):A(t))
and let
N = min(A(t*):A(t)). On every day [on day t], we
calculate the quantity
X-N.

In my example below, t=14. This means that at time 14, we
look back and fill
in the appropriate values in column B:

Row A B Comments
1 1
2 5
3 7
4 10 <- 10=Current Global Maximum
C.G.Max]
5 9
6 6 4 <- 6=C.G. Minimum
7 9
8 17
9 21 <- 21=New C.G. Max, but columnB is
not equal to (21-6)! The minimum must occur After the
Current Global maximum.

10 14
11 16 <- I have just changed the value in A11!
12 10
13 9 12 <- 9=New Current local min
14 10

we need to leave cells B1:B4 blank, because on days 1-4,
we didn't
observe a minimum Following a maximum.

We need to leave cell B5 blank, because the value in
A5=A5=9
is not a local minimum [!!]. We need for this to be a
local minimum, because if you recall
we are interested in the "*Maximum retracement*" [please
see above].

Cell B6 gives us what we are looking for - the maximum
retracement
from the Global Maximum [10] to the local minimum that
follows it [6],
is 4.

In row 9, we obtain a new Global maximum. Thus, we need a
to find
a local minimum that occurs below row 9, before we can
write anything in
column B.

It is important that we don't write the value in cell B10.
This is because for Each Global Maximum, we must have only
One value for
the retracement [we are interested in the *Maximum
Retracement*].

Since t=14 [i.e. "today" is day 14], we know that the
maximum retracement
from the max that had occured on day 9, was 12, because on
day 13,
A13=9 < A10, and so A13 is the min of the range (A10:A14)
= min
(A(t* +1):A(t)).


*********
So, given T observations, we first find all local maximums
maximums, such that
on they day that they occur, they are the Global maximums
[i.e. if a Local maximum
occurs on day t, A(t) is a maximum of range A(1):A(t).

Suppose there are 3 of these maxes,
first max occurs on day t* and the second max occurs on
day t**, and the third
occurs on day t***.
[thus, it follows that A(t*)< A(t**)<A(t***)]

Then we find the local min during the time interval (t*,
t**), say it occurs
on day m*, t* < m* < t**
We record the quantity "=A(t*)-A(m*)" in cell B(m*).

Then we find the local min during the time interval (t**,
t***), which occurs
on day m**, t**< m* < t***

We record "A(t**)-A(m**)" in cell B(m**).

Lastly, we find the local min during the time interval
(t***, T)
that occurs on day m***, t*** < m*** < T

We record A(t***)-A(m***) in cell B(m***).

Of course, we need to be able to do this for any arbitrary
number of maximums
found in T simulated observations...
***********

I spent a lot of time with this problem, but my knowledge
of Excel functions
is just not sufficient to solve problems of this level of
complexity.

Thank you very much for considering this problem.

Regards


Stan
 
Stan,

Here's a function to find the global maximum and
puts "GM" in the cell. Put this in row B next to
your data. Note that it finds a max if it's the
largest value from 1 to * and is larger than * + 1.
Noticed that 17 wasn't a max in your example
ie in Cell B2:
=IF(AND(A2=MAX(A$1:A2),A2>A3), "GM","")
drag down

Here's a function that looks up the Min from GM*
to GM*+1
ie in Cell C2:
=IF(B2="GM",MIN(INDIRECT("A"&ROW()&
":A"&ROW()+MATCH("GM",B3:B26,0))),"")
drag down

This will put MAX* - MIN* in the cell next to the
max (I tried to get it next to the min, but it got a
little complicated)

=IF(AND(A9=MAX(A$1:A9),A9>A10), A9-
MIN(INDIRECT("A"&ROW()&":A"&ROW()+
MATCH("GM",B10:B33,0))),"")

Dan E

Stan Bauer said:
Hello Rob


Thank you!
CLIPPED
 
Those formulae should have been

=IF(AND(A2=MAX(A$1:A2),A2>A3), "GM","")

=IF(B2="GM",MIN(INDIRECT("A"&ROW()&
":A"&ROW()+MATCH("GM",B1:B$65,0))),"")


=IF(AND(A2=MAX(A$1:A2),A2>A3), A2-
MIN(INDIRECT("A"&ROW()&":A"&ROW()+
MATCH("GM",B1:B$65,0))),"")

Change the 65's to your own row #

Dan E
 
Thank you, Dan!

The location doesn't matter, I just needed [REALLY needed]
to obtain these numbers.

I have just completed doing this project - everything
worked beautifully!

G'd bless you, Dan! I hope you get back all of the
positive karma that you had generated with your help.

Best Wishes


Stan
 
Back
Top