Bonjour,
Je me retrouve avec beaucoup de SL ou de TP à100 alors que j’ai mis un BREAKEVEN ainsi qu’une clôture partielle à 50% => donc je de vrait jamais avoir de TP complet (à 100) mais seulement à 50 max.
Voici le code. Merci pour votre aide.
/SECURISATION
//Ordre Achat
IF achat and Not OnMarket THEN
BUY 1 CONTRACT AT MARKET
SLFinance = 0
ENDIF
//StopLoss financé à x points en coupant la moitié de la position
if longonmarket and close-tradeprice>=25 and SLFinance = 0 then
sell COUNTOFPOSITION/2 CONTRACTS AT MARKET
set stop BREAKEVEN //////////////////////////////////////////////////////////////
SLFinance = 1
endif
//Ordre Vente
IF vente and Not OnMarket THEN
SELLSHORT 1 CONTRACT AT MARKET
SLFinance = 0
ENDIF
//StopLoss financé à x points en coupant la moitié de la position
If shortonmarket and tradeprice-close>=25 and SLFinance = 0 then
BUY COUNTOFPOSITION/2 CONTRACTS AT MARKET
set stop BREAKEVEN //////////////////////////////////////////////////////////////
SLFinance = 1
endif
// Stops and targets
SET STOP pLOSS 25
SET TARGET pPROFIT 100
Sur les lignes 12 et 23, il est préférable d’ajouter /PipSize, sinon 25 risque de ne pas être converti correctement en différence de prix :
if longonmarket and close-tradeprice>=25/PipSize and SLFinance = 0 then
If shortonmarket and tradeprice-close>=25/PipSize and SLFinance = 0 then
Utilisez EXITSHORT pour quitter une position courte :
EXITSHORT
Utilisez ABS() avec CountOfPosition, car il renvoie une valeur négative pour les opérations courtes :
EXITSHORT abs(COUNTOFPOSITION)/2 CONTRACTS AT MARKET
Entendu merci Roberto pour le retour.
Par contre, je n’ai toujours aucun trade stopé à BE sur un test de 50K Unité. La sortie BE est elle bien codé ?
JSParticipant
Senior
Le problème est que la commande Set Stop BreakEven à la ligne 13 et à la ligne 25 est écrasée par la commande Set Stop pLoss 25 à la ligne 30…
Par conséquent, le BreakEven n’est jamais activé…
JS a raison, voici le code mis à jour :
//SECURISATION
//Ordre Achat
IF achat and Not OnMarket THEN
BUY 1 CONTRACT AT MARKET
SLFinance = 0
SET STOP pLOSS 25
SET TARGET pPROFIT 100
ENDIF
//StopLoss financé à x points en coupant la moitié de la position
if longonmarket and close-tradeprice>=25/PipSize and SLFinance = 0 then
sell COUNTOFPOSITION/2 CONTRACTS AT MARKET
set stop BREAKEVEN //////////////////////////////////////////////////////////////
SLFinance = 1
endif
//Ordre Vente
IF vente and Not OnMarket THEN
SELLSHORT 1 CONTRACT AT MARKET
SLFinance = 0
SET STOP pLOSS 25
SET TARGET pPROFIT 100
ENDIF
//StopLoss financé à x points en coupant la moitié de la position
If shortonmarket and tradeprice-close>=25/PipSize and SLFinance = 0 then
EXITSHORT abs(COUNTOFPOSITION)/2 CONTRACTS AT MARKET
set stop BREAKEVEN //////////////////////////////////////////////////////////////
SLFinance = 1
endif
Merci à tout les 2. Ca avance 🙂