- Requests & Ideas, the beginning
- Multi Timeframe Indicators
- Moving average and price crossover (a must for research!)
ummmm ...
modify 2nd MA compare to be against price ?
Should be a good first MQL4 coding exercise
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);
}
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use