# Only 1 position open and only this position close.. Help me for Magic Number Please... :/

1) I want to open only 1 position for this signal using "void " but I couldn't. :(
2) I have more than one signal. and I have a separate close signal for each signal. So I think I need to record the magic number and I need to use this magic number to close but I couldn't :(

Can you write me an example that makes a simple AL and CLOSE operation with Signal = 1 and Signal = 0?

So it will be much more comfortable for me to understand. Thank you very much in advance.

I hope I can find a master who will make me happy.

I use MT5 and MQL5.

Sorry for the following nonsense. Can you edit it the way I want ?

```if(signal==1)
{
int ordercount()
{
total=0;
int i;
for(i=0; i<OrdersTotal(); i++)
{
if(OrderSymbol()!=Symbol() ||
OrderMagicNumber()!=MagicNumber)
continue;
total++;
}
return(total);
}
}

if(ordercount()==0  && signal==1)
{
}

signal=0;

if (signal==0)
{
Close()
}

//+------------------------------------------------------------------+
//| Check for close order conditions                                 |
//+------------------------------------------------------------------+
void Close()
{

//---
for(int i=0;i<OrdersTotal();i++)
{
if(OrderMagicNumber()!=MagicNumber || OrderSymbol()!=Symbol()) continue;
//--- check order type
{
{
if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,White))
Print("OrderClose error ",GetLastError());
}
break;
}
if(OrderType()==OP_SELL)
{
{
Print("OrderClose error ",GetLastError());
}
break;
}
}
//---
}```

```if(signal==1)
{
int ordercount(){ … }
}

if(ordercount()==0  && signal==1)```
1. Don't post code that will not even compile. You can't define a function inside other code.
2. What do you want signal==1 to do?

William Roeder:
1. Don't post code that will not even compile. You can't define a function inside other code.
2. What do you want signal==1 to do?

Can you write me an example that makes a simple AL and CLOSE operation with Signal = 1 and Signal = 0?