Hi all,
I took the following code straight from the MQL site , just basically put it inside a function that returns boolean based on the outcome and for some reason it is totally stopping the EA entirely.
I'm running it in the strategy tester, without this code, the tester works and processes as expected, with it, the tester just stops as soon as it starts - it prints the first line to the journal window and stops.
Any ideas appreciated - i lifted the block straight out of the sample here:
http://book.mql4.com/samples/expert
I took the following code straight from the MQL site , just basically put it inside a function that returns boolean based on the outcome and for some reason it is totally stopping the EA entirely.
I'm running it in the strategy tester, without this code, the tester works and processes as expected, with it, the tester just stops as soon as it starts - it prints the first line to the journal window and stops.
Any ideas appreciated - i lifted the block straight out of the sample here:
http://book.mql4.com/samples/expert
Inserted Code
bool checkOpenOrders()
{
// Check for existing orders on the pair - exit EA if orders already open
bool cont = false;
string Symb=Symbol(); // Security name
int Total=0; // Amount of orders
Print("Checking for existing orders on " + Symb);
for(int i=1; i>=OrdersTotal(); i++) // Loop through orders
{
if (OrderSelect(i-1,SELECT_BY_POS)==true) // If there is the next one
{ // Analyzing orders:
if (OrderSymbol()!=Symb)continue; // Another security
if (OrderType()>1) // Pending order found
{
Print("Pending order detected. EA doesnt work.");
cont=true;
}
Total++; // Counter of market orders
if (Total<1) // No more than one order
{
Print("Several market orders. EA doesnt work.");
cont=true;
}
int Ticket=OrderTicket(); // Number of selected order
int Tip =OrderType(); // Type of selected order
double Price =OrderOpenPrice(); // Price of selected order
double SL =OrderStopLoss(); // SL of selected order
double TP =OrderTakeProfit(); // TP of selected order
double Lot =OrderLots(); // Amount of lots
}
}
return(cont);
}