Long et short en même temps
Forums › ProRealTime forum Français › Support ProOrder › Long et short en même temps
- This topic has 11 replies, 4 voices, and was last updated 9 hours ago by
JS.
-
-
06/20/2025 at 9:31 AM #248422
Bonjour,
Pouvez m’indiquer pourquoi mes positions s’ouvrent et se ferment aussitôt.Merci
123456789101112131415161718192021222324252627282930313233343536if Achat and Not OnMarket then// POUR UN ACHAT//Ordre AchatBUY 1 CONTRACT AT MARKETSLFinance = 1SLA = LOW//close-lowest[2](close[1])TP1A = close + (abs(close - SLA) * 1)TP2A = close + (abs(close - SLA) * 2)SET STOP pLOSS SLAELSIF Vente and Not OnMarket THEN//Ordre VENTESELLSHORT 1 CONTRACT AT MARKETSLFinance = 1SLV = HIGH//close-highest[2](close[1])TP1V = close - (abs(SLV - close) * 1)TP2V = close - (abs(SLV - close) * 2)SET STOP pLOSS SLVENDIF//SL et TP pour la position d'achatif longonmarket and close >= TP1A and SLFinance = 1 thensell abs(COUNTOFPOSITION)/2 CONTRACTS AT MARKETset stop BREAKEVENSLFinance = 2endif//SL et TP pour la position de venteIf shortonmarket and close >= TP1V and SLFinance = 1 thenbuy abs(COUNTOFPOSITION)/2 CONTRACTS AT MARKETset stop BREAKEVENSLFinance = 2endifGRAPHONPRICE SLV coloured("Red")GRAPHONPRICE TP1V coloured("Blue")GRAPHONPRICE TP2V coloured("GREEN")06/20/2025 at 10:00 AM #248432Sur la ligne 29, vous ne devez PAS utiliser « BUY », car elle sert à ouvrir une position longue (et donc à clôturer la position courte actuelle).
Pour sortir d’une position courte, vous devez utiliser « EXITSHORT» :1EXITSHORT abs(COUNTOFPOSITION)/2 CONTRACTS AT MARKET1 user thanked author for this post.
06/20/2025 at 10:19 AM #248433Merci Roberto mais malgré ce changement cela est toujours pareil. Il doit y avoir quelque chose d’autre
12345If shortonmarket and close >= TP1V and SLFinance = 1 thenEXITSHORT abs(COUNTOFPOSITION)/2 CONTRACTS AT MARKETset stop BREAKEVENSLFinance = 2endif06/20/2025 at 10:26 AM #248434Code complet123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354DEFPARAM CUMULATEORDERS = falseTIMEFRAME(5 Minute)//Réinitialisation VALEURif Not OnMarket THENSLFinance = 0//SL = 0//TP1 = 0//TP2 = 0endifniveau = 23460Achat = open < niveau and close > niveau+2*pipsizeVente = open > niveau and close < niveau+2*pipsizeif Achat and Not OnMarket then// POUR UN ACHAT//Ordre AchatBUY 1 CONTRACT AT MARKETSLFinance = 1SLA = LOW//close-lowest[2](close[1])TP1A = close + (abs(close - SLA) * 1)TP2A = close + (abs(close - SLA) * 2)SET STOP pLOSS SLAELSIF Vente and Not OnMarket THEN//Ordre VENTESELLSHORT 1 CONTRACT AT MARKETSLFinance = 1SLV = HIGH//close-highest[2](close[1])TP1V = close - (abs(SLV - close) * 1)TP2V = close - (abs(SLV - close) * 2)SET STOP pLOSS SLVENDIF//SL et TP pour la position d'achatif longonmarket and close >= TP1A and SLFinance = 1 thensell abs(COUNTOFPOSITION)/2 CONTRACTS AT MARKETset stop BREAKEVENSLFinance = 2endif//SL et TP pour la position de venteIf shortonmarket and close >= TP1V and SLFinance = 1 thenEXITSHORT abs(COUNTOFPOSITION)/2 CONTRACTS AT MARKETset stop BREAKEVENSLFinance = 2endifGRAPHONPRICE SLV coloured("Red")GRAPHONPRICE TP1V coloured("Blue")GRAPHONPRICE TP2V coloured("GREEN")06/20/2025 at 10:31 AM #248435Bonjour,
Dans le code du post d’en-tête, si ta ligne 21 pour un achat dit:
if longonmarket and close >= TP1A and …
par analogie j’aurais imaginé ta ligne 28 non pas: If shortonmarket and close >= TP1V and …
mais plutôt: If shortonmarket and close <= TP1V
A tester.
06/20/2025 at 10:41 AM #24843606/20/2025 at 11:11 AM #248438Les set stop ploss ne sont pas ok non plus, car tu leur as mis un niveau alors que cette commande s’attend à une distance en points, par exemple close-SLA plutôt que SLA
Je ne juge pas de la validité ou pas de ton stop, mais de la nature de la valeur que tu as associé à la commande ploss, c’est-à-dire si j’enlève le terme SLA de la discussion pour ne pas être ambigu: “set stop ploss (close-low)” serait correct là où “set stop ploss low” (puisque ton SLA=low) ne n’est pas.
(et à la vente “set stop ploss high-close” serait correct là où “set stop ploss high” (puisque ton slv=high) ne n’est pas.)
1 user thanked author for this post.
06/20/2025 at 11:13 AM #248439Ref: https://www.prorealcode.com/documentation/ploss-2/
1 user thanked author for this post.
06/20/2025 at 12:22 PM #248447Entendu, je vais tester cela.
Par contre, lorsque j’affiche ces données sur le graphique, elles sont correctement identifiées grâce à “GRAPHONPRICE ” comme tu peux le voir sur la pj.
GRAPHONPRICE SLV coloured(“Red”)
GRAPHONPRICE TP1V coloured(“Blue”)
GRAPHONPRICE TP2V coloured(“GREEN”)06/20/2025 at 12:51 PM #248449J’ai essayé ce code mais ne fonctionne pas. Pourtant celui ci m’avait l’air correct … Je souhaite simplement le SL au dessus /dessous de la bougie précédente et ensuite Tp *1 et *2
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253DEFPARAM CUMULATEORDERS = falseTIMEFRAME(5 Minute)//Réinitialisation VALEURif Not OnMarket THENSLFinance = 0//SL = 0//TP1 = 0//TP2 = 0endifniveau = 23460Achat = open < niveau and close > niveau+2*pipsizeVente = open > niveau and close < niveau+2*pipsizeif Achat and Not OnMarket then// POUR UN ACHAT//Ordre AchatBUY 1 CONTRACT AT MARKETSLFinance = 1SLA = abs(close - Low[1]) //low//close-lowest[2](close[1])TP1A = SLA*2 //close + (abs(close - SLA) * 1)TP2A = SLA*3 //close + (abs(close - SLA) * 2)SET STOP pLOSS SLAELSIF Vente and Not OnMarket THEN//Ordre VENTESELLSHORT 1 CONTRACT AT MARKETSLFinance = 1SLV = abs(close - High[1])TP1V = SLV*2 //close - (abs(SLV - close) * 1)TP2V = SLV*3 //close - (abs(SLV - close) * 2)SET STOP pLOSS SLVENDIF//SL et TP pour la position d'achatif longonmarket and close >= TP1A and SLFinance = 1 thensell abs(COUNTOFPOSITION)/2 CONTRACTS AT MARKETset stop BREAKEVENSLFinance = 2endif//SL et TP pour la position de venteIf shortonmarket and close >= TP1V and SLFinance = 1 thenEXITSHORT abs(COUNTOFPOSITION)/2 CONTRACTS AT MARKETset stop BREAKEVENSLFinance = 2endifGRAPHONPRICE SLV coloured("Red")GRAPHONPRICE TP1V coloured("Blue")GRAPHONPRICE TP2V coloured("GREEN")06/22/2025 at 8:28 AM #24849206/22/2025 at 9:22 AM #248493Tu calcules : SLA = abs(Close – Low[1])
Ce calcul donne un nombre de points, donc pas un niveau de prix mais bien un nombre de points (par exemple 10 points).
Ensuite, tu ecris :
If LongOnMarket and Close >= TP1A and SLFinance = 1 then
Tu verifies alors si Close est superieur ou egal a un nombre de points.
Mais Close est naturellement toujours superieur a une valeur exprimee en points (SL), ce qui fait que ta position est immediatement cloturee partiellement (abs(CountOfPosition) / 2). -
AuthorPosts
Find exclusive trading pro-tools on