Confluence strategy - could someone make it compile please
Confluence strategy - could someone make it compile please
Hello, Could someone make this code compilable into MC please:
- 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
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;
- TJ
- Posts: 7742
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times