ProRealCode - Trading & Coding with ProRealTime™
Bonjour tout le monde
je vous partage une stratégie sur eur/usd en graph 2 min. Merci au passage à nicolas et roberto ou j’ai intégré le break even.
Je voudrais intégrer dans la stratégie la vente partielle.
Voila j’ai suivi chaque jour les prises de postions et j’ai remarqué que souvent il arrive à hauteur de 10 euros( par exemple) et redescend pour cloturer toute la position au break even déclenché qui peut être de 3.5 euros ou autres.
Je voudrais intégrer également la cloture du trade quand celui si arrive à 60,80 ou autre bougie si le trade dure trop longtemps.
Si cela peut intéresser quelqu’un et m’inclure cela dans le code ou vous remerciant
// Définition des paramètres du code
DEFPARAM CumulateOrders = False // Cumul des positions désactivé
// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position avant l'heure spécifiée
noEntryBeforeTime = 080000
timeEnterBefore = time >= noEntryBeforeTime
// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position après l'heure spécifiée
noEntryAfterTime = 192000
timeEnterAfter = time < noEntryAfterTime
// Empêche le système de placer de nouveaux ordres sur les jours de la semaine spécifiés
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
// Conditions pour ouvrir une position en vente à découvert
indicator1 = SenkouSpanB[9,26,52]
c1 = (close >= indicator1)
indicator2 = SenkouSpanB[9,26,52]
c2 = (low[1] < indicator2)
IF (c1 AND c2) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry and tally < maxTrades THEN
sellshort 1 CONTRACT AT MARKET
ENDIF
//---------------------------------------------------------------------------------------------------------------
once maxTrades = 3 //maxNumberDailyTrades
once tally = 0
if intradayBarIndex = 0 then
tally = 0
endif
newTrades = (onMarket and not onMarket[1]) or ((not onMarket and not onMarket[1]) and (strategyProfit <> strategyProfit[1])) or (longOnMarket and ShortOnMarket[1]) or (longOnMarket[1] and shortOnMarket) or ((tradeIndex(1) = tradeIndex(2)) and (barIndex = tradeIndex(1)) and (barIndex > 0) and (strategyProfit = strategyProfit[1]))
if newTrades then
tally = tally +1
endif
//------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
//Max-Orders per Day
once maxOrdersL = 1 //long
once maxOrdersS = 1 //short
if intradayBarIndex = 0 then //reset orders count
ordersCountL = 0
ordersCountS = 0
endif
if longTriggered then //check if an order has opened in the current bar
ordersCountL = ordersCountL + 1
endif
if shortTriggered then //check if an order has opened in the current bar
ordersCountS = ordersCountS + 1
endif
//------------------------------------------------------------------------------------------------------------------------
// Stops et objectifs
set stop %loss 0.58
set target %profit 0.81
IF Not OnMarket THEN
//
// when NOT OnMarket reset values to default values
//
TrailStart = 1.79 //30 Start trailing profits from this point
BasePerCent = 0.000 //20.0% Profit percentage to keep when setting BerakEven
StepSize = 1 //10 Pip chunks to increase Percentage
PerCentInc = 0.000 //10.0% PerCent increment after each StepSize chunk
BarNumber = 10 //10 Add further % so that trades don't keep running too long
BarPerCent = 0.235 //10% Add this additional percentage every BarNumber bars
RoundTO = -0.5 //-0.5 rounds always to Lower integer, +0.4 rounds always to Higher integer, 0 defaults PRT behaviour
PriceDistance = 9 * pipsize //7 minimun distance from current price
y1 = 0 //reset to 0
y2 = 0 //reset to 0
ProfitPerCent = BasePerCent //reset to desired default value
TradeBar = BarIndex
ELSIF LongOnMarket AND close > (TradePrice + (y1 * pipsize)) THEN //LONG positions
//
// compute the value of the Percentage of profits, if any, to lock in for LONG trades
//
x1 = (close - tradeprice) / pipsize //convert price to pips
IF x1 >= TrailStart THEN // go ahead only if N+ pips
Diff1 = abs(TrailStart - x1) //difference from current profit and TrailStart
Chunks1 = max(0,round((Diff1 / StepSize) + RoundTO)) //number of STEPSIZE chunks
ProfitPerCent = BasePerCent + (BasePerCent * (Chunks1 * PerCentInc)) //compute new size of ProfitPerCent
// compute number of bars elapsed and add an additionl percentage
// (this percentage is different from PerCentInc, since it's a direct percentage, not a Percentage of BasePerCent)
// (if BasePerCent is 20% and this is 10%, the whole percentage will be 30%, not 22%)
BarCount = BarIndex - TradeBar
IF BarCount MOD BarNumber = 0 THEN
ProfitPerCent = ProfitPerCent + BarPerCent
ENDIF
//
ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent)) //make sure ProfitPerCent doess not exceed 100%
y1 = max(x1 * ProfitPerCent, y1) //y1 = % of max profit
ENDIF
ELSIF ShortOnMarket AND close < (TradePrice - (y2 * pipsize)) THEN //SHORT positions
//
// compute the value of the Percentage of profits, if any, to lock in for SHORT trades
//
x2 = (tradeprice - close) / pipsize //convert price to pips
IF x2 >= TrailStart THEN // go ahead only if N+ pips
Diff2 = abs(TrailStart - x2) //difference from current profit and TrailStart
Chunks2 = max(0,round((Diff2 / StepSize) + RoundTO)) //number of STEPSIZE chunks
ProfitPerCent = BasePerCent + (BasePerCent * (Chunks2 * PerCentInc)) //compute new size of ProfitPerCent
// compute number of bars elapsed and add an additionl percentage
// (this percentage is different from PerCentInc, since it's a direct percentage, not a Percentage of BasePerCent)
// (if BasePerCent is 20% and this is 10%, the whole percentage will be 30%, not 22%)
BarCount = BarIndex - TradeBar
IF BarCount MOD BarNumber = 0 THEN
ProfitPerCent = ProfitPerCent + BarPerCent
ENDIF
//
ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent)) //make sure ProfitPerCent doess not exceed 100%
y2 = max(x2 * ProfitPerCent, y2) //y2 = % of max profit
ENDIF
ENDIF
IF y1 THEN //Place pending STOP order when y1 > 0 (LONG positions)
SellPrice = Tradeprice + (y1 * pipsize) //convert pips to price
//
// check the minimun distance between ExitPrice and current price
//
IF abs(close - SellPrice) > PriceDistance THEN
//
// place either a LIMIT or STOP pending order according to current price positioning
//
IF close >= SellPrice THEN
SELL AT SellPrice STOP
ELSE
SELL AT SellPrice LIMIT
ENDIF
ELSE
//
//sell AT MARKET when EXITPRICE does not meet the broker's minimun distance from current price
//
SELL AT Market
ENDIF
ENDIF
IF y2 THEN //Place pending STOP order when y2 > 0 (SHORT positions)
ExitPrice = Tradeprice - (y2 * pipsize) //convert pips to price
//
// check the minimun distance between ExitPrice and current price
//
IF abs(close - ExitPrice) > PriceDistance THEN
//
// place either a LIMIT or STOP pending order according to current price positioning
//
IF close <= ExitPrice THEN
EXITSHORT AT ExitPrice STOP
ELSE
EXITSHORT AT ExitPrice LIMIT
ENDIF
ELSE
//
//ExitShort AT MARKET when EXITPRICE does not meet the broker's minimun distance from current price
//
EXITSHORT AT Market
ENDIF
ENDIF
Bonjour à tous,
J’ai partagé une stratégie algo eurusd 2min et je recherche à intégrer dans cette stratégie la vente partielle en pourcentage quand celui si arrive à( par exemple à 15 euros. je voudrais qu’il me vende 0.5% de la position.)
Est ce possible je ne trouve pas de lien qui puisse m’aider?
Dans l’attente de vous lire et merci.
Merci,
Je voudrais remplacer pointzise par un pourcentage mais je ne suis pas sur de moi , remplacer par percent suffirai ?
merci a toi
Je voudrais l’intégrer dans ma stratégie peux tu me dire si la synthase est bonne?
// Définition des paramètres du code
DEFPARAM CumulateOrders = False // Cumul des positions désactivé
// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position avant l'heure spécifiée
noEntryBeforeTime = 080000
timeEnterBefore = time >= noEntryBeforeTime
// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position après l'heure spécifiée
noEntryAfterTime = 192000
timeEnterAfter = time < noEntryAfterTime
// Empêche le système de placer de nouveaux ordres sur les jours de la semaine spécifiés
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
// Conditions pour ouvrir une position en vente à découvert
indicator1 = SenkouSpanB[9,26,52]
c1 = (close >= indicator1)
indicator2 = SenkouSpanB[9,26,52]
c2 = (low[1] < indicator2)
IF (c1 AND c2) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry and tally < maxTrades THEN
sellshort 1 CONTRACT AT MARKET
ENDIF
//---------------------------------------------------------------------------------------------------------------
once maxTrades = 3 //maxNumberDailyTrades
once tally = 0
if intradayBarIndex = 0 then
tally = 0
endif
newTrades = (onMarket and not onMarket[1]) or ((not onMarket and not onMarket[1]) and (strategyProfit <> strategyProfit[1])) or (longOnMarket and ShortOnMarket[1]) or (longOnMarket[1] and shortOnMarket) or ((tradeIndex(1) = tradeIndex(2)) and (barIndex = tradeIndex(1)) and (barIndex > 0) and (strategyProfit = strategyProfit[1]))
if newTrades then
tally = tally +1
endif
//------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
//Max-Orders per Day
once maxOrdersL = 1 //long
once maxOrdersS = 1 //short
if intradayBarIndex = 0 then //reset orders count
ordersCountL = 0
ordersCountS = 0
endif
if longTriggered then //check if an order has opened in the current bar
ordersCountL = ordersCountL + 1
endif
if shortTriggered then //check if an order has opened in the current bar
ordersCountS = ordersCountS + 1
endif
//------------------------------------------------------------------------------------------------------------------------
// Stops et objectifs
set stop %loss 0.58
set target %profit 0.81
IF Not OnMarket THEN
//
// when NOT OnMarket reset values to default values
//
TrailStart = 1.79 //30 Start trailing profits from this point
BasePerCent = 0.000 //20.0% Profit percentage to keep when setting BerakEven
StepSize = 1 //10 Pip chunks to increase Percentage
PerCentInc = 0.000 //10.0% PerCent increment after each StepSize chunk
BarNumber = 10 //10 Add further % so that trades don't keep running too long
BarPerCent = 0.235 //10% Add this additional percentage every BarNumber bars
RoundTO = -0.5 //-0.5 rounds always to Lower integer, +0.4 rounds always to Higher integer, 0 defaults PRT behaviour
PriceDistance = 9 * pipsize //7 minimun distance from current price
y1 = 0 //reset to 0
y2 = 0 //reset to 0
ProfitPerCent = BasePerCent //reset to desired default value
TradeBar = BarIndex
ELSIF LongOnMarket AND close > (TradePrice + (y1 * pipsize)) THEN //LONG positions
//
// compute the value of the Percentage of profits, if any, to lock in for LONG trades
//
x1 = (close - tradeprice) / pipsize //convert price to pips
IF x1 >= TrailStart THEN // go ahead only if N+ pips
Diff1 = abs(TrailStart - x1) //difference from current profit and TrailStart
Chunks1 = max(0,round((Diff1 / StepSize) + RoundTO)) //number of STEPSIZE chunks
ProfitPerCent = BasePerCent + (BasePerCent * (Chunks1 * PerCentInc)) //compute new size of ProfitPerCent
// compute number of bars elapsed and add an additionl percentage
// (this percentage is different from PerCentInc, since it's a direct percentage, not a Percentage of BasePerCent)
// (if BasePerCent is 20% and this is 10%, the whole percentage will be 30%, not 22%)
BarCount = BarIndex - TradeBar
IF BarCount MOD BarNumber = 0 THEN
ProfitPerCent = ProfitPerCent + BarPerCent
ENDIF
//
ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent)) //make sure ProfitPerCent doess not exceed 100%
y1 = max(x1 * ProfitPerCent, y1) //y1 = % of max profit
ENDIF
ELSIF ShortOnMarket AND close < (TradePrice - (y2 * pipsize)) THEN //SHORT positions
//
// compute the value of the Percentage of profits, if any, to lock in for SHORT trades
//
x2 = (tradeprice - close) / pipsize //convert price to pips
IF x2 >= TrailStart THEN // go ahead only if N+ pips
Diff2 = abs(TrailStart - x2) //difference from current profit and TrailStart
Chunks2 = max(0,round((Diff2 / StepSize) + RoundTO)) //number of STEPSIZE chunks
ProfitPerCent = BasePerCent + (BasePerCent * (Chunks2 * PerCentInc)) //compute new size of ProfitPerCent
// compute number of bars elapsed and add an additionl percentage
// (this percentage is different from PerCentInc, since it's a direct percentage, not a Percentage of BasePerCent)
// (if BasePerCent is 20% and this is 10%, the whole percentage will be 30%, not 22%)
BarCount = BarIndex - TradeBar
IF BarCount MOD BarNumber = 0 THEN
ProfitPerCent = ProfitPerCent + BarPerCent
ENDIF
//
ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent)) //make sure ProfitPerCent doess not exceed 100%
y2 = max(x2 * ProfitPerCent, y2) //y2 = % of max profit
ENDIF
ENDIF
IF y1 THEN //Place pending STOP order when y1 > 0 (LONG positions)
SellPrice = Tradeprice + (y1 * pipsize) //convert pips to price
//
// check the minimun distance between ExitPrice and current price
//
IF abs(close - SellPrice) > PriceDistance THEN
//
// place either a LIMIT or STOP pending order according to current price positioning
//
IF close >= SellPrice THEN
SELL AT SellPrice STOP
ELSE
SELL AT SellPrice LIMIT
ENDIF
ELSE
//
//sell AT MARKET when EXITPRICE does not meet the broker's minimun distance from current price
//
SELL AT Market
ENDIF
ENDIF
IF y2 THEN //Place pending STOP order when y2 > 0 (SHORT positions)
ExitPrice = Tradeprice - (y2 * pipsize) //convert pips to price
//
// check the minimun distance between ExitPrice and current price
//
IF abs(close - ExitPrice) > PriceDistance THEN
//
// place either a LIMIT or STOP pending order according to current price positioning
//
IF close <= ExitPrice THEN
EXITSHORT AT ExitPrice STOP
ELSE
EXITSHORT AT ExitPrice LIMIT
ENDIF
ELSE
//
//ExitShort AT MARKET when EXITPRICE does not meet the broker's minimun distance from current price
//
EXITSHORT AT Market
ENDIF
ENDIF
Bonjour à tous, je remais en poste ma demande .
J’ai partagé une stratégie algo eurusd 2min et je recherche à intégrer dans cette stratégie la vente partielle en pourcentage quand celui si arrive à( par exemple à 15 euros. je voudrais qu’il me vende 0.5% de la position.)
J’ai essayé ce que l’on m’a proposé mais cela ne fonctionne pas. rien ne se passe. Si vous pouviez venir à mon aide je pense que cela pourrais bien améliorer les gains.
Et au passage que pensez vous de la stratégie ?
Dans l’attente de vous lire et merci.
Bonjour,
Je ne sais pas ce qu’est ta variable “percent”, à moins que pour toi percent soit un mot-clé du langage probuilder, dans ce cas la réponse est non, ce n’est pas un mot clé, on peut chercher la doc par mot-clé là si on ne veut pas consulter le manuel page par page:
https://www.prorealcode.com/prorealtime-documentation/
Pointsize sert à convertir 20 en points, tu peux vouloir 20 sur le dax (20*1) mais si tu veux 20 pips sur cfd eurusd par exemple alors tu veux 0.002=20*0.0001 car le pointsize dans ce cas est 0.0001
Il manque de caser le closed=0 de la ligne 3 de l’exemple aussi, à mettre dans la boucle où se fait l’entrée pour laquelle on veut autoriser la cloture partielle.
Enfin, merci de consulter attentivement les règles de publication situées le grand cadre jaune en bas de chaque page, auxquelles on adhère quand on clic sur “submit” message. J’ai déjà dû fusionner 3 topics différents au sein du présent fil de discussion ce weekend, je vois qu’en plus de doubler le message contrairement aux règles du forum la question a été reposée encore en plus dans le forum italien, et ce matin encore un nouveau fil de discussion pour poser la même question dans ce même forum français, que je vais supprimer dans quelques instants…
On pose la question une fois, on la reformule si besoin, mais on maintient la conversation à propos d’un même sujet dans le même fil de discussion, on n’ouvre pas un nouveau fil post par post, ces règles servent à garder un minimum d’ordre pour que les utilisateurs puissent ensuite éxécuter des recherches internes au site fil par fil (et avec posts de library aussi). Pour info si besoin, le moteur de recherche interne est soit en page d’accueil du site, soit en haut à droite de chaque page, première ligne du menu déroulant qui apparait si on survole son avatar avec la souris.
Bonjour , autant pour moi .
je pensais que je devais remonter les conversations et recréer des topics.
EXCUSEZ MOI.
Bonsoir à tous
je voudrais cloturer partiellement une vente sur eurusd mais rienvvne se passe.
J’ai pris la formule suivante partager par nicolas.
Pouvez vous m’aider s’il vous plait
sellshort 1 CONTRACT AT MArket
partiel=0
endif
// sortie partielle
if longonmarket and close-tradeprice>=0.00001*pointsize and partial=0 then
sell countofposition/1 contract at market
partial = 1
endif
Bjr,
L’exemple de Nicolas était :
if rsi[14] crosses over 50 then
buy 2 contracts at market
closed=0
endif
if longonmarket and close-tradeprice>=20*pointsize and closed=0 then
sell 1 contract at market
closed=1
endif
Et tu l’as modifié en :
sellshort 1 CONTRACT AT MArket
partiel=0
endif
// sortie partielle
if longonmarket and close-tradeprice>=0.00001*pointsize and partial=0 then
sell countofposition/1 contract at market
partial = 1
endif
il manque un if au début pour l’entrée, mais on va supposer que c’était juste le copier-coller, pas une erreur de syntaxe à l’origine du “rien ne se passe”.
ligne 2, typo probablement, avec écrit partiEl alors que les autres lignes sont en partiAl
ligne 1 changée en sellshort (une vad) alors qu’elle était en buy (achat) et que les lignes 5 et 6 utilisant les termes “longonmarket” et “sell” qui sont des termes liés au sens acheteur, pas au sens vendeur (termes pour cet autre sens vendeur: “shortonmarket” et “exitshort”) ne sont pas changées aussi, il faut ou tout l’un ou tout l’autre
ligne 6 vend un nombre countofposition/1 ( que le /1 soit typo ou divise par 1 sans conséquence, peu importe) qui n’a rien de partiel.
Donc il y a une cascade de modifications qui chacune à elle seule peut empêcher que ça fonctionne.
Je repars de l’exemple de Nicolas, et je garde en valeur numérique un achat de 2, et une vente partielle de 1, je garde le flag “closed” au lieu d’un “partiel/partial”. Je ne garde pas la condition d’entrée de Nicolas du premier if, je te laisse le soin de la remplacer par la tienne. La modification pour ton cas est si par exemple gain en fin de bougie de 8 points (soit 16 euros hors spread si tu es à 1 euro le point avec 2 contrats 2×8=16 , vu que j’ai cru comprendre que tu parlais d’environ 15, on est dans les environs voulus), alors on change le 20 en 8
if (mettre ici tes conditions d'achats et éventuellement de vérification de non cumul) then
buy 2 contracts at market
closed=0
endif
if longonmarket and close-tradeprice>=8*pointsize and closed=0 then
sell 1 contract at market
closed=1
endif
Bonjour JC.
MERCI POUR LE RETOUR.
Comme tu peux voir j’ai réglé mon robot pour des trades à la vente, du coup j’essai d’intégrer la vente partielle.
J’ai essayé d’intégrer les termes que tu viens de me suggérer mais les profits et perte ne change pas est ce que tu peux m’aider à corriger s’il te plait et me dire pourquoi je n’arrive pas à obtenir des rachats de vente à découvert pour ne garder qu’un contrat..
je te joins l’algo
// Définition des paramètres du code
DEFPARAM CumulateOrders = False // Cumul des positions désactivé
// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position avant l'heure spécifiée
noEntryBeforeTime = 080000
timeEnterBefore = time >= noEntryBeforeTime
// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position après l'heure spécifiée
noEntryAfterTime = 232500
timeEnterAfter = time < noEntryAfterTime
// Empêche le système de placer de nouveaux ordres sur les jours de la semaine spécifiés
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
// Conditions pour ouvrir une position en vente à découvert
c1 = (close > close[10])
indicator1 = SenkouSpanB[9,26,52]
c2 = (close > indicator1)
indicator2 = SenkouSpanA[9,26,52]
c3 = (close > indicator2)
IF (c1 AND c2) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry and tally < maxTrades THEN
sellshort 2 CONTRACT AT MArket
partial=0
endif
// sortie partielle
if shortonmarket and close-tradeprice>=8*pointsize and partial=0 then
exitshort countofposition/1 contract at market
partial = 1
endif
//---------------------------------------------------------------------------------------------------------------
once maxTrades = 3 //maxNumberDailyTrades
once tally = 0
if intradayBarIndex = 0 then
tally = 0
endif
newTrades = (onMarket and not onMarket[1]) or ((not onMarket and not onMarket[1]) and (strategyProfit <> strategyProfit[1])) or (longOnMarket and ShortOnMarket[1]) or (longOnMarket[1] and shortOnMarket) or ((tradeIndex(1) = tradeIndex(2)) and (barIndex = tradeIndex(1)) and (barIndex > 0) and (strategyProfit = strategyProfit[1]))
if newTrades then
tally = tally +1
endif
//------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
//Max-Orders per Day
once maxOrdersL = 1 //long
once maxOrdersS = 1 //short
if intradayBarIndex = 0 then //reset orders count
ordersCountL = 0
ordersCountS = 0
endif
if longTriggered then //check if an order has opened in the current bar
ordersCountL = ordersCountL + 1
endif
if shortTriggered then //check if an order has opened in the current bar
ordersCountS = ordersCountS + 1
endif
//------------------------------------------------------------------------------------------------------------------------
// Stops et objectifs
set stop %loss 0.58
set target %profit 0.11
IF Not OnMarket THEN
//
// when NOT OnMarket reset values to default values
//
TrailStart = 1.74 //30 Start trailing profits from this point
BasePerCent = 0.000 //20.0% Profit percentage to keep when setting BerakEven
StepSize = 1 //10 Pip chunks to increase Percentage
PerCentInc = 0.000 //10.0% PerCent increment after each StepSize chunk
BarNumber = 10 //10 Add further % so that trades don't keep running too long
BarPerCent = 0.235 //10% Add this additional percentage every BarNumber bars
RoundTO = -0.5 //-0.5 rounds always to Lower integer, +0.4 rounds always to Higher integer, 0 defaults PRT behaviour
PriceDistance = 9 * pipsize //7 minimun distance from current price
y1 = 0 //reset to 0
y2 = 0 //reset to 0
ProfitPerCent = BasePerCent //reset to desired default value
TradeBar = BarIndex
ELSIF LongOnMarket AND close > (TradePrice + (y1 * pipsize)) THEN //LONG positions
//
// compute the value of the Percentage of profits, if any, to lock in for LONG trades
//
x1 = (close - tradeprice) / pipsize //convert price to pips
IF x1 >= TrailStart THEN // go ahead only if N+ pips
Diff1 = abs(TrailStart - x1) //difference from current profit and TrailStart
Chunks1 = max(0,round((Diff1 / StepSize) + RoundTO)) //number of STEPSIZE chunks
ProfitPerCent = BasePerCent + (BasePerCent * (Chunks1 * PerCentInc)) //compute new size of ProfitPerCent
// compute number of bars elapsed and add an additionl percentage
// (this percentage is different from PerCentInc, since it's a direct percentage, not a Percentage of BasePerCent)
// (if BasePerCent is 20% and this is 10%, the whole percentage will be 30%, not 22%)
BarCount = BarIndex - TradeBar
IF BarCount MOD BarNumber = 0 THEN
ProfitPerCent = ProfitPerCent + BarPerCent
ENDIF
//
ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent)) //make sure ProfitPerCent doess not exceed 100%
y1 = max(x1 * ProfitPerCent, y1) //y1 = % of max profit
ENDIF
ELSIF ShortOnMarket AND close < (TradePrice - (y2 * pipsize)) THEN //SHORT positions
//
// compute the value of the Percentage of profits, if any, to lock in for SHORT trades
//
x2 = (tradeprice - close) / pipsize //convert price to pips
IF x2 >= TrailStart THEN // go ahead only if N+ pips
Diff2 = abs(TrailStart - x2) //difference from current profit and TrailStart
Chunks2 = max(0,round((Diff2 / StepSize) + RoundTO)) //number of STEPSIZE chunks
ProfitPerCent = BasePerCent + (BasePerCent * (Chunks2 * PerCentInc)) //compute new size of ProfitPerCent
// compute number of bars elapsed and add an additionl percentage
// (this percentage is different from PerCentInc, since it's a direct percentage, not a Percentage of BasePerCent)
// (if BasePerCent is 20% and this is 10%, the whole percentage will be 30%, not 22%)
BarCount = BarIndex - TradeBar
IF BarCount MOD BarNumber = 0 THEN
ProfitPerCent = ProfitPerCent + BarPerCent
ENDIF
//
ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent)) //make sure ProfitPerCent doess not exceed 100%
y2 = max(x2 * ProfitPerCent, y2) //y2 = % of max profit
ENDIF
ENDIF
IF y1 THEN //Place pending STOP order when y1 > 0 (LONG positions)
SellPrice = Tradeprice + (y1 * pipsize) //convert pips to price
//
// check the minimun distance between ExitPrice and current price
//
IF abs(close - SellPrice) > PriceDistance THEN
//
// place either a LIMIT or STOP pending order according to current price positioning
//
IF close >= SellPrice THEN
SELL AT SellPrice STOP
ELSE
SELL AT SellPrice LIMIT
ENDIF
ELSE
//
//sell AT MARKET when EXITPRICE does not meet the broker's minimun distance from current price
//
SELL AT Market
ENDIF
ENDIF
IF y2 THEN //Place pending STOP order when y2 > 0 (SHORT positions)
ExitPrice = Tradeprice - (y2 * pipsize) //convert pips to price
//
// check the minimun distance between ExitPrice and current price
//
IF abs(close - ExitPrice) > PriceDistance THEN
//
// place either a LIMIT or STOP pending order according to current price positioning
//
IF close <= ExitPrice THEN
EXITSHORT AT ExitPrice STOP
ELSE
EXITSHORT AT ExitPrice LIMIT
ENDIF
ELSE
//
//ExitShort AT MARKET when EXITPRICE does not meet the broker's minimun distance from current price
//
EXITSHORT AT Market
ENDIF
ENDIF
Ligne 28, la modif du mot-clé en exitshort est bonne, mais il y a toujours le problème de la quantité évoqué dans le post précédent avec la présence de countofposition
countofposition en théorie est négatif si tu le fais intervenir en vente partielle de short, et même s’il ne l’était pas sa valeur absolue vaut le total des positions, pas la quantité partielle souhaitée, la ligne 23 ayant vendu 2 contrats il faudrait tester avec:
exitshort 1 contract at market
Puis de là, voir si ça va ou s’il faut chercher d’autres anomalies
Hello,
Merci pour le partage. J’ai l’impression qu’on peut en faire quelque chose sur du 10 – 30 secondes…As-tu d’autres systèmes sur ce type d’ut (2m par exemple) ou transposables sur d’autres instruments que NAS?
Merci de ton retour
Bonjour,
as tu esseyé sur du 30sec ? J’ai esseyé pendant un temps mais pas assez de recul dans le temps pour voir
Mais oui j’ai algo sur nadas et eur/usd sur sur 2 minu , 3min et du 5 min .
Je peux partager mais il faudrait travailler dessus
Hello,
J’ai mis en test EUR USD 2M sur du 10 secondes. Cela a l’air de fonctionner. Mais pas beaucoup de recul en effet.
Pourrai tu partager NASDAQ 2 minutes par exemple pour commencer? Peut-être serai t-il aussi valable sur du scalping, style 10 secondes ? Je veux bien tester différentes possibilités. Merci de ton retour…
stratégie eur/usd 2 min
This topic contains 20 replies,
has 4 voices, and was last updated by
Meta Signals Pro
2 years, 5 months ago.
| Forum: | ProOrder : Trading Automatique & Backtests |
| Language: | French |
| Started: | 07/13/2022 |
| Status: | Active |
| Attachments: | 7 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.