Here is how to make Break Even closing on several points profit.
Find the "External variables" section on line 80 and add this external variable:
extern int Break_Even_Shift = 5;
It will be visible when starting the expert and you can set the Break Even shift in points. The default is 5, but you can change it.
After that find the "void SetBreakEvenStop(string symbol)" function on line 1031 and replace it with that one:
///
/// Sets a BreakEven stop of current positions.
///
void SetBreakEvenStop(string symbol)
{
if (SetAggregatePosition(symbol) <= 0)
return;
double breakeven = MarketInfo(symbol, MODE_STOPLEVEL);
if (breakeven < BreakEven)
breakeven = BreakEven;
double breakprice = 0; // Break Even price including commission.
double commission = 0; // Commission in pips.
if (PositionCommission != 0)
commission = MathAbs(PositionCommission) / MarketInfo(symbol, MODE_TICKVALUE);
double point = MarketInfo(symbol, MODE_POINT);
double digits = MarketInfo(symbol, MODE_DIGITS);
if (PositionType == OP_BUY)
{
double bid = MarketInfo(symbol, MODE_BID);
breakprice = NormalizeDouble(PositionOpenPrice + point * Break_Even_Shift + point * commission / PositionLots, digits);
if (bid - breakprice >= point * breakeven)
if (PositionStopLoss < breakprice)
{
SetStopLossAndTakeProfit(symbol, breakprice, PositionTakeProfit);
Print("Break Even (", BreakEven, " pips) set Stop Loss to ", breakprice, ", Bid = ", bid);
}
}
else if (PositionType == OP_SELL)
{
double ask = MarketInfo(symbol, MODE_ASK);
breakprice = NormalizeDouble(PositionOpenPrice - point * Break_Even_Shift - point * commission / PositionLots, digits);
if (breakprice - ask >= point * breakeven)
if (PositionStopLoss == 0 || PositionStopLoss > breakprice)
{
SetStopLossAndTakeProfit(symbol, breakprice, PositionTakeProfit);
Print("Break Even (", BreakEven, " pips) set Stop Loss to ", breakprice, ", Ask = ", ask);
}
}
}
There are two modifications only. For long position:
breakprice = NormalizeDouble(PositionOpenPrice + point * commission / PositionLots, digits);
changed to:
breakprice = NormalizeDouble(PositionOpenPrice + point * Break_Even_Shift + point * commission / PositionLots, digits);
And for short position:
breakprice = NormalizeDouble(PositionOpenPrice - point * commission / PositionLots, digits);
changed to:
breakprice = NormalizeDouble(PositionOpenPrice - point * Break_Even_Shift - point * commission / PositionLots, digits);