Matriciel

EURUSD 15-minutes timeframe Dhigh / Dlow Strategy

Category: Strategies By: Matriciel Created: July 11, 2019, 10:07 AM
July 11, 2019, 10:07 AM
Strategies
61 Comments
EURUSD 15-minutes timeframe Dhigh / Dlow Strategy

Hello everyone,

I wanted to share with you a strategy that works on the EUR / USD instrument in 15 minutes timeframe.
I have set up a partial position closure but unfortunately it still does not work in real time.

There is something that is problematic for me, some positions last very long time on the market and pay attention to overnight charges!

Good trades!

DEFPARAM CumulateOrders = False
DEFPARAM PRELOADBARS = 10000

daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0

Horaire = time >= 000000 and time <= 200000

CloturePartielle = 1
PositionsizeA = 1
PositionsizeV = 1

IF CloturePartielle THEN
PositionsizeA = 4
PositionsizeV = 3
ENDIF

MM = Average[56,3](totalprice)

Newhighest=0
FOR a = 0 TO 1 DO
 IF DHigh(a)>Newhighest or Newhighest=0 THEN
  Newhighest = DHigh(a)
 ENDIF
NEXT

Newlowest=0
FOR b = 0 TO 1 DO
 IF DLow(b)<Newlowest or Newlowest=0 THEN
  Newlowest = DLow(b)
 ENDIF
NEXT

Milieu = (Newhighest+Newlowest)/2
Surachat = average[10,4]((Newhighest+Milieu)/2)
Survente = average[10,4]((Newlowest+Milieu)/2)

CA = (MM > Surachat) and (close crosses over Milieu)
CV = (MM < Survente) and (close crosses under Milieu)

// Long Entries
IF Horaire AND CA AND not daysForbiddenEntry AND NOT SHORTONMARKET THEN
 BUY PositionsizeA CONTRACTS AT MARKET
ENDIF

IF CloturePartielle THEN
 IF LONGONMARKET THEN
  SELL 1 CONTRACTS AT TRADEPRICE + 40*pointsize LIMIT
 ENDIF

 IF LONGONMARKET THEN
  SELL 1 CONTRACTS AT TRADEPRICE + 20*pointsize LIMIT
 ENDIF

 IF LONGONMARKET THEN
  SELL 1 CONTRACTS AT TRADEPRICE + 18*pointsize LIMIT
 ENDIF
ENDIF

// Short Entries
IF Horaire AND CV AND not daysForbiddenEntry AND NOT LONGONMARKET THEN
 SELLSHORT PositionsizeV CONTRACTS AT MARKET
ENDIF

IF CloturePartielle THEN
 IF SHORTONMARKET THEN
  EXITSHORT 1 CONTRACTS AT TRADEPRICE - 40*pointsize LIMIT
 ENDIF

 IF SHORTONMARKET THEN
  EXITSHORT 1 CONTRACTS AT TRADEPRICE - 78*pointsize LIMIT
 ENDIF
ENDIF

//MFE
//trailing stop
trailingstop = 33
 
//resetting variables when no trades are on market
if not onmarket then
 MAXPRICE = 0
 MINPRICE = close
 priceexit = 0
endif
 
//case SHORT order
if shortonmarket then
 MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
  if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
   priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
  endif
 endif
 
//case LONG order
if longonmarket then
 MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
  if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
   priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
  endif
endif
 
//exit on trailing stop price levels
if onmarket and priceexit>0 then
 EXITSHORT AT priceexit STOP
 SELL AT priceexit STOP
endif

//SET TARGET pPROFIT 46
SET STOP pLOSS 200

Download
Filename: EURUSD-15mn-DhighDlowStrategy.itf
Downloads: 2400
Matriciel
Matriciel Master
Currently debugging life, so my bio is on hold. Check back after the next commit for an update.
Author’s Profile

Comments

Bibi83
3 years ago
#

Bonsoir à tous Je viens de backtest la stategie sur EUR/USD en graphique 1H sur 1 mois et demi Total : 13 trades Gagnant : 12 Neutre : 0 Perdant : 1 Resultat brut : - 40 Le trade perdant fait perdre la totalité des gains. Serait-il possible d'y ajouter un stop loss breakeven ? Par avance merci pour vos conseil ;)

bousalahane
4 years ago
#

Hi Rajesh Deshpande, Thank you for this code, I see that the code is perfect, but the positions stay in the market for a long time, do you calculate these fees or a way to put a stoploss.

Rajesh Deshpande
6 years ago
#

Updated the code which has now 100% winning rate in last 2yrs. Yes takes average 1 trade per month. This can work as in current IG. Doesnot require partial closure. DEFPARAM CumulateOrders = False MM = Average[20,3](totalprice) Newhighest=max(DHigh(0), DHigh(1)) Newlowest=min(DLow(0), DLow(1)) Milieu = (Newhighest+Newlowest)/2 Surachat = average[10,4]((Newhighest+Milieu)/2) Survente = average[10,4]((Newlowest+Milieu)/2) CA = (MM > Surachat) and (close crosses over Milieu) CV = (MM < Survente) and (close crosses under Milieu) // Long Entries IF CA AND NOT SHORTONMARKET THEN BUY 2 CONTRACTS AT MARKET ENDIF IF LONGONMARKET THEN SELL AT TRADEPRICE + 25*pointsize LIMIT ENDIF // Short Entries IF CV AND NOT LONGONMARKET THEN SELLSHORT 2 CONTRACTS AT MARKET ENDIF IF SHORTONMARKET THEN EXITSHORT AT TRADEPRICE - 65*pointsize LIMIT ENDIF

murre87
5 years ago
#

No Stoploss?

vinit0412
6 years ago
#

I tried using the above strategy but since IG doesnt allow partial closing of the positions. Handled the code in a different manner as was mentioned in one of the thread. Code is working fine and we can play it in LIVE too. Only issue is number of trades which was coming as 100 for 2 years is reduced to only 40 trades. Can anyone help to increase the number of trades. DEFPARAM CumulateOrders = False DEFPARAM PRELOADBARS = 10000 daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0 Horaire = time >= 000000 and time Newhighest or Newhighest=0 THEN Newhighest = DHigh(a) ENDIF NEXT Newlowest=0 FOR b = 0 TO 1 DO IF DLow(b) Surachat) and (close crosses over Milieu) CV = (MM =trailingstop*pointsize then //if the MFE is higher than the trailingstop then priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level endif endif //case LONG order if longonmarket then MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level endif endif //exit on trailing stop price levels if onmarket and priceexit>0 then EXITSHORT AT priceexit STOP SELL AT priceexit STOP endif //SET TARGET pPROFIT 46 SET STOP pLOSS 200

Eqscaper
6 years ago
#

Also just to let you know, im using PRT v10.3 as thats all IG allows at the moment... ive tried everything i can think of to recieve the data from probacktest but it keeps coming up blank even if i copy past the code, or if i import the ITF file directly

Eqscaper
6 years ago
#

Hi there Matriciel, great setup by the looks of things, ive imported the code and tried to run a backtest but for some reason its not coming up with any results, its simply showing 0.0 % and n/a - n/a ... i changed the CloturePartielle to 0 for PRT but still no data return Any ideas ? i imported via ITF file direct into PRT

pat95162
6 years ago
#

ça ne fonctionne pas pour moi

Franro
6 years ago
#

Marcus you run this?

Marcus Quartus Aurius
6 years ago
#

Hi thanks, it better work on timeframe 1H

fastsky
6 years ago
#

Hi, only with CloturePartielle=0 I get a positive result. Just, for I can't add it to automatic trading because it uses scaled positions.

Matriciel
7 years ago
#

Bonjour olivierrajzman, je suis d'accord avec toi. Les positions restent bien trop longtemps sur le marché; elles engendreront trop de frais overnight. Je ne l'ai jamais lancée en démo ni en live.

olivierrajzman
7 years ago
#

Bonjour Matriciel, merci pour cette stratégie, néanmoins je pense qu'elle ne serait pas rentable si on rajoute les frais de tenu nocturne chez le broker. l'as-tu deja lancer avec proorder sur un compte demo ou live ?

betocil
7 years ago
#

ligne 47 le close ne fonctionne pas: IF SHORTONMARKET AND COUNTOFLONGSHARES close[6]) = 32 THEN

Matriciel
7 years ago
#

Bonjour Florian, c'est un code qui tourne sur la plateforme ProRealTime.

Florian Legeard
7 years ago
#

Merci Matriciel ! Je cherche depuis quelques jours à améliorer ta stratégie ! Je pense il y a quelque chose à faire ! @juju333 a travaillé également dessus d’après ce que j’ai vu. Avez vous un what’s app Ou mail pour faire groupe de travail sur la stratégie ? A force je me perds sur le forum ... A + Flo

Florian Legeard
7 years ago
#

Bonjour, comment faire fonctionner sous IG ? Je n'arrive pas a corriger le code. Merci pour votre aide

Pinou De Rossi
7 years ago
#

OKmerci

Matriciel
7 years ago
#

Je suis chez IG. Je sais que la fonction des clôtures partielles n'est pas autorisée pour l'instant chez IG. Tu peux quand même utiliser ce code en désactivant cette fonction en mettant : CloturePartielle = 0

Pinou De Rossi
7 years ago
#

Matriciel tu est chez quel broker car avec IG malheureusement c'est mort avec les clôtures partiel. merci

juju333
7 years ago
#

Seems even greater with EURCAD :-). Many thanks for sharing it.

Matriciel
7 years ago
#

Ok, let's go ! :)

BobFlynn
7 years ago
#

I opened a topic to discuss this strategy, feel free to join in and submit improvments : https://www.prorealcode.com/topic/discussing-matriciel-eurusd-dhigh-dlow/

BobFlynn
7 years ago
#

Apparently slashes are removed from the copy paste <<

darbes
7 years ago
#

still a pb, even in line 47

Globalmarkets79
7 years ago
#

The update code doesn't work.

Matriciel
7 years ago
#

That's the piece of code to stick to instead of "Maxshares" MAXSHARES = abs(COUNTOFPOSITION) Surachat) and (close crosses over Milieu)

Matriciel
7 years ago
#

It's catastrophic, even the copied / pasted does not work!

CMM
CMM
7 years ago
#

Still a problem with this line "MAXSHARES = abs(COUNTOFPOSITION) Surachat) and (close crosses over Milieu) CV = (MM < Survente) and (close crosses under Milieu)" and I get "Surachat" marked. I'm so curious to try it. Any suggestion?

Matriciel
7 years ago
#

Hi all, This is the last version. Cheers. The "Add PRT code" button do not work ! :( DEFPARAM CumulateOrders = True DEFPARAM PRELOADBARS = 10000 daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0 Horaire = time >= 000000 and time <= 200000 CloturePartielle = 1// 1 = ON, 0 = OFF PositionsizeA = 1 PositionsizeV = 1 MAXSHARES = abs(COUNTOFPOSITION) Surachat) and (close crosses over Milieu) CV = (MM < Survente) and (close crosses under Milieu) // Long Entries IF Horaire AND CA AND MAXSHARES AND not daysForbiddenEntry AND NOT SHORTONMARKET THEN BUY PositionsizeA CONTRACTS AT MARKET ENDIF IF CloturePartielle THEN IF LONGONMARKET AND COUNTOFLONGSHARES <= 16 THEN SELL 1 CONTRACTS AT TRADEPRICE + 40*pointsize LIMIT ENDIF IF LONGONMARKET AND COUNTOFLONGSHARES <= 4 THEN SELL 1 CONTRACTS AT TRADEPRICE + 20*pointsize LIMIT ENDIF IF LONGONMARKET AND COUNTOFLONGSHARES <= 6 THEN SELL 1 CONTRACTS AT TRADEPRICE + 18*pointsize LIMIT ENDIF ENDIF IF LONGONMARKET AND summation[35](close < close[6]) = 35 THEN SELL AT MARKET ENDIF // Short Entries IF Horaire AND CV AND MAXSHARES AND not daysForbiddenEntry AND NOT LONGONMARKET THEN SELLSHORT PositionsizeV CONTRACTS AT MARKET ENDIF IF CloturePartielle THEN IF SHORTONMARKET AND COUNTOFSHORTSHARES <= 20 THEN EXITSHORT 1 CONTRACTS AT TRADEPRICE - 78*pointsize LIMIT ENDIF IF SHORTONMARKET AND COUNTOFLONGSHARES close[6]) = 32 THEN EXITSHORT AT MARKET ENDIF //MFE //trailing stop trailingstop = 33 //resetting variables when no trades are on market if not onmarket then MAXPRICE = 0 MINPRICE = close priceexit = 0 endif //case SHORT order if shortonmarket then MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level endif endif //case LONG order if longonmarket then MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level endif endif //exit on trailing stop price levels if onmarket and priceexit>0 then EXITSHORT AT priceexit STOP SELL AT priceexit STOP endif //SET TARGET pPROFIT 46 SET STOP pLOSS 200

ProRealCode ProRealCode
Loading...