PureBytes Links
Trading Reference Links
|
The function DerivativeMA, as posted with the following EL code...
---------------------------------------------
Inputs: Price(numeric), Length(Numeric);
VARS: DERIV(0),SUMD(0),LENG2(0),N1(0),DR(0);
DERIV= (AVERAGE(Price,Length)*2) - AVERAGE(Price,Length)[1];
SUMD=Length*DERIV;
LENG2=length - 1 ;
N1= (AVERAGE(Price,LENG2))*LENG2;
DR=SUMD-N1;
DerivativeMA = DR;
--------------------------------------------
can be simplified to the following equivalent code...
--------------------------------------------
Inputs: Price(numeric), Length(Numeric);
DerivativeMA = Price - Price[Length] + Price[Length-1] ;
--------------------------------------------
We now see that it simply the current price reduced by the price change that occurred Length-1 bars ago. What is the rationale behind combining these two numbers?
Mark Jurik
http://www.jurikres.com
----------
From: A.J. Maas[SMTP:anthmaas@xxxxxxxxx]
Reply To: metastock@xxxxxxxxxxxxx
Sent: Saturday, March 25, 2000 8:19 AM
To: Metastock-List
Subject: Re: Confluence Indicator
Point to Word97 or higher and Save As .doc or .txt.
{or see the Guiness Book of Records awarded "the largest indicator (or BOOK)" below}
Regards,
Ton Maas
ms-irb@xxxxxxxxxxxxxxxx
Dismiss the ".nospam" bit (including the dot) when replying.
Homepage http://home.planet.nl/~anthmaas
----- Original Message -----
From: "M. Robb" <robb@xxxxxxxxxxxx>
To: <metastock@xxxxxxxxxxxxx>
Sent: zaterdag 25 maart 2000 10:21
Subject: Re: Confluence Indicator
> Thank Walter.
>
> The formula download was unreadable. To open, it wanted a choice of program.
> Word Pad didn't help. I'll try again.
=========================================================
***NOTE: I posted the following to the Omega List back in 1998.
This is the SUM TOTAL of my knowledge about Dale Legan's "Confluence"
indicator. I do not have ANY further background or understanding
about what Dale was trying to accomplish, and Dale has apparently
disappeared. If you're interested in this and want more information,
you're on your own.
================================================================
Hi O-listers,
I'm glad to see that the list seems to be getting back to a few
trading discussions. In the hopes of sparking a bit more trading
discussion and less bashing, I'm appending some code I've been
playing with using Dale Legan's recently-posted Confluence indicator.
Thanks for sharing this with us, Dale, and I hope you come through
your surgery OK.
I've done several things:
* I moved the core Confluence computations into a Confluence function.
Since the Confluence indicator returned several "states" (bull, bear,
yellow, and zero), I modified the return value a bit:
-9 to -1 = Bearish
-0.9 to 0.9 = "yellow" (and zero)
1 to 9 = Bullish
The "yellow" range corresponds to the "yellow" values plotted by Dale's
indicator, but they're divided by 10. So -0.4 is equivalent to "yellow
-4" in Dale's indicator.
* I got rid of a bit of extra computation in the function. I didn't try
to do a hard-core Pierre-style optimization :-), but I noticed several
significant chunks of calculation were being done several times each
bar, and I commented them out and replaced them with an intermediate
variable. It still calls sine/cosine a dozen times on each bar, which
accounts for the bulk of the processing time, but I think it's a bit
easier to understand what the code is doing this way. (It also seems to
work better -- see below.) For the most part I didn't try to use
mnemonic names for these intermediate variables, because I don't
understand exactly what the values represent!!
* I'm appending a simplified Confluence indicator using the function.
* I've also appended a simple Confluence system. This system sets an
entry stop above/below the current bar if Confluence goes into bull/bear
mode, and similarly sets an exit stop below/above the bar where it exits
bull/bear mode. There's also an optional "aggressive" stop mode that
tightens the stops if the market moves in your direction; for example,
if the high is 1000 and your "Trigger" offset is 2, the initial stop is
set at 1002. If the next bar has a high of 997, the stop is tightened
to 997+2=999.
The system has its MaxBarsBack property set to 150, which works for
values of Harmonic up to about 15. If you experiment with large values
of Harmonic, you will have to change MaxBarsBack to roughly 10*Harmonic.
Interestingly, when I first wrote this system, I ran into a strange
MaxBarsBack problem. The Confluence indicator worked just fine with a
MaxBarsBack setting of "Auto-Detect." But systems don't have a setting
like that -- you have to specify a fixed value. But NO fixed value (up
to the maximum of 999) worked for either the system OR the indicator!
And I couldn't see anywhere that it was looking back that many bars.
Then, when I did the optimization on the Confluence code, the
MaxBarsBack problem mysteriously disappeared. Sometimes TradeStation is
just spooky... Any ideas what happened?
I've appended a sample system report for the system on SPX, using the
default parameters. The system actually does pretty well. It probably
won't make anyone rich, but I thought some folks might enjoy playing
with it. There are some other things you could do with it -- e.g. it
might be interesting to change it to look for long opportunities when
Confluence hits -9, and short when it hits 9. If I get a chance to
throw that together, I'll post it to the list.
The ELA code is appended (assuming it makes it through the list's size
filters). The source and the ELA are also available in my FTP
directory, ftp://ftp.frii.com/pub/fritz .
Have fun,
Gary
================================================================
{Function: Confluence
Returns a value from -9 to +9.
-9 to -1: bearish
-0.9 to +0.9: "yellow"
1 to 9: bullish
Written by Dale Legan <dlegan@xxxxxxxxx>
}
Input: price(Numeric),Harmonic(Numeric);
vars: STL(0),ITL(0),LTL(0),HOFF(0),SOFF(0),IOFF(0),LTOFF(0),Phase(1);
vars: mtl(0),momsig(0),mom(0),HT(0),HTA(0);
vars: ST(0),STA(0),IT(0),ITA(0),SUM(0),ERR(0),ERRSUM(0),ERRSIG(0),TC(0),TCSIG(0);
vars: ERRNUM(0),MOMNUM(0),TCNUM(0);
Vars: Havg(0), Savg(0), Iavg(0), Lavg(0);
{Calculate Lengths}
if (BarNumber = 1) then begin
MTL=harmonic/2;
STL= IntPortion((harmonic*2)-1); {11}
ITL= IntPortion((STL*2)-1); {21}
LTL= IntPortion((ITL*2)-1); {41}
HOFF=intportion(harmonic/2); {3}
SOFF=intportion(STL/2); {5}
IOFF=intportion(ITL/2); {10}
LTOFF=intportion(LTL/2); {20}
end;
{ Averages }
Havg = average(price, Harmonic);
Savg = average(price, STL);
Iavg = average(price, ITL);
Lavg = average(price, LTL);
{Cycle Momentum}
value2 = Savg - Havg[HOFF];
value3 = Iavg - Savg[SOFF];
value12 = Lavg - Iavg[IOFF];
momsig = value2 + value3 + value12; {Momentum Signal Line}
value5= ((summation(price,harmonic-1) + derivativema(price,harmonic))/harmonic);
value6= ((summation(price,STL-1) + derivativema(price,STL))/STL);
value7= ((summation(price,ITL-1) + derivativema(price,ITL))/ITL);
value13=((summation(avgprice,LTL-1) + derivativema(price,LTL))/LTL);
value9 = value6 - value5[HOFF];
value10=value7 - value6[SOFF];
value14=value13 - value7[IOFF];
mom = value9 + value10 + value14;
{ harmonic =6 was 5 may use harmonic -1 }
{
HT= sine((summation(price,(harmonic-1))+derivativema(price,harmonic))/harmonic) +
cosine((summation(price,(harmonic-1))+derivativema(price,harmonic))/harmonic);
}
HT = sine(value5) + cosine(value5);
HTA= sine(Havg) + cosine(Havg);
{
ST= sine((summation(price,(STL-1))+derivativema(price,STL))/ STL) +
cosine((summation(Price,(STL-1))+derivativema(Price,STL))/STL);
}
ST = sine(value6) + cosine(value6);
STA = sine(Savg) + cosine(Savg);
{
IT= sine((summation(price,(ITL-1))+derivativema(c,ITL))/ITL) +
cosine((summation(price,(ITL-1))+derivativema(Price,ITL))/ITL);
}
IT = sine(value7) + cosine(value7);
ITA=sine(Iavg)+ cosine(Iavg);
Sum= HT+ST+IT; {Est in Cyc Estimator/ Cycle Est Err = Sum - Err }
Err =HTA + STA +ITA;
{phase detect}
Condition2= (Sum > Sum[SOFF]
and Havg < Havg[SOFF])
OR (Sum < Sum[SOFF]
and Havg > Havg[SOFF]) ;
Phase=1;
if Condition2 then Phase=-1;
ErrSum = (Sum - Err)*phase; { ERROR OF THE CYCLE}
ErrSig=average(ErrSum,SOFF); { ERROR SIGNAL LINE}
{Trend Catcher}
value68=value5;
{( (summation(price,(harmonic-1)) + derivativema(price,harmonic)) / harmonic );}
value69=value13;
{( (summation(avgprice,(LTL-1)) + derivativema(price,LTL)) / LTL );}
value70 = value68-value69; { EST W Der}
value71 = average(value70,Harmonic);
TC =value70;
TCSig=value71;
{Begin Counting Bars}
If ErrSum > 0 then begin
if Errsum < ErrSum[1] and ErrSum < ErrSig then ErrNum=1;
If ErrSum <ErrSum[1] and ErrSum >ErrSig then ErrNum=2;
If ErrSum>ErrSum[1] and ErrSum<ErrSig then ErrNum=2;
If ErrSum > ErrSum[1] and ErrSum> ErrSig then ErrNum=3;
End;
If ErrSum < 0 then begin
if Errsum > ErrSum[1] and ErrSum > ErrSig then ErrNum=-1;
If ErrSum <ErrSum[1] and ErrSum >ErrSig then ErrNum=-2;
If ErrSum>ErrSum[1] and ErrSum<ErrSig then ErrNum=-2;
If ErrSum < ErrSum[1] and ErrSum< ErrSig then ErrNum=-3;
End;
If Mom > 0 THEN begin
if mom < mom[1] and mom < momsig then momNum=1;
If mom <mom[1] and mom >momsig then momNum=2;
If mom>mom[1] and mom<momsig then momNum=2;
If mom > mom[1] and mom> momSig then momNum=3;
End;
If mom < 0 then begin
if mom > mom[1] and mom > momSig then momNum=-1;
If mom <mom[1] and mom >momSig then momNum=-2;
If mom>mom[1] and mom<momSig then momNum=-2;
If mom < mom[1] and mom< momSig then momNum=-3;
End;
If TC > 0 THEN begin
if TC < TC[1] and TC < TCsig then TCNum=1;
If TC <TC[1] and TC >TCsig then TCNum=2;
If TC>TC[1] and TC<TCsig then TCNum=2;
If TC > TC[1] and TC> TCSig then TCNum=3;
End;
If TC < 0 then begin
if TC > TC[1] and TC > TCSig then TCNum=-1;
If TC <TC[1] and TC >TCSig then TCNum=-2;
If TC>TC[1] and TC<TCSig then TCNum=-2;
If TC < TC[1] and TC< TCSig then TCNum=-3;
End;
value42= ErrNum + MomNum+TCNum;
Confluence = 0;
IF value42 >0 and TC >0 THEN Confluence = Value42; { Bullish }
IF value42<0 and TC < 0 THEN Confluence = Value42; { Bearish }
If (value42 > 0 and tc <0) or (value42 <0 and tc>0) then Confluence = Value42 / 10;
================================================================
{ Function: Derivativema -- used by Confluence function }
Inputs: Price(numeric), Length(Numeric);
VARS: DERIV(0),SUMD(0),LENG2(0),N1(0),DR(0);
DERIV= (AVERAGE(Price,Length)*2) - AVERAGE(Price,Length)[1];
SUMD=Length*DERIV;
LENG2=length - 1 ;
N1= (AVERAGE(Price,LENG2))*LENG2;
DR=SUMD-N1;
DerivativeMA = DR;
================================================================
{ Indicator: Confluence }
Input: price(close),Harmonic(10);
Vars: Conf(0);
Conf = Confluence(price, Harmonic);
IF Conf >= 1 THEN Plot1(Conf, "Bull");
IF Conf <= -1 THEN Plot2(Conf,"Bear");
If (Conf = 0) then Plot4(0,"ZERO")
else If (Conf > -1) and (Conf < 1) then Plot3(10*Conf, "Yellow");
================================================================
{**** System: Confluence ****}
{
Based on Dale Legan's Confluence indicator that was posted to
the Omega list in November 1998. See the Confluence function
to see how the Conf oscillator is calculated.
Inputs:
Price: Price to use in the Confluence calculations.
Harmonic: Seems to be an estimate of the dominant cycle length?
Trigger: System buys/sells Trigger points above/below the bar
where Confluence goes bullish/bearish. When the
Confluence drops out of bullish/bearish mode, the system
sets an exit stop Trigger points below Low / above High.
AggStops: If true, the system tightens its stops if the market
moves in your direction. E.g. if High is 1000 and
Trigger is 2, initial long stop is set at 1002.
If the next bar has a high of 999, stop is moved to 999.
}
{ These default input values seem to work well on 30-min SPX }
inputs: Price(Close), Harmonic(4), Trigger(5), AggStops(False);
Vars: Conf(0), Signal(0), Lstop(99999), Lexit(0), Sstop(0), Sexit(99999);
{ Is the indicator in bull/bear mode? }
Conf = Confluence(Price, Harmonic);
Signal = 0;
if (Conf >= 1) then Signal = 1; {bull}
if (Conf <= -1) then Signal = -1; {bear}
{ Set entry stops when indicator first moves into bull/bear mode }
if (Signal = 1) and (Signal[1] <> 1) then begin
Lstop = High + Trigger;
Lexit = 0;
end;
if (Signal = -1) and (Signal[1] <> -1) then begin
Sstop = Low - Trigger;
Sexit = 99999;
end;
{ Set exit-position stops when indicator leaves bull/bear state }
if (Signal <> 1) and (Signal[1] = 1) then begin
Lexit = Low - Trigger;
Lstop = 99999;
end;
if (Signal <> -1) and (Signal[1] = -1) then begin
Sexit = High + Trigger;
Sstop = 0;
end;
{ Aggressive stops: move them if mkt moves in our direction }
if AggStops then begin
if (Lstop <> 99999) then Lstop = MinList(Lstop, High + Trigger);
if (Lexit <> 0) then Lexit = MaxList(Lexit, Low - Trigger);
if (Sstop <> 0) then Sstop = MaxList(Sstop, Low - Trigger);
if (Sexit <> 99999) then Sexit = MinList(Sexit, High + Trigger);
end;
{ Clear stops when our price is hit }
if (H > Lstop) then Lstop = 99999;
if (L < Lexit) then Lexit = 0;
if (L < Sstop) then Sstop = 0;
if (H > Sexit) then Sexit = 99999;
{ Issue the buy/sell order on each bar until price is hit }
if (Lstop <> 99999) then buy at Lstop stop;
if (Lexit <> 0) then exitlong at Lexit stop;
if (Sstop <> 0) then sell at Sstop stop;
if (Sexit <> 99999) then exitshort at Sexit stop;
Attachment Converted: "f:\eudora\attach\RE Confluence Indicator (simpl"
|