Hello everyone ! I use the following code for break-even trades. This works perfectly (for example: when I have 5 pips profit on the EUR/USD my stop loss change from -10 pips change to +1 pip so I can’t lose anymore on this position:
startBreakeven = 5 //how much pips/points in gain to activate the breakeven function?
PointsToKeep = 1 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)
//reset the breakevenLevel when no trade are on market
IF NOT ONMARKET THEN
breakevenLevel=0
ENDIF
//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
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
I searched this forum but can’t find anything about it. Does anyone know if it is possible to do something similar with a profit target ? For example my system opens a trade as follows:
Stop loss: 10 pips
Profit target: 10 pips
If I lose 5 pips (-5) in an open losing position then I want to move my profit target automatically from +10 pips to -1 pips. From here there are 2 scenarios:
Losing 1 pip (profit target)
Losing 10 pips (stop loss)
Thank you.
I never heard about this technique.
You can use the same code reversing conditions, look for losses and as soon as you reach -startbreakeven you set breakeven to Tradeprice – PointsToKeep.