Download MetaTrader 5
To add comments, please log in or register
Add our channel to friends and follow the news!
bohardy
12
bohardy 2015.03.15 16:13 

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()

  {

//---

   

  }

//+------------------------------------------------------------------+


whroeder1
13619
whroeder1 2015.03.15 19:42  
bohardy: the Alert box does not show.
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. Add print statements (with values) before AND inside your if statements and track it down.
  3. int start()                          // Special function start
    :
    void OnTick()
    start - old way, OnTick - new way. NOT BOTH.
/
To add comments, please log in or register