Hello Everyone,
Would someone be able to tell me how to keep an algorithm from opening unwanted orders? I am opening two orders at the same time, and only want to open another set of two orders after both orders have closed. If I remove the check for Ticket1 and Ticket2, then it continues to open a new set of two orders after only one order closes. If I include the Ticket1 and Ticket2 check below, then it will not open any new order at all. Please assist if you can.
int start()
{
int Ticket1 = 0, Ticket2 = 0;
bool IsTrade = False;
if((!IsTrade) && (Ticket1 == 0) && (Ticket2 == 0))
{
RefreshRates();
Ticket1=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,0,0,"",MagicNumber,0,Blue);
Ticket2=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,0,0,"",MagicNumber,0,Blue);
if (Ticket1 < 1 || Ticket2 < 1)
{
lastError = GetLastError();
Print("Error Sending the Market Order: ",ErrorMessage(lastError));
}
}
return(0);
}
Would someone be able to tell me how to keep an algorithm from opening unwanted orders? I am opening two orders at the same time, and only want to open another set of two orders after both orders have closed. If I remove the check for Ticket1 and Ticket2, then it continues to open a new set of two orders after only one order closes. If I include the Ticket1 and Ticket2 check below, then it will not open any new order at all. Please assist if you can.
int start()
{
int Ticket1 = 0, Ticket2 = 0;
bool IsTrade = False;
if((!IsTrade) && (Ticket1 == 0) && (Ticket2 == 0))
{
RefreshRates();
Ticket1=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,0,0,"",MagicNumber,0,Blue);
Ticket2=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,0,0,"",MagicNumber,0,Blue);
if (Ticket1 < 1 || Ticket2 < 1)
{
lastError = GetLastError();
Print("Error Sending the Market Order: ",ErrorMessage(lastError));
}
}
return(0);
}