# Count by magic number

13

Hi all,

I was wondering if there was a way to fix myEA, it won't place orders because there are other orders open on other pairs etc, not placed on this chart by the EA.

Here's my order code, if you need any more, ask and ill put it up.

So i have an array, where the strategies to be used are set to true.

stratsUsed is a variable where the EA cycles at the start to see how many strategies the user has selected.

I also have a question about trailing stop, but ill post it on another thread to keep relevance.

```void placeOrderCheck()
{
int trueSell=0;
int howManyOrdersOpen=OrdersTotal();
int howManyOrdersEA=0;
int size2=ArraySize(stratsCheckSell);
for
//check for number of strategies signalled to buy
for(int i=0;i<size;i++)
{
{
}
}
//check for number of strategies signalled to sell
for(int x=0;x<size2;x++)
{
if(stratsCheckSell[x]==true)
{
trueSell++;
}
}
//check if total buy is equal to total used, if so, place buy order
{
if(howManyOrdersOpen>=1)
{
}
else
{
}

}

//check if total sell is equal to total used, if so, place sell order
if(trueSell==stratsUsed)
{
if(howManyOrdersOpen>=1)
{
}
else
{
bool c2 = OrderSend(Symbol(), OP_SELL, 0.1, ND(Ask), 10, ND(Bid-StopLoss*Point()), ND(Bid+TakeProfit*Point()));
countSell=0;
}

}

}```

Thanks!

20207

brucey2343:

I was wondering if there was a way to fix myEA,

it won't place orders because there are other orders open on other pairs etc, not placed on this chart by the EA.

1. You fix your broken code.

2. `   int howManyOrdersOpen=OrdersTotal();`
Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles

3. ```        bool c2 = OrderSend(Symbol(), OP_SELL, 0.1, ND(Ask), 10, ND(Bid-StopLoss*Point()), ND(Bid+TakeProfit*Point()));
```
OrderSend does not return a boolean. Check your return codes for errors, and report them including GLE/LE. Don't look at it unless you have an error. Don't just silence the compiler, it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.