Extratrend stratégie en un indicateur
Forums › ProRealTime forum Français › Support ProBuilder › Extratrend stratégie en un indicateur
- This topic has 28 replies, 8 voices, and was last updated 2 years ago by plbourse.
-
-
05/23/2022 at 12:09 PM #193712
Bonjour à toutes et tous,
J’ai effectué un backtest d’une stratégie en faisant appel à Extratrend.
J’aimerai transformé cette stratégie en indicateur, afin de pouvoir l’utiliser en temps réel. Pourriez vous m’aider à le faire svp ?
Merci d’avance,
Voici le code du backtest :
12345678910111213141516171819202122232425262728293031323334353637383940414243DEFPARAM CumulateOrders=Falsecapitalinitial=10000risque=0.5exitstrategy=1profitfactor=6stopfactor=1.5partialprofit=1partialprofitfactor=3ratchetfactor=7// Appel des valeurs d'ExtraTrend//myTrend, ignored, ignored = CALL "ExtraTrend v2" [0,0,0,0,0](close)myTrend, ignored, ignored, ignored, ignored = CALL "ExtraTrend"[0,0,0,0,0](close)// Tendance ExtraTrendif myTrend>myTrend[1] thentendance=1endifif myTrend<myTrend[1] thentendance=0endifif tendance and not tendance[1] and not longonmarket THEN//if not longonmarket thenpositionsize=round(((capitalinitial+STRATEGYPROFIT)*(risque/100))/(stopfactor*averagetruerange[20]))//positionsize=round(((capitalinitial+STRATEGYPROFIT)/close)BUY positionsize shares AT MARKETset stop loss stopfactor*averagetruerange[20]if exitstrategy=0 thenset target profit profitfactor*averagetruerange[20]endifflag=0endifif longonmarket and close>=myTrend+partialprofitfactor*averagetruerange[20] and flag=0 and partialprofit=1 thensell round(positionsize/2) shares at marketflag=1endifif longonmarket and exitstrategy=1 and close<lowest[30](highest[55](high)-ratchetfactor*averagetruerange[20])thensell at marketendif05/23/2022 at 4:06 PM #19372005/23/2022 at 4:36 PM #193724Ci-joint la version graphique de cette stratégie avec Extratrend:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354capitalinitial=10000risque=0.5exitstrategy=1profitfactor=6stopfactor=1.5partialprofit=1partialprofitfactor=3ratchetfactor=7// Appel des valeurs d'ExtraTrendmyTrend, ignored, ignored, ignored, ignored = CALL "ExtraTrend"[0,0,0,0,0](close)// Tendance ExtraTrendif myTrend>myTrend[1] thentendance=1endifif myTrend<myTrend[1] thentendance=0endifif tendance and not tendance[1] and not ionmarket THENdrawarrowup(barindex,low-AverageTrueRange[14](close)/2) coloured("green")istoploss = close-stopfactor*averagetruerange[20]//set stop loss stopfactor*averagetruerange[20]if exitstrategy=0 thenitakeprofit = close+profitfactor*averagetruerange[20]//set target profit profitfactor*averagetruerange[20]endifflag=0ionmarket=1endifif ionmarket and close>=myTrend+partialprofitfactor*averagetruerange[20] and flag=0 and partialprofit=1 thendrawtext("X",barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured("green")flag=1endifif ionmarket and exitstrategy=1 and close<lowest[30](highest[55](high)-ratchetfactor*averagetruerange[20])thendrawtext("exit",barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured("green")ionmarket=0endif//test stoploss & takeprofitif ionmarket thenif high >= itakeprofit and exitstrategy=0 thendrawtext("TP",barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured("green")ionmarket=0elsif low <= istoploss thendrawtext("SL",barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured("red")ionmarket=0endifendifreturn itakeprofit style(dottedline2) coloured("green"), istoploss style(dottedline3) coloured("red")1 user thanked author for this post.
05/23/2022 at 7:11 PM #19372605/23/2022 at 7:37 PM #193729Cela a l’air de bien marcher.
J’ai trois questions.
– Je suppose que :
SL c’est Stop Loss touché
Le “X” c’est une prise de profit
La flèche vers le haut c’est la prise de position
Mais qu’est ce que le “EXIT” ?– Est il possible d’avoir le niveau trailing stop ? Car sur le graphique, il ne “suit” pas vraiment le cours. Je suis prévenu que lorsqu’il est tapé.
– J’essaye de changer la couleur des évènements du vert vers le noir, mais je n’y arrive pas ^^
05/24/2022 at 7:20 AM #19374705/24/2022 at 10:43 AM #19376305/24/2022 at 12:54 PM #19377105/30/2022 at 8:15 PM #194221Bonsoir Nicolas,
Un grand merci pour ton aide !
Je viens de recevoir ma licence Metascore, et j’aimerai rajouter une condition d’achat.
Pourrais tu m’aider à le faire stp ? (Désolé, je suis vraiment très mauvais en codage, je ne sais pas faire grand chose).
J’aimerai conserver cette stratégie (entrée quand nouvelle zone de force à condition de ne pas déjà être en position, prise de profit partielle, trailing stop avec un ratchet…) mais en rajoutant la condition stricte que le métascore soit supérieur ou égal à 80.
J’aimerai le backtester d’abord et puis le transformer en indicateur visuel si cela se révèle probant.
En te remerciant par avance,
Amicalement,
Thibaut
1 user thanked author for this post.
05/31/2022 at 9:25 AM #19424605/31/2022 at 9:42 AM #194250D’accord, merci.
J’ai tenté d’implémenter.
Cela donne ça, c’est correct ?
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152DEFPARAM CumulateOrders=Falsecapitalinitial=10000risque=0.5exitstrategy=1profitfactor=6stopfactor=1.5partialprofit=1partialprofitfactor=3ratchetfactor=7// Appel des valeurs d'ExtraTrend//myTrend, ignored, ignored = CALL "ExtraTrend v2" [0,0,0,0,0](close)myTrend, ignored, ignored, ignored, ignored = CALL "ExtraTrend"[0,0,0,0,0](close)// Tendance ExtraTrendif myTrend>myTrend[1] thentendance=1endifif myTrend<myTrend[1] thentendance=0endif// score MetascoremyScore, ignored, ignored = CALL "MetaScore"[80, 0, 0](close)if myScore>80 thentendance=1endifif myScore<80 thentendance=0endif//strategy of entryif tendance and not tendance[1] and not longonmarket THEN//if not longonmarket thenpositionsize=round(((capitalinitial+STRATEGYPROFIT)*(risque/100))/(stopfactor*averagetruerange[20]))//positionsize=round(((capitalinitial+STRATEGYPROFIT)/close)BUY positionsize shares AT MARKETset stop loss stopfactor*averagetruerange[20]if exitstrategy=0 thenset target profit profitfactor*averagetruerange[20]endifflag=0endifif longonmarket and close>=myTrend+partialprofitfactor*averagetruerange[20] and flag=0 and partialprofit=1 thensell round(positionsize/2) shares at marketflag=1endifif longonmarket and exitstrategy=1 and close<lowest[30](highest[55](high)-ratchetfactor*averagetruerange[20])thensell at marketendif05/31/2022 at 9:50 AM #194251Bonjour, pour joindre le code PRT au bon format, merci d’utiliser le bouton “insert PRT code”, s’il disparait temporairement (bug du site), merci de faire CTRL+F5 pour le faire réapparaitre, mini-tuto qui contourne le bug et permet de localiser le bouton si on ne le connait pas encore: https://www.youtube.com/watch?v=jBuqwWPW3H4
(psa besoin de reposter, je vais éditer le code ci-dessus pour le mettre au bon format)
05/31/2022 at 1:28 PM #194288Non, la logique n’est pas correct, le code devrait être comme ceci :
12345678910111213141516171819202122232425262728293031323334353637383940414243444546DEFPARAM CumulateOrders=Falsecapitalinitial=10000risque=0.5exitstrategy=1profitfactor=6stopfactor=1.5partialprofit=1partialprofitfactor=3ratchetfactor=7// Appel des valeurs d'ExtraTrend//myTrend, ignored, ignored = CALL "ExtraTrend v2" [0,0,0,0,0](close)myTrend, ignored, ignored, ignored, ignored = CALL "ExtraTrend"[0,0,0,0,0](close)// Tendance ExtraTrendif myTrend>myTrend[1] thentendance=1endifif myTrend<myTrend[1] thentendance=0endif// score MetascoremyScore, ignored, ignored = CALL "MetaScore"[80, 0, 0](close)//strategy of entryif tendance and not tendance[1] and not longonmarket and myscore>80 THEN//if not longonmarket thenpositionsize=round(((capitalinitial+STRATEGYPROFIT)*(risque/100))/(stopfactor*averagetruerange[20]))//positionsize=round(((capitalinitial+STRATEGYPROFIT)/close)BUY positionsize shares AT MARKETset stop loss stopfactor*averagetruerange[20]if exitstrategy=0 thenset target profit profitfactor*averagetruerange[20]endifflag=0endifif longonmarket and close>=myTrend+partialprofitfactor*averagetruerange[20] and flag=0 and partialprofit=1 thensell round(positionsize/2) shares at marketflag=1endifif longonmarket and exitstrategy=1 and close<lowest[30](highest[55](high)-ratchetfactor*averagetruerange[20])thensell at marketendif05/31/2022 at 5:08 PM #19432606/22/2022 at 10:20 PM #195900Bonjour Nicolas,
J’ai développé une variante de ma stratégie, en incluant une partie SHORT.
Mais j’ai du mal à la transformer en indicateur visuel ^^
Je ne veux pas abuser mais pourrais tu m’aider stp ?
(Désolé mais j’ai beau tape CTRL+F5 mais le bouton Insert PRT code ne s’affiche pas…)
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980DEFPARAM CumulateOrders=Falsecapitalinitial=100000risque=0.5exitstrategy=1profitfactor=6stopfactor=1.5partialprofit=1partialprofitfactor=3ratchetfactor=7//myTrend, ignored, ignored = CALL "ExtraTrend v2" [0,0,0,0,0](close)myTrend, ignored, ignored, myReDyn, ignored = CALL "ExtraTrend"[0,0,0,0,0](close)// Tendance ExtraTrendif myTrend>myTrend[1] thentendance=1endifif myTrend<myTrend[1] thentendance=0endif// Break Résistance Dynamique ExtraTrendif myReDyn>myReDyn[1] thenReDyn=1endifif myReDyn<myReDyn[1] thenReDyn=0endif// MetascoremyScore, ignored, ignored = CALL "MetaScore"[0,0,0](close)//STRATEGIES OF BUYif tendance and not tendance[1] and not longonmarket and not shortonmarket and myScore>80 and ReDyn=1 THEN//if not longonmarket thenpositionsize=round(((capitalinitial+STRATEGYPROFIT)*(risque/100))/(stopfactor*averagetruerange[20]))//positionsize=round(((capitalinitial+STRATEGYPROFIT)/close)BUY positionsize shares AT MARKETset stop loss stopfactor*averagetruerange[20]if exitstrategy=0 thenset target profit profitfactor*averagetruerange[20]endifflag=0endifif longonmarket and close>=myTrend+partialprofitfactor*averagetruerange[20] and flag=0 and partialprofit=1 thensell round(positionsize/2) shares at marketflag=1endifif longonmarket and exitstrategy=1 and close<lowest[30](highest[55](high)-ratchetfactor*averagetruerange[20])thensell at marketendif//STRATEGIES OF SELLif not tendance and not tendance[0] and not shortonmarket and not longonmarket and myScore<20 THEN//if not ShortOnMarket thenpositionsize=round(((capitalinitial+STRATEGYPROFIT)*(risque/100))/(stopfactor*averagetruerange[20]))//positionsize=round(((capitalinitial+STRATEGYPROFIT)/close)SELLSHORT positionsize shares AT MARKETset stop loss stopfactor*averagetruerange[20]if exitstrategy=0 thenset target profit profitfactor*averagetruerange[20]endifflag=0endifif shortonmarket and close>=myTrend+partialprofitfactor*averagetruerange[20] and flag=0 and partialprofit=1 thensell round(positionsize/2) shares at marketflag=1endifif shortonmarket and exitstrategy=1 and close<lowest[30](highest[55](high)-ratchetfactor*averagetruerange[20])thenexitshort at marketendif -
AuthorPosts
Find exclusive trading pro-tools on