Hi everyone.. hope I formatted this correctly ?
I use the breakeven code a lot in my systems, however I find myself requiring an additonal levels in one of my systems as the breakeven level Vs the Profit level are very wide..
As below.. the points difference is 850 .. to optimise the system further I would like to be able to add another breakeven (or stop move) when the profit gets to 600 points (i.e. after the first breakeven has executed at startbreakeven =150).. many trades reach 600+ points but end up reverting to the 50 point stop.. which is costly..
I dont want to use a stepped trailing stop as its not flexible enough.
// Stops and targets
SET STOP pLOSS 160
SET TARGET pPROFIT 1000
startBreakeven = 150 //how many point gain to activate the breakeven function
PointsToKeep = 50 //how many points profit above or below the entry price when the breakeven is activated
//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*pointsize THEN
//calculate the breakevenLevel
breakevenLevel = TRADEPRICE(1)+PointsToKeep*pointsize
ENDIF
//place the new stop orders on market at breakevenLevel
IF breakevenLevel>0 THEN
SELL AT breakevenLevel STOP
ENDIF
Replace lines 13-22 with these ones (not tested):
//test if the price have moved favourably of "startBreakeven" points already
IF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pointsize AND breakevenLevel=0 THEN
//calculate the breakevenLevel
breakevenLevel = TRADEPRICE(1)+PointsToKeep*pointsize
ENDIF
IF LONGONMARKET AND close-tradeprice(1)>=600*pointsize THEN
//calculate the breakevenLevel
breakevenLevel = TRADEPRICE(1)+(PointsToKeep+300)*pointsize
ENDIF
//place the new stop orders on market at breakevenLevel
IF breakevenLevel>0 THEN
SELL AT breakevenLevel STOP
ENDIF
it will lock an additional 300 pips after a 600-pip temp gain.
JSParticipant
Veteran
Maybe you can use the Standard Deviation:
BreakEvenLevel = TradePrice(1) + Std[n](Close) or BreakEvenLevel = TradePrice(1) + 2 * Std[n](Close)
When the price is going down the Standard Deviation (BreakEvenLevel) will rise…
Ciao Roberto,
It Works really well on backtest.. thankyou so much..