Bonjour à tous,
Cela fait un moment que je suis parmi vous sur ce forum. Depuis toutes ces années j’ai surtout appris dans l’ombre et aujourd’hui je voudrais rendre un peu de qui a été donné en partageant une stratégie avec la communauté.
C’est un stratégie très simple qui fonctionne en 30 minutes sur le DAX40 (backtest sur PRT via IG avec 1 million d’unités).
Je précise que je ne suis pas du tout satisfait de la stratégie. Elle me semble bien trop optimisée et trop fébrile pour être lancé en réel. Cependant cela peut constituer une base de travail intéressante. n’hésitez pas à vous l’appropriez et à l’améliorer.
Je la poste ici afin tout le monde puisse en profiter l’améliorer le cas échéant.
@nicolas @robertogozzi @fbolsa si vous le souhaitez je peux publier cette stratégie dans la libraire. As you wish 😉
// DAX 30MIN
DEFPARAM flatbefore = 090000
DEFPARAM flatafter = 173000
DEFPARAM CumulateOrders = False
//Filtre de tendance
timeframe(4 hours)
filtre= Supertrend[3,10]
if close>filtre then
tendance=1
else
tendance=-1
endif
timeframe(30 minutes)
//Paramètres
atrPeriod = 2
multipleatr=2
riskMult = 0.5
tpMult = 0.5
// Keltner
myATR = AverageTrueRange[atrPeriod](close)
ema20=ExponentialAverage[50](close)
Ksup=ema20+multipleatr*myATR
Kinf=ema20-multipleatr*myATR
//Volume
vol=Volume
smavol=Average[20](vol)
//Condition volatilité
condvol=vol>smavol
//Condition d'entrée en position
condachat=close crosses over Ksup
condvente=close crosses under Kinf
//Prises de positions
IF condachat and condvol and tendance=1 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF condvente and condvol and tendance=-1 THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
//Sorties sur rentournement
IF LongOnMarket AND close<ema20 THEN
SELL AT MARKET
ENDIF
IF ShortOnMarket AND close>ema20 THEN
EXITSHORT AT MARKET
ENDIF
// SL et TP initiaux
IF LongOnMarket THEN
SET STOP LOSS (tradeprice - riskMult * myATR)
SET TARGET PROFIT (tradeprice + tpMult * myATR)
ENDIF
IF ShortOnMarket THEN
SET STOP LOSS (tradeprice + riskMult * myATR)
SET TARGET PROFIT (tradeprice - tpMult * myATR)
ENDIF
Je viens de me rendre compte que j’ai testé avec un spread de 1, or nous sommes à 2 aujourd’hui avec IG sur le DAX. Cela change légèrement les résultats mais ça reste sympa visuellement.
Merci turame, en effet pour être au range de “master”, il faut avoir de la bouteille sur le site 🙂 (présent depuis 2017 ! merci pour ta présence).
En analysant ton code, je vois un problème de “taille”, si je peux m’exprimer ainsi, en effet:
// SL et TP initiaux
IF LongOnMarket THEN
SET STOP LOSS (tradeprice - riskMult * myATR)
SET TARGET PROFIT (tradeprice + tpMult * myATR)
ENDIF
IF ShortOnMarket THEN
SET STOP LOSS (tradeprice + riskMult * myATR)
SET TARGET PROFIT (tradeprice - tpMult * myATR)
ENDIF
tu utilises des niveaux de prix, alors que ces instructions attendent des distances, soit une fraction du prix. Il faut plutôt utiliser les instructions SET STOP PRICE et SET TARGET PRICE, comme ceci:
// SL et TP initiaux
IF LongOnMarket THEN
SET STOP PRICE (tradeprice - riskMult * myATR)
SET TARGET PRICE (tradeprice + tpMult * myATR)
ENDIF
IF ShortOnMarket THEN
SET STOP PRICE (tradeprice + riskMult * myATR)
SET TARGET PRICE (tradeprice - tpMult * myATR)
ENDIF
Malheureusement, je pense que cela aura un impact fort sur les résultats, à tester !
Bien vu @nicolas ! Mais je n’ai pas dis mon dernier mot. J’ai une autre version. les conditions d’entrées sont les mêmes, seul le money management change. Je l’ai fais très vite, il y a probablement des erreurs. Voici la version et les résultats :
// DAX 30MIN
DEFPARAM flatbefore = 090000
DEFPARAM flatafter = 173000
DEFPARAM CumulateOrders = False
//Filtre de tendance
timeframe(4 hours)
filtre= Supertrend[3,10]
if close>filtre then
tendance=1
else
tendance=-1
endif
timeframe(30 minutes)
//Money Management
capitalinitial=10000
risque=0.5
exitstrategy=1
profitfactor=6
stopfactor=1.5
partialprofit=1
partialprofitfactor=3
ratchetfactor=7
//Paramètres
atrPeriod = 2
multipleatr=2
riskMult = 0.5
tpMult = 0.5
// Keltner
myATR = AverageTrueRange[atrPeriod](close)
ema20=ExponentialAverage[50](close)
Ksup=ema20+multipleatr*myATR
Kinf=ema20-multipleatr*myATR
//Volume
vol=Volume
smavol=Average[20](vol)
//Condition volatilité
condvol=vol>smavol
//Condition d'entrée en position
condachat=close crosses over Ksup
condvente=close crosses under Kinf
//Positions achats
IF condachat and condvol and tendance=1 THEN
positionsize=round(((capitalinitial+STRATEGYPROFIT)*(risque/100))/(stopfactor*averagetruerange[20]))
buy positionsize shares at market
set stop loss stopfactor*averagetruerange[20]
if exitstrategy=0 THEN
set target profit profitfactor*averagetruerange[20]
ENDIF
flag=0
ENDIF
if LONGONMARKET and close>Ksup+partialprofitfactor*averagetruerange[20] and flag=0 and partialprofit=1 THEN
sell round(positionsize/2) shares at market
flag=1
ENDIF
if LONGONMARKET and exitstrategy=1 and close<lowest[30](highest[55](high)-ratchetfactor*averagetruerange[20]) THEN
sell at market
ENDIF
//Positions ventes
IF condvente and condvol and tendance=-1 THEN
positionsize=round(((capitalinitial+STRATEGYPROFIT)*(risque/100))/(stopfactor*averagetruerange[20]))
sellshort positionsize shares at market
set stop loss stopfactor*averagetruerange[20]
if exitstrategy=0 THEN
set target profit profitfactor*averagetruerange[20]
ENDIF
flag=0
ENDIF
if SHORTONMARKET and close<Kinf-partialprofitfactor*averagetruerange[20] and flag=0 and partialprofit=1 THEN
exitshort round(positionsize/2) shares at market
flag=1
ENDIF
if SHORTONMARKET and exitstrategy=1 and close>highest[30](lowest[55](low)+ratchetfactor*averagetruerange[20]) THEN
exitshort at market
ENDIF