Random Exit problem

 

I know this sound fubar but it's just and experiment i want to tri out i have the random entry from an EA on here somewhere but I have been trying to create a random exit for both the buy and sell entries.

any suggestions would be good

//+------------------------------------------------------------------+
//| Ïðîâåðêà íà îòêðûòèå ïîçèöèè                                    |
//+------------------------------------------------------------------+
void checkForOpen()
{
int a = 0;
MathSrand(TimeLocal());
  // Îòîáðàæàåò 10 ÷èñåë.
  for(int i=0;i<10;i++ )
    if(i==5)
    {
      a = MathRand();
      if(a > 16383.5)
      {
      // Ñîâåðøàåì ïîêóïêó
        ticket = OrderSend(Symbol(),OP_BUY,1,Ask,3,0,0,"TestDrawSell",NUM_BUY);
        if (ticket == -1) Alert("Îøèáêà ïðè ñîâåðøåíèè îïåðàöèè ïîêóïêè");
      }
      else
      {
      //Ñîâåðøàåì ïðîäàæó
        ticket = OrderSend(Symbol(),OP_SELL,1,Bid,3,0,0,"TestDrawBuy",NUM_SELL);
        if (ticket == -1) Alert("Îøèáêà ïðè ñîâåðøåíèè îïåðàöèè ïðîäàæè");
      }
    }
    else
    {
      a = MathRand();
    } 
}
                          
//+------------------------------------------------------------------+
void checkForClose()
{

int a = 0;

MathSrand(TimeLocal());
  for(int i=0;i<10;i++ )
    if(i==5)
    {
      a = MathRand();
      if(a > 16383.5)
      {
     //---- check order type 
      if(OrderType()==OP_BUY)
        {
         if(ticket == -1) OrderClose(OrderTicket(),OrderLots(),Bid,3,Blue);
         }
        else
        {
      if(OrderType()==OP_SELL)
        {
         if(ticket == -1) OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);
         }
         }
      }
    }
    else
    {
      a = MathRand();
    } 
}
     
//----
//+------------------------------------------------------------------+
 
kiwi06 wrote >>

I know this sound fubar but it's just and experiment i want to tri out i have the random entry from an EA on here somewhere but I have been trying to create a random exit for both the buy and sell entries.

any suggestions would be good

Right the exit problem is solved but it will not work on multiple pairs. where do i have to look to fixe the problem

Files: