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

Re: Coding problem with hypothetical close



PureBytes Links

Trading Reference Links

I'll tell you how to do it. I don't have the time to do it, though through
to completion.

The easiest way is to use the XAverage and set XAverage(c,40) =
XAverage(c,50); assume that when the averages are equal that it is a
crossover. But, this isn't a statement you can use in a program. This is an
algebra statement of sorts, you have to solve for the magic value x that
completes this. That takes some work, but is doable with mathematics. Go to
the function code for XAverage to get the math to solve for.
 Doing it with Average requires the use of an array to store the past
values. Suppose that y represents the sum of the past FLen - 1  values and x
is the sum of the SLen - 1 values prior to that then:

(y + c[0]) / FLen = (x + c[0]) / SLen ;

this simplifies to:

c[0] = (x(Flen/SLen) - y)/(1 - FLen/ SLen) ;

Using arrays for x and y solves the problem.  I've left the variables
generic to ease in op-timization. This equation solves for the Close of the
current bar that is desired to meet this criteria. You wouldn't want to use
C[0] in your code as it would confuse the compiler.

Jim Bronke
Phoenix, AZ



----- Original Message -----
From: "Van Oayda" <van@xxxxxxxxxxxx>
To: <omega-list@xxxxxxxxxx>
Sent: Tuesday, October 02, 2001 4:04 PM
Subject: Coding problem with hypothetical close


:
:
: Hi all,
: I wanted to see if you would be able to help me with a problem.
: I want to write an indicator that will show what price a market must close
: at for a moving average to crossover.
: eg average(c,40) > average(c,50) what price does the market have to close
at
: for the average(c,40) < average(c,50).
: Is that possible in TS. Is it hard to do??
:
: Thanks in advance,
:
: Van
:
:
: