Indicator/ea type thing - code please

Hello -
My brain doesn’t work well - - I want a simple .mq4 file that will tell / email / text / pop alert me when
on 15 min chart - the price crosses the 20 ema - don’t care which direction
but
at the ‘same time’ I need for the 1 minute chart to be crossing the 400 ema. again don’t care which direction.

and by the ‘same time’ I mean - in the general vicinity lets say 30 1 minute bars either before or after the 15 mint chart showed a cross - – or if its easier visa versa - first check for 1 min and then see if 15 minute did cross.

here is what I have so far - - I’ve tried a while funtion - and some other stuff - but cannot get it to work.

Oh - and just 1 email / alert / pop menu - per 15 minute candle - - - - - even if the other one crossed several times -don’t care

here is the basics - but I cannot make the magic happen
(Dont’ get hung up on coding mistakes seen here – I can fix those :slight_smile:
SEma = iMA(NULL, PERIOD_M15, , 20, MODE_EMA, PRICE_CLOSE, 0);
LEma = iMA(NULL, PERIOD_M1, 400, 0, MODE_EMA, PRICE_CLOSE, 0);

//----

//----

    if(Bid < LEma && High[0] > LEma && !sent)
      {
           Print("BID < LEma when High > LEma");
           sent = true;
       
      }
    if(Bid < SEma && High[0] > SEma && !sent1)
      {
         Print("Bid < SEma and High > SEma");
         sent1 = true;
      }

below are a couple of options I am trying as well
/*
here is more like what I want
if(Bid < LEma && High[0] > LEma && !sent) //bid is < ema and High is> ema - we have price crossing
{
Print(“BID < LEma when High > LEma”);
sent = true;
if(Bid < SEma && High[0] > SEma && !sent1) //after we have x on 15 - time to check for 1 min chart
{
so inside we have what I think is price x the 15 min chart 20 ema and now checking the 1 mint chart
sendalert()
sendemail() whatever goes here
}

      }

OR do I need to do some sort of looping inside?
if(Bid < LEma && High[0] > LEma && !sent) //bid is < ema and High is> ema - we have price crossing
{
Print(“BID < LEma when High > LEma”);
sent = true;
for(cnt=0;cnt<30;cnt++)
{
if(Bid < SEma && High[cnt] > SEma && !sent1) //after we have x on 15 - time to check for 1 min chart
{
so inside we have what I think is price x the 15 min chart 20 ema and now checking the 1 mint chart
sendalert()
sendemail() whatever goes here
}
}
}