Why does it stop to detect for a next signal?

 

Hello dear Mql-programmers,

I got a problem in the following code.

It should return a signal (long/short) if the smaller MA just got over the bigger MA and this signal should  been kept until the price moves above the smaller MA to send the Order. My Porblem is that this only works for the first Order and after that it doesnt even return when bots MA's cross.

(I created some Prints and comments in this code, so that you can look for it by yourself, if you want)

Anyone an idea why this EA doesnt detect another signal after there had been a first order ?(even when i can clearly see another cross on the chart) 

Thx


extern int MA_langperiode=110;
extern int MA_kurzperiode =42;


extern double Lot=0.01;
int Slippage=2;
int LongOrder,ShortOrder;
int MagicNummer=12345;
bool SL_Setzen,TP_Setzen,SL_Setzen2,TP_Setzen2;

static int Ordersiglong,Ordersigshort;

void OnTick()
  {


      double MAlanghandle=iMA(NULL,0,MA_langperiode,0,MODE_SMA,PRICE_CLOSE,0);
      double MAlangVorperiode=iMA(NULL,0,MA_langperiode,0,MODE_SMA,PRICE_CLOSE,1);
      double MAlangVorvorperiode=iMA(NULL,0,MA_langperiode,0,MODE_SMA,PRICE_CLOSE,2);

      double MAkurzhandle=iMA(NULL,0,MA_kurzperiode,0,MODE_SMA,PRICE_CLOSE,0);
      double MAkurzVorperiode=iMA(NULL,0,MA_kurzperiode,0,MODE_SMA,PRICE_CLOSE,1);
      double MAkurzVorvorperiode=iMA(NULL,0,MA_kurzperiode,0,MODE_SMA,PRICE_CLOSE,2);

      static datetime lastOrderSend;

      if(Time[0]!=lastOrderSend)
        {
         Comment("works");
         if(MAkurzhandle>MAlanghandle && (MAkurzVorperiode<=MAlangVorperiode /*||MAkurzVorvorperiode<MAlangVorvorperiode*/)) { Print("2works"); Comment("2works"); Ordersigshort=false; Ordersiglong=true;} 
           else {Print("2no");Comment("2no");}
         if((Time[3])!=lastOrderSend && Bid>=MAkurzhandle && Ordersiglong==true)
           {
            LongOrder=OrderSend(Symbol(),OP_BUY,Lot,Bid,10,0,0,"einfach Long",MagicNummer,0,Green);
            Ordersiglong=false;
            lastOrderSend=Time[0];
            Print("3works");Comment("3works");
           }
         else{Print("3no");Comment("3no");}

         //Short
         if(MAkurzhandle<MAlanghandle && (MAkurzVorperiode>=MAlangVorperiode /*||MAkurzVorvorperiode>MAlangVorvorperiode*/)){Print("2works");Comment("2works"); Ordersiglong=false; Ordersigshort=true;}
          else {Print("2no");Comment("2no");}
         if((Time[3])!=lastOrderSend && Ask<=MAkurzhandle && Ordersigshort==true)
           {
            ShortOrder=OrderSend(Symbol(),OP_SELL,Lot,Ask,10,0,0,"einfach Short",MagicNummer,0,Green);
            //ShortOrder++;
            Ordersigshort=false;
            lastOrderSend=Time[0];
            Comment("3works");
           }
         else{Print("3no");Comment("3no");}
        }
      if(Ordersiglong==true){Comment("SigLong");}
      if(Ordersigshort==true){Comment("SigShort");}
Reason: