SMA and price Indicator

 
I am looking for a simple indicator based on SMA and price. If price moves above SMA show an Up arrow if price moves below SMA show a down arrow. I have been looking around but found files which have atleast 2 MA (slow and fast) but i need only one. Can anybody please help me please. I would really appreciate
 

ummmm ...

modify 2nd MA compare to be against price ?

Should be a good first MQL4 coding exercise

 
...or, if you're sort of lazy, you can use MA(1) in those 2 MA indicators. :)
 
brewmanz:

ummmm ...

modify 2nd MA compare to be against price ?

Should be a good first MQL4 coding exercise


I tried to modify it, this is what i have

Can you please help correct this code

double sma1 = iMA(NULL,0,48,0,MODE_SMA,PRICE_CLOSE,i);
if (PRICE_CLOSE>sma1)
{
if (i == 1 && flagval1==0){ flagval1=1; flagval2=0; }
CrossUp[i] = Low[i] - Range*0.75;
}
else if (PRICE_CLOSE<sma1)
{
if (i == 1 && flagval2==0) { flagval2=1; flagval1=0; }
CrossDown[i] = High[i] + Range*0.75;
}
}

if (flagval1==1 && CurTime() > GlobalVariableGet("AlertTime"+Symbol()+Period()) && GlobalVariableGet("SignalType"+Symbol()+Period())!=OP_BUY)
{
// if (GlobalVariableGet("LastAlert"+Symbol()+Period()) < 0.5)
// {
if (SoundON) Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("BUY signal alert","BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
// }
tmp = CurTime() + (Period()-MathMod(Minute(),Period()))*60;
GlobalVariableSet("AlertTime"+Symbol()+Period(),tmp);
GlobalVariableSet("SignalType"+Symbol()+Period(),OP_SELL);
// GlobalVariableSet("LastAlert"+Symbol()+Period(),1);
}

if (flagval2==1 && CurTime() > GlobalVariableGet("AlertTime"+Symbol()+Period()) && GlobalVariableGet("SignalType"+Symbol()+Period())!=OP_SELL) {
// if (GlobalVariableGet("LastAlert"+Symbol()+Period()) > -0.5)
// {
if (SoundON) Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
if (EmailON) SendMail("SELL signal alert","SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
// }
tmp = CurTime() + (Period()-MathMod(Minute(),Period()))*60;
GlobalVariableSet("AlertTime"+Symbol()+Period(),tmp);
GlobalVariableSet("SignalType"+Symbol()+Period(),OP_BUY);
// GlobalVariableSet("LastAlert"+Symbol()+Period(),-1);
}

 
Actually, I think that Drave's idea was better than mine
Reason: