Demande de boucle pour pyramidage, trailing stop et breakeven
Forums › ProRealTime forum Français › Support ProOrder › Demande de boucle pour pyramidage, trailing stop et breakeven
- This topic has 28 replies, 2 voices, and was last updated 6 years ago by FREDNC.
-
-
01/23/2019 at 2:35 PM #8944301/23/2019 at 2:45 PM #89446
Inutile de faire une boucle, puisque tu rentres directement au marché, tu sais précisément quand incrémenter la variable, donc à chaque instruction BUY ou SELLSHORT, tu peux faire :
1234if buycondition thenbuy 1596 shares at market //entre en positionpos = pos +1 //incrémente ma variable posendifet n’oublie pas de reset pos à 0 quand tu n’es plus au marché.
01/24/2019 at 4:34 AM #89519Merci, effectivement c’est plus simple et tout aussi efficace. Dois-je vraiment acheter 1596 shares at market hahahah 😉
En attendant ta réponse, j’avais remplacé la condition “countofposition” par “breakeven” (Breakeven étant:” breakevenLevel>0″ ).
Mais, même si on utilise des valeurs identiques, Il semblerait qu’à partir du moment ou l’on change les paramétrés du trail en cours de position on perd un petit peu. Rien de dramatique mais c’est un fait…
Je te fais parts des prochains résultats.
Cordialement
01/24/2019 at 5:30 PM #89592Bonjour @Nicolas.
1)La stratégie avance bien , j’ai presque fini et je la posterais quand tout seras vraiment débugger….
2)Juste une question, aujourd’hui j’ai eu l’occasion de voir une prise de position en direct d’un de mes robots.
Le niveau de Startbreakeven a était traversés plusieurs fois par le cours (des mèches), Du coup , j’ai fini par sortit en manuel.
Dans cette stratégie je sors sur le trail en extrême limite avant retournement et non sur un TP.
Normalement, j’aurais dût sortir à au minimum à startbreakeven et + Point to keep, si le court me favorise, vrai ou faut ?
Le trail que j’utilise c’est le même que précédemment, C’est normal ou il y a eu un bog ?
Je t’ais joins un Screenshots. PS: L’outil règle de PRT, délimite mon SL et mon startbreakeven (il est même plus haut). Comme d’habitude mes règles sont simples SL = (close- Donchian) , startbreakeven = abs (MM34-CDH[0]) et je réduis la distance de startbreakeven par – abs( MM34-close).
voici le code d’entré et le Trail
1234567891011121314151617181920212223242526272829303132333435363738394041424344// Conditions pour ouvrir une position Shortif (close CROSSES UNDER MM34) AND timeEnterBefore AND timeEnterAfter then//BE = abs (MM34-CDH[0])MinusBE = abs(MM34-close)//TP = abs (close-CDH[0])+(SPREAD/2)SL = abs (close-CDH[0])+(SPREAD/2)NBR= TEuro/SL//**************Mettre à 1 pour bactester****************SELLSHORT NBR CONTRACT AT MARKETENDIF//************************************************************************startBreakeven = (BE-MinusBE) //how much pips/points in gain to activate the breakeven function?PointsToKeep = 10000 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)//reset the breakevenLevel when no trade are on marketIF NOT ONMARKET THENbreakevenLevel=0ENDIF// --- BUY SIDE ---//test if the price have moved favourably of "startBreakeven" points alreadyIF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)+PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENSELL AT breakevenLevel STOPENDIF// --- SHORT SIDE ---IF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)-PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENEXITSHORT AT breakevenLevel STOPENDIF//************************************************************************// Stops et objectifsSET STOP pLOSS SL//Merci
Cordialement .
01/24/2019 at 5:45 PM #8959601/24/2019 at 6:19 PM #8959901/24/2019 at 6:25 PM #8960001/24/2019 at 8:01 PM #89603Bon , au moment de cette position, le graph de la variable BE me donne 9,21765 et MinusBE 0.08235 ce qui nous donne un startbreakeven à 9,1353 . De l’entrée en position (open) à la mèche la plus basse il y a 11,5 pips. Même en enlevant 1 pip de spread, le startbreakeven aurai dût ce mettre en route . Ca toujours était le cas jusqu’à présent. Après si tu me dit que l’écriture de mon code et source de bog, je suis très intéressé. Mais je ne comprends pas du tout, d’autant que le graph des variables démontre que ça aurait dût se déclenché….
@nicolas: Peux tu être plus explicite car je suis dans le floue, mais je demande qu’à corriger01/25/2019 at 8:26 AM #89618Pour déclencher ton breakeven, tu ne testes pas les mèches, mais les Close: close–tradeprice(1)
Hors tu penses que si une mèches a traversé le niveau de déclenchement du breakeven, alors il aurait du fonctionner, c’est faux. Si tu veux tester une mèche, tu testes les Highs et les Lows, pas les Close.
01/25/2019 at 12:27 PM #89642Merci Pour ta réponse, effectivement je comprends mieux….
Faut que je revois l’écriture du code du trailling-stop ….
Mais je ne sais pas si tu as fait attention, on voit clairement que les closes sont au dessus breakevenlevel mais l’open d’après est plus bas. En refaisant mes calcules, l’open est pile poile sur le niveau mais c’est tellement serrer que le doute existeras toujours. C’est quand même étrange d’avoir un open d’une bougie vert plus bas qu’un close de précédente bougie (rouge) . Micro slippage ?
Bref je vais donc revoir l’écriture du trail à tête reposé.
Si à ta connaissance il en existe déjà un trail qui tient comptes des highs et des lows à la place des closes, je suis preneur.
je suis en over-coding 😉
01/25/2019 at 1:33 PM #89649C’est quand même étrange d’avoir un open d’une bougie vert plus bas qu’un close de précédente bougie (rouge) .
Non, ça s’appelle un “gap” 🙂
Un gap est un écart haussier ou baissier entre le cours de clôture d’un chandelier et le cours d’ouverture du chandelier suivant. Un gap est du à un nombre important d’ordres allant dans le même sens entre les deux chandeliers.
https://www.centralcharts.com/fr/gm/1-apprendre/5-trading/14-strategie/293-comment-trader-les-gaps
01/27/2019 at 12:25 AM #89722Exact, c’est un gap, un micro-gap… J’ai une stratégie en développement qui trade les gaps de 8h00 sur le Dax.
En cours de journée, j’appelle plutôt ça “un trou de cotation” mais c’est de la rhétorique car un trou de cotation c’est un gap 😉
01/29/2019 at 10:33 AM #89918Bonjour Nicolas,
J’ai enfin fini… Le concept du “Machin Gun ” est un succès.
Voici les trois versions: Screenshots ci dessous
Version N° 1: la stratégie de base:
Version N°2: stratégie avec le Multi-positions et démarrage du trailing sur close – traderprice. On observe que les gains fond plus que doubler. Le drawdown maîtrisé mais en augmentation en terme globale et non en terme de positions. L’augmentation du drawdonw est du au spread des positions supplémentaires qui sort à o
Version N°3: stratégie avec le Multi-positions et démarrage du trailing sur High/Low -traderprice. Le drawdown est moindre que la version originale (en euro) et on observe une belle progression par rapport à la version d’origine. Mais on observe que les gains sont moindre que la version N°3. A noté que sur la version N°3 ,j’ai supprimé “countofposition” à la faveur d’une variable suivant tes conseils. Ça n’apporte rien en terme de performance mais ça évite de l’utilisation de “countofposition” qui est source d’erreurs.
Je trouve que globalement, ça apport une belle amélioration et le concept mérite qu’on si attarde en tous cas. Avec l’arrivé de l’ ESMA l’année dernière faudrait faire attention à ne pas être en appel de marge dût au Multi-position. La fonction “limiter le nombre de positions” sera très utile en fonction des compte de chacun.
Si tu souhaite la mettre en bibliothèque je ferai un post spécifique.
Merci pour ton aide
Ps: Si dessous la version N°3 (ma préférée)
V3123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199// Définition des paramètres du code*************** Dax M1, 100 000 bougies, spread 1******************DEFPARAM CumulateOrders = true //false // Cumul des Entrytions ACTIVEES***Voir option Pyramidage Tout à la fin, sous le BreakEven***DEFPARAM Preloadbars = 20000//Nbr de contrats*******************N=2//**********************************// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une Entrytion avant l'heure spécifiéenoEntryBeforeTime = 091500//080000//091500timeEnterBefore = time >= noEntryBeforeTime//Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une Entrytion après l'heure spécifiéenoEntryAfterTime = 170000//2130000//170000timeEnterAfter = time < noEntryAfterTime//Jour de trading du lundi au vendredi inclusif DayOfWeek <= 5 thenTradeday=1elsif tradeday=1 and DayOfWeek > 5 thenTradeDay=0endifIF ONMARKET and (TIME>=171500 and close-positionprice>1) THENSELL AT MARKETEXITSHORT AT MARKETENDIFSpread=1//Canal Donchian**********************************************************************************DC=15//CDH=Highest[DC](high)CDB=Lowest[DC](low)//Taille des Entrytions autorisées en Pips*********************************************************TMini=7//7TMaxi=13//12TailleA = (abs(close-CDB))TailleV = (abs(CDH-close))PC=5//14// ***********************************Optimisable entre 10% et 40% admit Entre Entrytion/objectif/MM34If Abs (close[1]-close) < abs(tailleA*PC/100) thenDist=1elsif Abs (close[1]-close) < abs(TailleV*PC/100) thenDist=1elseDist=0endif//PPJ*********************************************************************************************PPJ= (DHigh(1) + DLow(1) + DClose(1))/3//TDI*********************************************************************************************lengthRSI = 13lengthband = 34lengthrsipl = 2lengthtradesl = 7r = rsi[lengthrsi](close)ma = average[lengthband](r)offs = (1.6185 * std[lengthband](r))up = ma+offsdn = ma-offsmid = (up+dn)/2TDIVert = average[lengthrsipl](r)TDIRouge = average[lengthtradesl](r)// "CROSS 1"**************************************************************************************IF not onmarket and TDIVert > mid and TDIRouge > mid and mid > 50 and TMini<abs((CDB[0]-Close)+(SPREAD/2)) and TMaxi>abs((CDB[0]-close)+(SPREAD/2)) and close >= PPJ and dist and Tradeday AND timeEnterBefore AND timeEnterAfter THENCROSSTa = 1elsif not onmarket and TDIVert < mid and TDIRouge < mid and mid < 50 and TMini<abs((close-CDH[0])+(SPREAD/2)) and TMaxi>abs((close-CDH[0]+(SPREAD/2))) and close <= PPJ and dist and Tradeday AND timeEnterBefore AND timeEnterAfter THENCROSSTb = 1elseCROSSTa=0CROSSTb=0ENDIF// "CROSS 2"**************************************************************************************if Pyra and TDIVert crosses over TDIRouge or r[1]<r or TDIVert[1]< TDIVert THEN//CROSST2A = 1elsif Pyra and TDIVert crosses under TDIRouge or r[1]<r or TDIVert[1]< TDIVert THEN//CROSST2V = 1elseCROSST2A=0CROSST2V=0ENDIF//Bot1 **************************************************************************************************If not onmarket thenEntry=0endif//Long1Bot1=0If not onmarket and CROSSTa and TDIVert crosses over TDIRouge thenBot1=3 //Pour graph la variable. Inutine quand tous fonctionneBUY N CONTRACT AT MARKETSL = abs (close-CDB)+(SPREAD/2)TP = abs (close-CDB)+(SPREAD/2)Entry = Entry+1endif//Short1if not onmarket and CROSSTb and TDIVert crosses under TDIRouge thenBot1=3 //Pour graph la variable. Inutine quand tous fonctionneSELLSHORT N CONTRACT AT MARKETSL = abs (CDH-close)+(SPREAD/2)TP = abs (CDH-close)+(SPREAD/2)Entry = Entry+1ENDIF//Bot2********************************************************************************************On=1//******** 1= Bot2 actif 0= Bots inactif ********//Long2Bot2=0////Pour graph la variable. Inutine quand tous fonctionneIf longonmarket and on and Pyra and CROSST2A thenBot2=5//Pour graph la variable. Inutine quand tous fonctionneBUY N CONTRACT AT MARKETSL = abs (close-CDB)+(SPREAD/2)Entry = Entry+1endif//Short2if shortonmarket and On and Pyra and CROSST2V thenBot2=5//Pour graph la variable. Inutine quand tous fonctionneSELLSHORT N CONTRACT AT MARKETSL = abs (CDH-close)+(SPREAD/2)Entry = Entry+1endif//Trail Bascule "point to keep"*******************************************************************//Mono EntrytionIf breakeven=0 thenStBe=TP/1PtK= TP/3 //1000 pour sortir au plus haut. Aucune respiration posible. Peut être modifié (TP/X)//Muti-poditions et au delà de X pipselsif Entry>1 then//StBe=TP/1PtK=1000// pour sortir au plus haut. Aucune respiration posible. Peut être modifié (TP/X)//**************************************endif// Trail et management **************************************************************************************************//définifition et bascule de "StartBreakeven" et "Point To Keep"startBreakeven = StBe//how much pips/points in gain to activate the breakeven function?PointsToKeep = PtK//ref //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)//reset the breakevenLevel when no trade are on marketIF NOT ONMARKET THENbreakevenLevel=0breakeven=0ENDIF//trail************// --- BUY SIDE ---//test if the price have moved favourably of "startBreakeven" points alreadyIF LONGONMARKET AND high-POSITIONPRICE>=startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel= POSITIONPRICE+PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENSELL AT breakevenLevel STOPBreakeven=1ENDIF// --- SHORT SIDE ---IF SHORTONMARKET AND POSITIONPRICE-low>=startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = POSITIONPRICE-PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENEXITSHORT AT breakevenLevel STOPbreakeven=1ENDIF//Pyramidage si Be + limitation de Entrytion************************NbrContrats=25if not onmarket and Pyra=1 thenPyra=0elsif onmarket and PYra=0 and breakeven then //and breakevenLevelA>0Pyra=1elsif Pyra=1 and Entry>=NbrContrats or breakevenLevel<0 thenPyra=0endifSET STOP pLOSS SL//SET TARGET pPROFIT TP//graph pyragraph Entry//graph PtK//graph StBe//graph Entrytionprice//graph TP//graph (Entrytionprice-close)>0//graph Bot1//graph Bot2//graph breakeven//graph breakevenLevelA//graph breakevenLevelV>0If bot1 thenelsif bot2 thenelsif TP thenendif2 users thanked author for this post.
01/29/2019 at 3:33 PM #89953Petite erreur dans la stratégie V3 (post précédent) la limitation de position, ne se faisait pas correctement. Il faut remplacer juste le code de “pyramidage” par celui ci-dessous:
123456789//Pyramidage si Be + limitation de Entrytion************************NbrEntry=25if not onmarket and Pyra=1 thenPyra=0elsif onmarket and PYra=0 and breakeven and Entry<NbrEntry thenPyra=1elsif Entry>=NbrEntry or breakevenLevel<0 thenPyra=0endifMerci.
-
AuthorPosts
Find exclusive trading pro-tools on