bohardy: the Alert box does not show.
-
Play videoPlease edit your post.
For large amounts of code, attach it.
- Add print statements (with values) before AND inside your if statements and track it down.
int start() // Special function start : void OnTick()
start - old way, OnTick - new way. NOT BOTH.

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
In the following very simple code the Alert box does not show. Can someone tell me what I am doing wrong?
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int Init()
{
//---
Alert("Init");
//---
return(INIT_SUCCEEDED);
}
//-------------------------------------------------------------------+
// CALL SMA INDICATOR
//-------------------------------------------------------------------+
extern int Period_MA = 30; //Calculated MA period
bool Fact_Up = true; //Fact of report that price
bool Fact_Dn = true; //is above or below MA
//-------------------------------------------------------------------
int start() // Special function start
{
double MA; //MA value on 0 bar
Alert("start function");
//-------------------------------------------------------------------
// Technical indicator function call
//-------------------------------------------------------------------
MA=iMA(NULL,0,Period_MA,0,MODE_SMA,PRICE_CLOSE,0);
//-------------------------------------------------------------------
if (Bid > MA && Fact_Up == true) // checking if price is above
{
Fact_Dn = true; //Report about price above MA
Fact_Up = false; //Don't report about price below MA
Alert("Price is below MA (",Period_MA,")."); // Alert
}
//-------------------------------------------------------------------
if (Bid < MA && Fact_Dn == true) //Checking if price below
{
Fact_Up = true; //Report about price below MA
Fact_Dn = false; //don't report about price above MA
Alert ("Price is below MA(",Period_MA,").");//Alert
}
//----------------------------------------------------------------------
return(0); //exit start()
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
}
//+------------------------------------------------------------------+