// Valeur du Stop SUiveur
DEFPARAM CumulateOrders = False
startBreakeven = 9 //how much pips/points in gain to activate the breakeven function?
PointsToKeep = 2 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)
Seuil = 20
stopgaranti = 70
c1=rsi[60](close) crosses over 50
c2=rsi[60](close) crosses under 50
// Condition prise de position achat
IF not onmarket and c1 THEN
BUY 1 CONTRACT AT MARKET
TRAIL= Close - Stopgaranti
ENDIF
// Condition prise de position vente
IF not onmarket and c2 THEN
sellshort 1 CONTRACT AT MARKET
TRAIL= Close + Stopgaranti
ENDIF
// trailing stop ***********************************************************************************************
// trailing achat ***********************************************
// 1er mouvement trailing achat
if TRAIL= Close - Stopgaranti and close-seuil>tradeprice then
trail = close - Seuil
endif
// Mise à jour du cours achat
IF longonmarket and close-seuil>tradeprice and close-Seuil > trail THEN
trail = close - Seuil
ENDIF
// trailing vente ***********************************************
// 1er mouvement trailing vente
if TRAIL= Close + Stopgaranti and close+seuil<tradeprice then
trail = close + Seuil
endif
// Mise à jour du cours de vente
IF shortonmarket and close+seuil<tradeprice and close+Seuil < trail THEN
trail = close + Seuil
ENDIF
// breakeven****************************************************************************************
//reset the breakevenLevel when no trade are on market
IF NOT ONMARKET THEN
breakevenLevel=0
ENDIF
// --- BUY SIDE ---
//test if the price have moved favourably of "startBreakeven" points already
IF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN
//calculate the breakevenLevel
breakevenLevel = tradeprice(1)+PointsToKeep*pipsize
ENDIF
//place the new stop orders on market at breakevenLevel
IF breakevenLevel>0 THEN
SELL AT breakevenLevel STOP
ENDIF
// --- end of BUY SIDE ---
// --- sellshort SIDE ---
//test if the price have moved favourably of "startBreakeven" points already
IF shortONMARKET AND tradeprice(1)-close>=startBreakeven*pipsize THEN
//calculate the breakevenLevel
breakevenLevel = tradeprice(1)-PointsToKeep*pipsize
ENDIF
//place the new stop orders on market at breakevenLevel
IF breakevenLevel>0 THEN
exitshort AT breakevenLevel STOP
ENDIF
// --- end of sellshort SIDE ---
// Ordre de vente STOP achat
IF LONGONMARKET THEN
SELL AT TRAIL STOP
SET STOP PLOSS 75
ENDIF
// order de vente stop vente
if shortonmarket then
exitshort at trail stop
SET STOP PLOSS 75
endif