Bonjour,
Je rencontre un souci pour la mise en place du stop loss, je voudrai que celui-ci évolue et se replace quand un niveau de profit est atteint, toutefois avec le code que j’ai écris il ne se passe rien (il ne sort jamais du marché…) pouvez vous m’aider?
Merci
Defparam CumulateOrders=False
MM = Average[20]
// Conditions pour ouvrir une position acheteuse
IF CLOSE < MM THEN
BUY 1 CONTRACTS AT MARKET
SET STOP LOSS 50
ENDIF
IF close > (TRADEPRICE+100) then
SET STOP LOSS (TRADEPRICE+50)
ENDIF
IF close > (POSITIONPRICE+200) then
SET STOP LOSS (POSITIONPRICE+150)
ENDIF
IF STRATEGYPROFIT < -1000 THEN
QUIT
ENDIF
Bonjour,
Je déplace le sujet du forum ProBuilder (pour indicateurs) au forum ProOrder (stratégies auto et backtests).
Si la ligne 8 utilise correctement set stop loss avec une distance plutôt qu’un niveau de prix, ce n’est pas le cas des lignes 11 et 14. Si on veut exprimer un niveau de prix plutôt qu’une distance, on peut utiliser par exemple l’instruction set stop price
set stop loss https://www.prorealcode.com/documentation/ploss/
set stop price https://www.prorealcode.com/documentation/price/
Merci du coup en suivant cela j’ai écris ainsi mais ça ne marche toujours pas ( le stop price n’intervient jamais)?
BUY 1 CONTRACTS AT MARKET
SET STOP LOSS 50
ENDIF
IF close > (TRADEPRICE+100) then
SET STOP PRICE (TRADEPRICE+50)
ENDIF
IF close > (POSITIONPRICE+200) then
SET STOP PRICE (TRADEPRICE+50)
ENDIF
Est-ce que la valeur du point est de 1 ? (POINTSIZE), quel est l’instrument ?
La valeur du point est de 5 ( Mini FTSE) en fait je voudrai que le stop loss a 50 (10point) soit pris a l’achat et que ensuite si le prix augmente de 100 (20points) alors le stop loss soit déplacé a + 10 points par rapport au prix de l’achat et ainsi de suite… mais du coup dois-je plutôt utiliser POSITONPRICE plutôt que TRADEPRICE ou faire autrement? merci beaucoup
Désolé je voulais dire la taille du point (POINTSIZE et non POINTVALUE).
Bref, si tu veux 20 points alors utilise cette formulation:
IF close > (TRADEPRICE+20*pointsize) then
SET STOP PRICE (TRADEPRICE+10*pointsize)
ENDIF
D’ailleurs ton stoploss devrait être :
SET STOP PLOSS 10 //10 points
Bonjour,
Je bloque toujours sur la mise en place d’un stop loss qui changerai suite a l’évolution du prix, en fait celui-ci n’exécute que la dernière commande de stop ptrailing 100 et si je l’enlève il n’éxecute que le stop a (tradeprice+50)… Pouvez vous m’aider?
ST = Supertrend[3,30]
IF Not onmarket and CLOSE crosses over ST and CLOSE > OPEN THEN
BUY 1 SHARE AT MARKET
set stop loss 200
Endif
if LOngonmarket and Close > (tradeprice+75*pointsize) then
set stop loss 0
set stop price (Tradeprice+50)
endif
if LOngonmarket and Close > (tradeprice+180*pointsize) then
set stop price 0
set stop price (Tradeprice+90*pointsize)
endif
if LOngonmarket and Close > (tradeprice+250*pointsize) then
set stop price 0
set stop price (Tradeprice+160*pointsize)
endif
if LOngonmarket and Close > (tradeprice+300*pointsize) then
set stop price 0
set stop ptrailing 100
endif
piuf, tu te complique la vie pour rien,
garde ton set stoploss x
et tu rajoutes :
TGL0 = x (nb de point ou le Trailing Stop pour un achat commence)
TGS0 = x (nb de point ou le Trailing Stop pour une vente commence)
IF not onmarket THEN
MINPRICE = close
MAXPRICE = 0
PRICEXIT = 0
ENDIF
IF longonmarket THEN
MAXPRICE = MAX(MAXPRICE,close)
IF MAXPRICE - tradeprice(1) >= TGL0 * pointsize THEN
PRICEXIT = MAXPRICE - TGL0 * pointsize
ENDIF
ENDIF
IF shortonmarket then
MINPRICE = MIN(MINPRICE,close)
IF tradeprice(1) - MINPRICE >= TGS0 * pointsize THEN
PRICEEXIT = MINPRICE + TGS0 * pointsize
ENDIF
ENDIF
IF onmarket and PRICEXIT>0 THEN
SELL at PRICEXIT STOP
ENDIF
Bonjour, merci de votre aide, du coup j’ai modifié en mettant TGLO et TGSO a 300 (donc le stop suiveur devrait commencer a +300 et avant il devrait y avoir des “paliers” mais de combien? ) et en fait sur le backtest il vend un lot mais ne sort jamais… j’ai du faire une erreur?
Defparam CumulateOrders=False
ST = Supertrend[3,30]
TGL0 = 300 //(nb de point ou le Trailing Stop pour un achat commence)
TGS0 = 300 //(nb de point ou le Trailing Stop pour une vente commence)
IF Not onmarket and CLOSE crosses over ST and CLOSE > OPEN THEN
BUY 1 SHARE AT MARKET
set stop loss 200
Endif
IF not onmarket THEN
MINPRICE = close
MAXPRICE = 0
PRICEXIT = 0
ENDIF
IF longonmarket THEN
MAXPRICE = MAX(MAXPRICE,close)
IF MAXPRICE – tradeprice(1) >= TGL0 * pointsize THEN
PRICEXIT = MAXPRICE – TGL0 * pointsize
ENDIF
ENDIF
IF Not onmarket and CLOSE crosses under ST and CLOSE < OPEN THEN
Sellshort 1 SHARE AT MARKET
set stop loss 200
Endif
IF shortonmarket then
MINPRICE = MIN(MINPRICE,close)
IF tradeprice(1) – MINPRICE >= TGS0 * pointsize THEN
PRICEEXIT = MINPRICE + TGS0 * pointsize
ENDIF
ENDIF
IF onmarket and PRICEXIT>0 THEN
SELL at PRICEXIT STOP
ENDIF