you have to wait a long time, until 2 different calculated MA's with 4 digits are equal in one tick ...
maybe until the end of days - be patient ;-)
i suggest you are testing for a "crossover",you can read a new article here published about that... (decorating indicators)
you have to wait a long time, until 2 different calculated MA's with 4 digits are equal in one tick ...
maybe until the end of days - be patient ;-)
i suggest you are testing for a "crossover",you can read a new article here published about that... (decorating indicators)
Even worse, He's waiting until the calculated MA's are equal to infinite precision.
// if (ma1==ma2) if (NormalizeDouble(ma1-ma2,Digits) == 0)See: Working with Doubles in MQL4
TRY this (I hope it will give you some idea):
int start()
{
//**********up cross*****************
if ( iMA(NULL,0,9,0,MODE_SMA,0,0) >iMA(NULL,0,30,0,MODE_SMA,0,0));
if (iMA(NULL,0,30,0,MODE_SMA,0,1) > iMA(NULL,0,9,0,MODE_SMA,0,1));
{
Alert("Alert","Alert");
//**************down cross****************
if ( iMA(NULL,0,9,0,MODE_SMA,0,0) <iMA(NULL,0,30,0,MODE_SMA,0,0));
if (iMA(NULL,0,30,0,MODE_SMA,0,1) < iMA(NULL,0,9,0,MODE_SMA,0,1));
{
Alert("Alert","Alert");
return(0);
}}
//+-----------
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, this is my first EA and it's very simple and I'm stumped as to why it does not work. Can someone point me in the right direction.
The EA is intended to flash an alert message when the two MAs cross:
//+------------------------------------------------------------------+
//| Moving Average 30 and 9.mq4 |
//| Steven McLachlan |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Steven McLachlan"
#property link "http://www.metaquotes.net"
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----Declare the two integers
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----This just checks if the two moving averages are the same and when so it flashes a message
double ma1;
double ma2;
ma1 = iMA(NULL,0,30,0,MODE_SMA,0,0);
ma2 = iMA(NULL,0,9,0,MODE_SMA,0,0);
if (ma1==ma2)
{
Alert("Alert","Alert");
return(0);
}}
//+-----------