We are happy to announce the MultiCharts Easter Sale! Learn more
+1 888 340 6572

Confluence

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

Download: conflu.ela

File Includes:
Strategy - Confluence
Indicator - Confluence
Function - Derivativema
Function - Confluence

Category: Strategy > Confluence

Description:
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 - 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.
NOTE: These default input values seem to work well on 30-min SPX

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