zkucera wrote:Hi Steve/George,
Sorry for being so insistent, but I still think there is an issue.
The code says
if (TicketNo > -1 && !OrderSelect(TicketNo, SELECT_BY_TICKET, MODE_TRADES) )
{
while (!OrderSelect(TicketNo, SELECT_BY_TICKET, MODE_HISTORY) ) Sleep(100);
}//if (TicketNo > -1 && !OrderSelect(TicketNo, SELECT_BY_TICKET, MODE_TRADES) )
TradeExists = DoesTradeExist(TradePair);
if (TradeExists)
{
//if (OrderProfit() > 0) TradeManagementModule();
LookForTradeClosure();
}//if (TradeExists)
On my PC, the code didn't get as far as calling DoesTradeExist() because it was going into the while ... sleep loop. I have tested this adding Alert(TicketNo) line at the top of start() code and it only popped up once with value 0.
Could it be that instead of TicketNo > 0 the code needs to be rearranged to call DoesTradeExist() first?
TradeExists = DoesTradeExist(TradePair);
if (TradeExists)
{
//if (OrderProfit() > 0) TradeManagementModule();
LookForTradeClosure();
}//if (TradeExists)
if (TicketNo > -1 && !OrderSelect(TicketNo, SELECT_BY_TICKET, MODE_TRADES) )
{
while (!OrderSelect(TicketNo, SELECT_BY_TICKET, MODE_HISTORY) ) Sleep(100);
}//if (TicketNo > -1 && !OrderSelect(TicketNo, SELECT_BY_TICKET, MODE_TRADES) )
You are correct, if you have an order open already when you start the bot, you will be stuck in that loop. Add the following to the Init() procedure:
Doesn't really matter where. Thanks for catching this.
BTW, in the future, use the
Code: Select all
button at the top of the reply window when you put in code. It makes it so much easier to read!
George