Mechanically Recognizing Triangular Formations

 

Hello all,

Stocks & Commodities magazine March 2004 Volume 22:3 (24-38) shows an interesting article: 'Mechanically Recognizing Triangular Formations', by Giorgos Siligardos, Ph.D.

Who is willing to co-operate with us on the following:

1) code the original idea in MQL4 (and/or translate from MetaStock into MQL4), see explanation below.

2) make this into a system by adding more trading rules and risk parameters?

3) tune the system with artificial intelligence, in this case Support Vector Machines (SVM)?

Who are 'we'? We are a team of 5 professionals. Myself, discretionary futures trader (Eurostoxx, Bunds, 10+ years experience), one person being MSc. Management of Technology, Pre-Master Mechanical Engineering, one other person being Bsc. Electrical Engineering, Msc. Management of Technology, thesis ‘Prediction with Support Vector Machines’, a fourth person being a software engineer and trading analytics at one of the Top 5 high frequency trading firms in Amsterdam and a associate professor of Safety, Reliability and Probabilistic Methods at one of the Technical Universities in The Netherlands.

Where are we heading? Three quants, an associate professor and a discretionary trader combine their knowledge and produce a 100% quantitative trading model. The strategy is based on a proven market principle: volatility breakout. Markets go from high volatility to low volatility and back. We locate volatility regimes and trade the breakout by choosing direction. Mr. Siligardos' principle seems to be a nice starting point of the plan described above.

Are there any persons on this platform willing to work on this idea here in an open source environment? Are there any persons who understand MQL4 pretty well to translate MetaStock into MQL4? And/or read the article and code directly into MQL4?

If interested I can supply the original and complete article. Here is the code, below the code are BASIC STEPS OF THE ALGORITHM:

METASTOCK CODE FOR TPR EXPLORATIONS

—————————————————————————————

Use the code below as a filter to identify TFs that last up to 60 trading days and produce retracements of no more than 50%. In column A, write exactly the same code, but in the last line substitute “TPR>0” with “TPR.” You may also name column A as “TPR.” The code works with daily charts and requires the zz(20%) to have produced at least four swings in chart history to function properly. by Giorgos Siligardos.

Note: our market of choice is EURUSD, the pattern recognition should be scalable between several hours and several days, ZZ should therefore be between 0.1% and 1% as a first guess.

—————————————————————————————

{M ain}

zz:=Zig(C,20,%);

x:=Min(BarsSince(zz>Ref(zz,-1) AND Ref(zz,-1)<Ref(zz,-

2)),BarsSince(zz<Ref(zz,-1) AND Ref(zz,-1)>Ref(zz,-2)));

I:=LastValue(x)+1;

xM:=LastValue(I/2);

A:=LastValue( LinRegSlope(C,I ) );

{regression line}

reg:= A*x+LastValue(LinearReg(C,I))-A*(I-1);

{Up And Down Indicators}

day1:=LastValue(ValueWhen(1,x=0,DayOfMonth()));

Month1:=LastValue(ValueWhen(1,x=0,Month()));

year1:=LastValue(ValueWhen(1,x=0,Year()));

OK:=BarsSince(day1=DayOfMonth() AND month1=Month()

AND year1=Year())>=0;

down:=If(OK=False,0,If(Min(C-reg,0)=0,PREV,Min(C-reg,0)));

up:=If(OK=False,0,If(Max(C-reg,0)=0,PREV,Max(C-reg,0)));

{Slope of up and down indicators}

Id:=LastValue(Cum(Alert(OK AND C<reg,I)));

Iu:=LastValue(Cum(Alert(OK AND C>reg,I)));

downSlope:=Sum( (x-xM)*(down- LastValue(Sum(down,Id)/

Id)),Id)/Sum( (x-xM)*(x-xM),Id);

upSlope:=Sum( (x-xM)*(up- LastValue(Sum(up,Iu)/Iu)),Iu)/

Sum( (x-xM)*(x-xM),Iu);

{Short Term Swings}

SS:=Sum(If(Cross(Mov(C,5,S),reg),1,0)+If(Cross(reg,Mov(C,5,S)),1,0),I-1);

{Max Retracement}

retr:=Max(Abs(C-HHV(C,I+1)),Abs(C-LLV(C,I+1)))

/Abs(ValueWhen(2,x=0,C)-ValueWhen(1,x=0,C))*100;

{Volume slope}

VolSlope:=Sum( (x-xM)*(V- LastValue(Sum(V,I)/I)),I)/Sum(

(x-xM)*(x-xM),I);

{TPR Formula }

TPR:=

If(I>=10 AND I<=60 AND downSlope>0 AND upSlope<0 AND

retr<50 AND

SS>=3,

{Time}

If(I>=15 AND I<30,2,0) +

If(I>=30 AND I<=55,1,0) +

{r^2}

If(RSquared(C,I)<0.2,2,0) +

If(RSquared(C,I)>=0.2 AND RSquared(C,I)<0.5,1,0) +

{Max retracement}

If(retr<20,4,0) +

If(retr>=20 AND retr<38,3,0) +

{Volume}

If(VolSlope<0,4,0)+1,0);

TPR>0

STEP 1:

Locate the last point of zz(20%) and label it Γ . Locate the last bending of zz(20%) before Γ and label it B. Locate the last bending of zz(20%) before B and label it A.

STEP 2:

Generate a linear regression line for the time period that the leg ΒΓ lasts and name it reg. Generate the Up and Down indicators of the closing price based on reg for this period.

STEP 3:

Let C A and C B be the closing prices at points A and B, respectively, and let C be the indicator of closing prices. Define the height of the formation as the maximum value of the indicator  C B –C  during ΒΓ . (Note:  x  symbolizes the absolute value of x.) The percent retracement produced by the formation is then defined.

STEP 4:

Define the SS number to be the number of crossings of the five-period simple moving average of closing price through the regression line during the time span of ΒΓ .

STEP 5: The market movement between points B and Γ is identified as a triangular formation (TF) when all of the conditions below are satisfied:
• The slope of the linear regression line of the Up indicator
is negative and the slope of the linear regression line of
the Down indicator is positive.
• The time span between points B and Γ is between 10 and
60 trading days.
• SS>=3
• %retr<=50

 
All those credentials and you want someone else doing the work for free? As smart as you guys are, one of you should look through the documentations and code the EA within 8-hours flat. You can find cheap labor here.
 
ubzen:
All those credentials and you want someone else doing the work for free? As smart as you guys are, one of you should look through the documentations and code the EA within 8-hours flat. You can find cheap labor here.

Hello ubzen, not at all for free! This is an invitation to work with us, an invitation to join us. If it clicks from the beginning and if it all leads to something then I invite you to become a share holder of a company. Are you interested?
Reason: