Confluence strategy - could someone make it compile please

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
efgh622
Posts: 1
Joined: 26 Jul 2008

Confluence strategy - could someone make it compile please

Postby efgh622 » 31 Jul 2008

Hello, Could someone make this code compilable into MC please:

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Confluence strategy - could someone make it compile plea

Postby TJ » 01 Feb 2009

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;

Tresor
Posts: 1104
Joined: 29 Mar 2008
Has thanked: 12 times
Been thanked: 53 times

Postby Tresor » 01 Feb 2009

Thank you TJ :D

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

Reagrds

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Postby TJ » 01 Feb 2009

sorry I did not notice this thread earlier.

;-)

Tresor
Posts: 1104
Joined: 29 Mar 2008
Has thanked: 12 times
Been thanked: 53 times

Postby Tresor » 02 Feb 2009

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:


Return to “User Contributed Studies and Indicator Library”