Topic: MT4-FST Expert v13-Beta - BreakEven corrected.
- Bug fixed with Breakeven for a short position when the initial SL = 0;
- Expert recognizes FXCM, FXOpen and ODL for late SL and TP setting with additional OrderModify().
FXOpen is questionable. I'm not sure if they accept instant setting of SL and TP with OrderSend() or not. Any feed back is welcome.
The corrected BreakEven code:
///
/// 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_Activating_Distance)
breakeven = BreakEven_Activating_Distance;
else if(BreakEven_Activating_Distance > 2000)
breakeven = 2000;
if (PositionType == OP_BUY)
{
double bid = MarketInfo(symbol, MODE_BID);
if (bid - PositionOpenPrice >= Point * breakeven)
if (PositionStopLoss < PositionOpenPrice)
SetStopLossAndTakeProfit(symbol, PositionOpenPrice, PositionTakeProfit);
}
else if (PositionType == OP_SELL)
{
double ask = MarketInfo(symbol, MODE_ASK);
if (PositionOpenPrice - ask >= Point * breakeven)
if (PositionStopLoss == 0 || PositionStopLoss > PositionOpenPrice)
SetStopLossAndTakeProfit(symbol, PositionOpenPrice, PositionTakeProfit);
}
}