Here's the way I would Naturally do it. Other efficient methods https://www.mql5.com/en/forum/139415.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void start(){ Alert_Ma_CrossOver(); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void Alert_Ma_CrossOver(){ if(StringFind(Symbol(),"JPY")>-1){ int _2Real=100;}else{_2Real=10000;} //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int d5EMA_C = iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,0)*_2Real; int d5EMA_P = iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,1)*_2Real; int d10EMA_C =iMA(NULL,0,10,0,MODE_EMA,PRICE_CLOSE,0)*_2Real; int d10EMA_P =iMA(NULL,0,10,0,MODE_EMA,PRICE_CLOSE,1)*_2Real; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(d5EMA_C>d10EMA_C && d5EMA_P<=d10EMA_P){bool CrossUp=true;} if(d5EMA_C<d10EMA_C && d5EMA_P>=d10EMA_P){bool CrossDn=true;} //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(CrossUp || CrossDn){Alert("Cross");} //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Thanks ubzen, it's exactly what I needed
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi everyone,
I have a lot of experience with C and Java, so I though I'd start working on a simple MQL4 script that would alert me every time a 10EMA crosses a 5EMA, in any currencies available.
I don-t want it to trade, just to alert me, then I would manually review whether it's a good idea or not to trade.
Ideally it'd also check the stocha, MACD and ADX, but for now I'm having trouble simply with the EMA crosses.
Here's the basic code (the whole code is a bit more complexe as it handles all the currencies but here's the idea):