Re-paste the code using the method below. Otherwise makes it harder to read without the indentations.
Plus where's your start() and ordersend(). Paste the entire code or attach the file.
//----------------------------------- // Time to Open Positions!! //----------------------------------- TOrders=OrdersTotal(); if (TOrders != 5 && ((Hour()>=FromHourTrade && Hour()<=ToHourTrade) || !UseHourTrade)) { double SL,TP; int total,ord,t; //Verifying if an order for this symbol is already open for(t=0; t<total ;t++) { OrderSelect(t,SELECT_BY_POS); if(OrderSymbol() == Symbol())ord++; { if(ord>0) return (0); //Abort! A Position For This Pair is Already Open // Compare current Signals to go long if (stc_o == OPEN_BUY && lsr_o == OPEN_BUY) { Print ("---Creating BUY Order---"); if (Takeprofit!=0) TP = NormalizeDouble(Ask + Takeprofit*Point,Digits); else TP=0; if (Stoploss!=0) SL = NormalizeDouble(Bid - Stoploss*Point,Digits); else SL=0; OPENORDER (1,SL,TP); Print("+++Debug BUY Order+++"); if(ECNmode) { SetStop(); } if(Ticket>0) { if(OrderSelect(Ticket,SELECT_BY_TICKET,MODE_TRADES)) { Print("---BUY Order Opened : ",Symbol(),OrderOpenPrice()); } } } // Compare current signals to go short else if (stc_o == OPEN_SELL && lsr_o == OPEN_SELL) { Print ("---Creating SELL order---"); if (Takeprofit!=0) TP = NormalizeDouble(Bid - Takeprofit*Point,Digits); else TP=0; if (Stoploss!=0) SL = NormalizeDouble(Ask + Stoploss*Point,Digits); else SL=0; OPENORDER (-1,SL,TP); Print("+++Debug BUY Order+++"); if(ECNmode) { SetStop(); } if(Ticket>0) { if(OrderSelect(Ticket,SELECT_BY_TICKET,MODE_TRADES)) { Print("---SELL order opened : ",Symbol(),OrderOpenPrice()); } } else { Print("Error opening SELL order : ",Symbol(),GetLastError()); } } } // end else totalorders > 0 } // End }
Better to read if you use 'SRC' button
TOrders=OrdersTotal(); if (TOrders != 5 &&
OrdersTotal not equal to 5... What if it is 5 ??? What is then your situation ??
if(OrderSymbol() == Symbol())ord++; { if(ord>0) return (0); //Abort! A Position For This Pair is Already Open
So you can't have other EA's or you can't open yourself manual trades same symbol or it will fail... working
Also some things we can't see how it gets its value... stc_o lsr_o OPENORDER (1,SL,TP); SetStop();
TP = NormalizeDouble(Ask + Takeprofit*Point,Digits)
This is not made to trade 4 and 5 digit proof if takeprofit is 40 it is 40 pips on 4 digit notation but 4 pips at 5 digit notation
for(t=0; t<total ;t++) { OrderSelect(t,SELECT_BY_POS);Not checking return codes. If the OrderSelect fails than so does the rest of the code.
int count=0; for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--) if ( OrderSelect(iPos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == Magic.Number // my magic number && OrderSymbol() == chart.symbol // and my pair. ){ count++; } if (count != 5 ...
double SL,TP; int total,ord,t; //total = ????? //Verifying if an order for this symbol is already open for(t=0; t<total ;t++) //t<total ????
WHroeder has shows right how to check your OrdersTotal() counting downwards this is the best way to use
counting up will fail if you trie in the loop also to close trades.. but check your code what is the value of total in your loop ??

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,