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
You must be logged in to post a comment.
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.
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
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
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
Hi thanks, it better work on timeframe 1H
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 ?
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
Bonjour, comment faire fonctionner sous IG ? Je n'arrive pas a corriger le code. Merci pour votre aide
OKmerci
Matriciel tu est chez quel broker car avec IG malheureusement c'est mort avec les clôtures partiel. merci
The update code doesn't work.
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
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 ;)