+1 888 340 6572

# Oscillators > Confluence

Article/Author: Origin: Gary Fritz`s site.

File Includes:

Indicator - Confluence
Function - Derivativema
Function - Confluence
Strategy - Confluence

Category: Oscillators > Confluence

Description:

This is modified version of Dale Legan's "Confluence" indicator written by Gary Fritz.
================================================================
Here is Gary`s commentary:

* I moved the core Confluence computations into a Confluence function. Since the Confluence indicator returned several "states" (bull, bear, yellow, and zero), he 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.

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.

Have fun,
Gary
================================================================

Usage:

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.

Inputs:

Price - data series to calculate
Harmonic - value of harmonic

EasyLanguage Code:
```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");```