ProRealCode - Trading & Coding with ProRealTime™
Projet d’intelligence artificielle sur le Dow Jones en bougie de 10 minutes, il faudra bien vous régler sur 10 minutes ! J’ai tenté d’inculquer la réflexion et l’expérience du trader associé à des statistiques
defparam cumulateorders=false
defparam preloadbars = 500
n=1
perte=500
xx=69
rem yy=30
yy=30
J=350
pz=3
py=12
x=169
if (dayofweek=6 or dayofweek=7) or (time<091500 or time>203000) or (time>153000 AND time<160500)or (time>194500 AND time<195500) then
journee=0
else
journee=1
endif
if (highest[288](close)-close)>(close/80) or (highest[144](close)-close)>(close/85) then
sensvente=1
else
sensvente=1
endif
if (close-highest[288](close))>(close/80) or (close-highest[144](close))>(close/85) then
sensachat=0
else
sensachat=1
endif
if close>(highest[30](close)*0.99911) then
achatextrem=0
else
achatextrem=1
endif
if close<(lowest[36](close)*1.00041) then
venteextrem=0
else
venteextrem=1
endif
cloture=((highest[117](close)+lowest[117](close))/2)
if close<(cloture-50) then
cloturevente=0
else
cloturevente=1
endif
if time<140000 and close>(cloture) then
clotureachat=1
else
clotureachat=1
endif
stopventetemps=0
else
stopventetemps=1
endif
if (open[4]<close[4] and open[3]<close[3] and open[2]<close[2] and open[1]>close[1]) then
stopachattemps=1
else
stopachattemps=1
endif
ratio=4.6
gain2=(highest[14](close)-low)
if gain2<0 then
gain=(gain2*-1)/ratio
else
gain=gain2/ratio
endif
if gain>=22 then
gain=78
endif
if gain<=2.7 then
gain=2.8
endif
if gain>=2.8 and gain<=9.4 then
gain=94
endif
SET TARGET PROFIT gain
SET STOP LOSS perte
nombre=12
couleur=7
descente=0
for z=1 to nombre do
if open[z]>close[z] then
descente=descente+1
endif
next
if descente>=couleur then
achatbougie=0
else
achatbougie=1
endif
montee=0
for y=1 to nombre do
if open[y]<close[y] then
montee=montee+1
endif
next
if montee>=couleur then
ventebougie=0
else
ventebougie=1
endif
nombre2=7
couleur2=6
descente2=0
for z2=1 to nombre2 do
if open[z2]>close[z2] then
descente2=descente2+1
endif
next
if descente2>=couleur2 then
achatbougie2=0
else
achatbougie2=1
endif
montee2=0
for y2=1 to nombre2 do
if open[y2]<close[y2] then
montee2=montee2+1
endif
next
if montee2>=couleur2 then
ventebougie2=0
else
ventebougie2=1
endif
if open>highest[14](close) or open>(close[24]*1.014) then
achathaut=0
else
achathaut=1
endif
if open<lowest[17](close) or open<(close[24]/1.0028) then
ventebas=0
else
ventebas=1
endif
p=10
q=8
plusHaut = HIGHEST[p](HIGH)
plusBas = LOWEST[p](LOW)
oscillateur = (CLOSE - plusBas) / (plusHaut - plusBas) * 100
K = AVERAGE[q,6](oscillateur)
periode=34
innere = 2*weightedaverage[ round( Periode/2 ) ](close)-weightedaverage[Periode](close)
MM=weightedaverage[round(sqrt(periode))](innere)
if (close>close[50]*1.02) or (close>close[6]*1.002) or (onmarket and (tradeprice-close)>z) or ventebougie=0 or ventebougie2=0 or close<BollingerDown[20](close)+2 or ventebas=0 or cloturevente=0 or venteextrem=0 or sensvente=0 then
stopventecalcul=0
else
stopventecalcul=1
endif
if (close[50]>close*1.04) or (close[6]>close*1.005) or (onmarket and (tradeprice-close)<z) or achatbougie=0 or achatbougie2=0 or close>BollingerUp[20](close)+18 or achathaut=0 or clotureachat=0 or achatextrem=0 or sensachat=0 then
stopachatcalcul=0
else
stopachatcalcul=1
endif
i1=average[3](close)
c1=i1>i1[6]
if stopachattemps=1 and c1 and journee=1 and k<xx and mm[1]<mm and stopachatcalcul=1 then
buy n shares at market
endif
i2=average[3](close)
i3=average[5](close)
c2=i2 crosses under (I3-50)
if c2 and ((tradeprice-close)<pz) and (time>091000 and time<212000) then
sell at market
endif
periode2=18
innere2 = 2*weightedaverage[ round( Periode2/2 ) ](close)-weightedaverage[Periode2](close)
MM2=weightedaverage[round(sqrt(periode2))](innere2)
c3=i1<i1[6]
if c3 and journee=1 and k>yy and mm2[2]>mm2 and stopventecalcul=1 and stopventetemps=1 then
sellshort n shares at market
endif
c4=i2 crosses OVER (i3-10)
if c4 and (tradeprice-close)>pY and (time>091000 and time<212000) then
//if (i1[6]-i1)<15 then
exitshort at market
endif
if longonmarket and (BarIndex-TRADEINDEX)>j then
sell at market
endif
if shortonmarket and (BarIndex-TRADEINDEX)>j then
exitshort at market
endif
if longonmarket and (BarIndex-TRADEINDEX)>x and (close-tradeprice)>5 then
sell at market
endif
if shortonmarket and (BarIndex-TRADEINDEX)>x and (tradeprice-close)>5 then
exitshort at market
endif
Merci beaucoup pour le partage. J’ai volontairement basculé ton post vers le forum, j’aimerai en savoir plus sur le cheminement de l’élaboration de la stratégie, qui a vraiment piqué mon intérêt, merci.
J’ai tenté d’inculquer la réflexion et l’expérience du trader associé à des statistiques
Merci beaucoup cela semble très prometteur
Il manque une ligne entre 47 et 48, n'est-ce pas?
Bonjour à tous et merci pour votre intérêt partagé
En effet, il manque bien quelques lignes, une erreur de copier/coller, voici la version complète
Le cheminement est ultra complexe, je suis trader depuis 20 ans et j’ai souhaité transcrire ma façon de trader en algorithme
C’est en testant pendant longtemps que l’on voit qu’il fait des erreurs que l’on n’aurait pas faites et donc ensuite il faut trouver le moyen d’apprendre à l’algorithme à ne plus reproduire ces erreurs.
Cet algorithme, j’ai mis 10 mois pour le construire et il évoluera encore et encore.
L’intelligence artificielle m’intéresse et j’y travaille régulièrement.
Biensûr, il y a une faille, dans ce code par exemple, si on perd 550 points, celà fait une grosse perte mais il aura gagné bien + avant.
En général, les variations sont inférieures mais rien ne nous empêche de prévoir une perte supérieure mais dans ce cas on peut se retrouver coincé un moment et perdre + d’argent que de prendre une perte de 550 points et de repartir.
A votre disposition pour échanger et bon week-end à vous tous.
Yann.
defparam cumulateorders=false
defparam preloadbars = 500
n=1
perte=550
xx=69
yy=30
J=350
pz=3
py=12
x=169
if (dayofweek=6 or dayofweek=7) or (time<091500 or time>203000) or (time>153000 AND time<160500)or (time>194500 AND time<195500) then
journee=0
else
journee=1
endif
if (highest[288](close)-close)>(close/80) or (highest[144](close)-close)>(close/85) then
sensvente=1
else
sensvente=1
endif
if (close-highest[288](close))>(close/80) or (close-highest[144](close))>(close/85) then
sensachat=0
else
sensachat=1
endif
if close>(highest[30](close)*0.99911) then
achatextrem=0
else
achatextrem=1
endif
if close<(lowest[36](close)*1.00041) then
venteextrem=0
else
venteextrem=1
endif
cloture=((highest[117](close)+lowest[117](close))/2)
if close<(cloture-50) then
cloturevente=0
else
cloturevente=1
endif
if time<140000 and close>(cloture) then
clotureachat=1
else
clotureachat=1
endif
if (time>120000 and time<142500) or (time>100000 AND time<112000)or (time>175000 AND time<183000) or time>204000 or (open[4]>close[4] and open[3]>close[3] and open[2]>close[2] and open[1]<close[1]) then
stopventetemps=0
else
stopventetemps=1
endif
if (open[4]<close[4] and open[3]<close[3] and open[2]<close[2] and open[1]>close[1]) then
stopachattemps=1
else
stopachattemps=1
endif
ratio=4.6
gain2=(highest[14](close)-low)
if gain2<0 then
gain=(gain2*-1)/ratio
else
gain=gain2/ratio
endif
if gain>=22 then
gain=78
endif
if gain<=2.7 then
gain=2.8
endif
if gain>=2.8 and gain<=9.4 then
gain=94
endif
SET TARGET PROFIT gain
SET STOP LOSS perte
nombre=12
couleur=7
descente=0
for z=1 to nombre do
if open[z]>close[z] then
descente=descente+1
endif
next
if descente>=couleur then
achatbougie=0
else
achatbougie=1
endif
montee=0
for y=1 to nombre do
if open[y]<close[y] then
montee=montee+1
endif
next
if montee>=couleur then
ventebougie=0
else
ventebougie=1
endif
nombre2=7
couleur2=6
descente2=0
for z2=1 to nombre2 do
if open[z2]>close[z2] then
descente2=descente2+1
endif
next
if descente2>=couleur2 then
achatbougie2=0
else
achatbougie2=1
endif
montee2=0
for y2=1 to nombre2 do
if open[y2]<close[y2] then
montee2=montee2+1
endif
next
if montee2>=couleur2 then
ventebougie2=0
else
ventebougie2=1
endif
if open>highest[14](close) or open>(close[24]*1.014) then
achathaut=0
else
achathaut=1
endif
if open<lowest[17](close) or open<(close[24]/1.0028) then
ventebas=0
else
ventebas=1
endif
p=10
q=8
plusHaut = HIGHEST[p](HIGH)
plusBas = LOWEST[p](LOW)
oscillateur = (CLOSE - plusBas) / (plusHaut - plusBas) * 100
K = AVERAGE[q,6](oscillateur)
periode=34
innere = 2*weightedaverage[ round( Periode/2 ) ](close)-weightedaverage[Periode](close)
MM=weightedaverage[round(sqrt(periode))](innere)
if (close>close[50]*1.02) or (close>close[6]*1.002) or (onmarket and (tradeprice-close)>z) or ventebougie=0 or ventebougie2=0 or close<BollingerDown[20](close)+2 or ventebas=0 or cloturevente=0 or venteextrem=0 or sensvente=0 then
stopventecalcul=0
else
stopventecalcul=1
endif
if (close[50]>close*1.04) or (close[6]>close*1.005) or (onmarket and (tradeprice-close)<z) or achatbougie=0 or achatbougie2=0 or close>BollingerUp[20](close)+18 or achathaut=0 or clotureachat=0 or achatextrem=0 or sensachat=0 then
stopachatcalcul=0
else
stopachatcalcul=1
endif
i1=average[3](close)
c1=i1>i1[6]
if stopachattemps=1 and c1 and journee=1 and k<xx and mm[1]<mm and stopachatcalcul=1 then
buy n shares at market
endif
i2=average[3](close)
i3=average[5](close)
c2=i2 crosses under (I3-50)
if c2 and ((tradeprice-close)<pz) and (time>091000 and time<212000) then
sell at market
endif
periode2=18
innere2 = 2*weightedaverage[ round( Periode2/2 ) ](close)-weightedaverage[Periode2](close)
MM2=weightedaverage[round(sqrt(periode2))](innere2)
c3=i1<i1[6]
if c3 and journee=1 and k>yy and mm2[2]>mm2 and stopventecalcul=1 and stopventetemps=1 then
sellshort n shares at market
endif
c4=i2 crosses OVER (i3-10)
if c4 and (tradeprice-close)>pY and (time>091000 and time<212000) then
exitshort at market
endif
if longonmarket and (BarIndex-TRADEINDEX)>j then
sell at market
endif
if shortonmarket and (BarIndex-TRADEINDEX)>j then
exitshort at market
endif
if longonmarket and (BarIndex-TRADEINDEX)>x and (close-tradeprice)>5 then
sell at market
endif
if shortonmarket and (BarIndex-TRADEINDEX)>x and (tradeprice-close)>5 then
exitshort at market
endif
je pense que la ligne manquante est celle ci if time<195500 and close>(cloture) then
a voir
Il faut regarder le post avant le votre ou se trouve la version complète
Hello,
en parcourant en diagonale votre code, je trouve pas mal de conditions qui sont mal codée (ligne 17,43,53), et mon backtest, contrairement au votre, termine en une perte totale du capital. Il faut dire que j’ai pris une plus longue période de backtest que vous.Du coup, votre code ressemble bcp à de la sur-optimisation,…
Bonjour Stefou102, ami belge ! j’habite à côté de Lille et j’ai de la famille Belge
Ta remarque est pertinente et en effet, les 3 conditions que tu évoques sont neutralisées car je les utilise ou pas,comme des interrupteurs
Quand je vois qu’elles sont bénéfiques je mets l’interrupteur sur 1 et quand elles ne le sont pas je mets l’interrupteur sur 0
Celà me permet de ne pas avoir à les retaper à chaque fois
Avec l’expérience, je me suis aperçu qu’il était préférable d’optimiser les algorithmes sur une période de 1 à 3 mois maximum car l’algorithme qui fonctionne bien toute l’année n’est pas efficient, je préfère les backtester sur 3 mois environ soit 10 000 bougies de 10 minutes
Il faut donc bien mettre sur la plateforme prorealtime 10 000 puis 10 minutes sur wall street mini 1€ Cfd Cash
Idéalement il faudrait aussi remplacer en lignes 142 et 147 , “z” par “pz” car “z” varie de 1 à 12 mais j’aime bien apporter un peu d’aléas dans le gain, mais pas dans la perte
Je reste à ta disposition pour tout complément d’information
Bonjour Yannchev,
Déjà nous avons un problème, voici une capture d’écran de ton dernier code posté, les résultats ne sont pas vraiment les mêmes (spread = à 0), cela donne :
Bonjour Turame,
En effet on n’obtient pas les mêmes résultats , je viens de refaire un backtest ce 27 mai à 9h00 que je joins.
Aussi, chaque backtest est différent en fonction du point de départ
Mais là je trouve qu’il y a beaucoup d’écart par rapport à celui que je viens de faire
Est ce bien la dernière version complète qui est affichée sur ce post en 2ème publication ?
Faut vérifier si on a les mêmes réglages horaires dans le fichier attaché
Bonjour Yannchev,
Effectivement, la différence venait du fait que les réglages horaires étaient différents.
Mais quel est le bon réglage, le tien ou le mien ?
Je viens d’effectuer une simulation selon tes réglages horaires (plus avantageux que les mien).
Voici les résultats (sans aucun frais de spread)… à méditer.
Bonjour Yannchev,
Merci pour ton partage. Effectivement, travailler sur la notion de répétition et de cycle est constructif (on retrouve dans ton code des nombres de Gann). Je
m’y intéresse aussi.
J’ai testé ton code sur le dax 30 en 10 mn, spread de 2 mais en fait le spread varie selon les horaires chez IG donc ce n’est pas totalement juste notamment pour la nuit ni la journée. Le résultat n’est pas positif sur 200 000 unités mais il est pertinent d’analyser dans le détail, de revoir peut-être le TP car dans plusieurs cas ton MFE est supérieur aux gains.
Le code est long, ne serait- ce pas possible de le simplifier aussi ?
Je reste à ta disposition pour échanger
stratégie avec intelligence artificielle sur le Dow Jones en 10 Minutes
This topic contains 26 replies,
has 5 voices, and was last updated by
JC_Bywan
2 years, 1 month ago.
| Forum: | ProOrder : Trading Automatique & Backtests |
| Language: | French |
| Started: | 05/24/2019 |
| Status: | Active |
| Attachments: | 12 files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.