one trade per condition
int Number_of_Orders() { TicketNo = -1; if(OrdersTotal() == 0) { return(0); } for(int cc = OrdersTotal() - 1; cc >= 0; cc--) { if(!OrderSelect(cc, SELECT_BY_POS)) { return(-1); } if(OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol()) { TicketNo = OrderTicket(); return(1); } } return(0); }
Error occurred:
if(Number_of_Orders() < 0)
Send new order only::
if(Number_of_Orders() == 0)
//============================================================================= bool O_R_CheckForHistory(int ticket) { int lastTicket = OrderTicket(); int cnt = 0; int err = GetLastError(); // so we clear the global variable. err = 0; bool exit_loop = false; bool success=false; while (!exit_loop) { /* loop through open trades */ int total=OrdersTotal(); for(int c = 0; c < total; c++) { if(OrderSelect(c,SELECT_BY_POS,MODE_TRADES) == true) { if (OrderTicket() == ticket) { success = true; exit_loop = true; } } } if (cnt > 3) { /* look through history too, as order may have opened and closed immediately */ total=OrdersHistoryTotal(); for(c = 0; c < total; c++) { if(OrderSelect(c,SELECT_BY_POS,MODE_HISTORY) == true) { if (OrderTicket() == ticket) { success = true; exit_loop = true;
what about here ?
Dimitar Pavlov #: what about here ?
bool O_R_CheckForHistory(int ticket){ int lastTicket = OrderTicket();
You can not use any Trade Functions until you first select an order.
Im trying to make EA to make only 1 trade per condition, but it makes multiple trades , where im wrong ?