I think the issue is in ShouldWeMartingale(). It's referencing bid and ask, though it might be trying to enter a trade in a different symbol.
Code: Select all
void ShouldWeMartingale()
{
//Looks to see if a losing trade is >= PointsLossToTriggerTrade in the hole, and sends a fresh martingale trade if so.
//Trades are in the direction of the losing trade. Sounds bonkers to me, but there you are.
//Calculate lotsize
//TicketNo saves the ticket of the most recently sent trade
if (!OrderSelect(TicketNo, SELECT_BY_TICKET, MODE_TRADES) ) return;
double SendLots = OrderLots() * MartingaleLotMultiplier;
if (SendLots > MaxLotsAllowed) SendLots = Lot;
RefreshRates();
if (OrderType() == OP_BUY)
{
if (OrderOpenPrice() - Ask > (PointsLossToTriggerTrade * Point))
{
bool result = SendSingleTrade(OrderSymbol(), OP_BUY, TradeComment, SendLots, Ask, 0, 0);
}//if (OrderOpenPrice() - Ask > PointsLossToTriggerTrade * Point)
}//if (OrderType() == OP_BUY)
if (OrderType() == OP_SELL)
{
if (Bid - OrderOpenPrice() > (PointsLossToTriggerTrade * Point))
{
result = SendSingleTrade(OrderSymbol(), OP_SELL, TradeComment, SendLots, Bid, 0, 0);
}//if (Bid - OrderOpenPrice() > PointsLossToTriggerTrade * Point)
}//if (OrderType() == OP_SELL)
}//void ShouldWeMartingale()
Code: Select all
void ShouldWeMartingale()
{
//Looks to see if a losing trade is >= PointsLossToTriggerTrade in the hole, and sends a fresh martingale trade if so.
//Trades are in the direction of the losing trade. Sounds bonkers to me, but there you are.
//Calculate lotsize
//TicketNo saves the ticket of the most recently sent trade
if (!OrderSelect(TicketNo, SELECT_BY_TICKET, MODE_TRADES) ) return;
double SendLots = OrderLots() * MartingaleLotMultiplier;
if (SendLots > MaxLotsAllowed) SendLots = Lot;
RefreshRates();
double sym_bid = MarketInfo(OrderSymbol(),MODE_BID);
double sym_ask = MarketInfo(OrderSymbol(),MODE_ASK);
double sym_point = MarketInfo(OrderSymbol(),MODE_POINT);
if (OrderType() == OP_BUY)
{
if (OrderOpenPrice() - sym_ask > (PointsLossToTriggerTrade * sym_point))
{
bool result = SendSingleTrade(OrderSymbol(), OP_BUY, TradeComment, SendLots, sym_ask, 0, 0);
}//if (OrderOpenPrice() - sym_ask > PointsLossToTriggerTrade * sym_point)
}//if (OrderType() == OP_BUY)
if (OrderType() == OP_SELL)
{
if (sym_bid - OrderOpenPrice() > (PointsLossToTriggerTrade * sym_point))
{
result = SendSingleTrade(OrderSymbol(), OP_SELL, TradeComment, SendLots, sym_bid, 0, 0);
}//if (sym_bid - OrderOpenPrice() > PointsLossToTriggerTrade * sym_point)
}//if (OrderType() == OP_SELL)
}//void ShouldWeMartingale()
SPR wrote:Steve, I am still getting error 129 for already open trades (same things as reported by auvergnat). The very last update running here.