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

Re: Projecting values needed to make indicators cross?


  • To: "Omega List" <code-list@xxxxxxxxxxxxx>
  • Subject: Re: Projecting values needed to make indicators cross?
  • From: "Peter Iovanella" <ivo1@xxxxxxxxx>
  • Date: Mon, 8 Feb 1999 11:34:27 -0500 (EST)

PureBytes Links

Trading Reference Links

Along the lines on my initial inquiry:

Below is a function I had in my directory which shows the algebraic logic
behind calculating an MACD Cross in the future, based on an article by
Gibbons Burke in Futures Magazine
 http://www.futuresmag.com/library/oct97/comptrdr.html ).  How should I
alter it to anticipate crosses in Stochastics, which don't use moving
averages?  The algebraic basis upon which the function is based is included
below.

Peter


{Function Name: MACDCross}

Inputs: Price(NumericSeries), FastPer(NumericSimple),
SlowPer(NumericSimple), SigPer(NumericSimple);
Vars: VarA(0), VarB(0), VarC(0), VarD(0), VarE(0), VarF(0), FastMA(0),
SlowMA(0), SigMA(0);

VarA = 2 / (FastPer + 1);
VarB = 1 - VarA;
VarC = 2 / (SlowPer + 1);
VarD = 1 - VarC;
VarE = 2 / (SigPer + 1);
VarF = 1 - VarE;
FastMA = XAverage(Price,FastPer);
SlowMA = XAverage(Price,SlowPer);
SigMA = XAverage(MACD(Price,FastPer,SlowPer),SigPer);

MACDCross = ((SigMA * VarF) + (FastMA * VarB * VarE) - (SlowMA * VarD *
VarE) - (FastMA * VarB) + (SlowMA * VarD)) /
    (VarA - VarC - (VarA * VarE) + (VarC * VarE));

{Algebraic basis for above:

FastMA - SlowMA = SignalMA
(FastMA - SlowMA)

(Nb + xa) - (Md + xc) = Sf + ((Nb +
xa) - (Md + xc))e

Nb + xa - Md - xc = Sf + Nbe +
xae - Mde - xce

xa - xc - xae + xce = Sf + Nbe - Mde -
Nb + Md

x = (Sf + Nbe - Mde - Nb + Md)/
(a - c - ae + ce), where

MACD = FastMA - SlowMA = Signal

Signal = EMA (FastMA - SlowMA)

x = price that will cause a crossover in the next period

N = latest "fast" average value

M = latest "slow" average value

S = latest "signal" (average of N - M)

a = smoothing factor for N

b = decay factor for N, or 1 - a

c = smoothing factor for M

d = decay factor for M, or 1 - c

e = smoothing factor for S

f = decay factor for S, or 1 - e}