|
Ok...found part of the problem, at least! The MinWait computation in the "Close in profit" functions is not fully supported in Strategy Test mode so replace the functions with these:
void CloseBuysinProfit()
{
double BuyProfit, LastBuyTime;
for (int i = OrdersTotal() - 1; i >= 0; i--)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_BUY)
{
BuyProfit = OrderProfit() + OrderSwap() + OrderCommission();
if (OrderOpenTime() > LastBuyTime) LastBuyTime = OrderOpenTime();
if ((IsTesting() || TimeCurrent() - LastBuyTime >= MinTime) && BuyProfit > 0) OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
}
}
}
return;
}
//+-----------------------------------------------+
//| Closes all Sells in Profit
//+-----------------------------------------------+
void CloseSellsinProfit()
{
double SellProfit, LastSellTime;
for (int i = OrdersTotal() - 1; i >= 0; i--)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_SELL)
{
SellProfit = OrderProfit() + OrderSwap() + OrderCommission();
if (OrderOpenTime() > LastSellTime) LastSellTime = OrderOpenTime();
if ((IsTesting() || TimeCurrent() - LastSellTime >= MinTime) && SellProfit > 0) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red);
}
}
}
return;
}
Neo
|