Page 1 of 1

Confluence strategy - could someone make it compile please

Posted: 31 Jul 2008
by efgh622
Hello, Could someone make this code compilable into MC please:

Re: Confluence strategy - could someone make it compile plea

Posted: 01 Feb 2009
by TJ
Hello, Could someone make this code compilable into MC please:

Code: Select all

[LegacyColorValue = TRUE];

{**** 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 next bar at Lstop stop;
if (Lexit <> 0) then sell next bar at Lexit stop;
if (Sstop <> 0) then sellshort next bar at Sstop stop;
if (Sexit <> 99999) then buytocover next bar at Sexit stop;

Posted: 01 Feb 2009
by Tresor
Thank you TJ :D

I do not know what this forum would be like without you.

Reagrds

Posted: 01 Feb 2009
by TJ
sorry I did not notice this thread earlier.

;-)

Posted: 02 Feb 2009
by Tresor
sorry I did not notice this thread earlier.

;-)
No problem,

''Better late than never'' - a grandma said once when she arrived at the train station and missed her last train :lol: