'While' within a 'While' operator could it be the reason pls HELP!!

 

I wrote a simple Ea to send order when certain crirteria are fulfilled.In my codes are while operators used within another while operator and also some user defined function.The program compiled without any error,but the EA will not run,it will even hang the terminal.I tried run it on strategy tester it brings this error --( TestGenerator;unmatched data error).pls somebody should help look into thhis.I have attached the EA to this text .Thank you.

 

Unmatched data I think usually refers to misaligned tick data. Try redownloading the symbol history. I'm curious why you are using while loops, why not just if...thens? Usually if the expert is hanging your best bet it is one of the many while loops. Why not just utilize the start function? That function is hit every time a new tick comes.


   if (time0 != Time[0]) {
      if(hangingman == true && uptrend == true){
         if (StopLoss != 0) ldStop = pBid + StopLoss * Point;
         if (TakeProfit != 0) ldTake = pBid-TakeProfit * Point;
         int Ticket = SetOrder(OP_SELLSTOP, pBid, ldStop, ldTake);
	    if(Ticket < 0){
	       time0 =0;
         }else{
            time0=Time[0];
         }
      }

      if(hammer == true && downtrend == true){
	    if (StopLoss != 0) ldStop = pAsk - StopLoss * Point;
         if (TakeProfit != 0) ldTake = pAsk + TakeProfit * Point;
         int Ticket1 = SetOrder(OP_BUYSTOP, pAsk, ldStop, ldTake);
	    if(Ticket1 < 0){
            time0 = 0;
         }else{
            time0=Time[0];
	    }
      }
    }