OnChartEvent() ... does not work in Indicator but in strategy do.

 

dear, can OnChartEvent() work in indicator? ( according to manual yes) but this code as indicator doesn't work. Do you know why, please?


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

//| ChartEvent function                                              |

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

void OnChartEvent(const int id,

                  const long &lparam,

                  const double &dparam,

                  const string &sparam)

  {

//---

   //---

   ResetLastError();

   RefreshRates();

   //--

   static bool keyPressed=false;


//--- this is an Event of a keystroke

   if(id==CHARTEVENT_KEYDOWN)

     {

      if(lparam==KEY_PLUS || lparam==KEY_MINUS)

        {

         if(!keyPressed) keyPressed=true;

         else keyPressed=false;

        }

      //--

      switch(int(lparam)) 

        { 

          case KEY_PLUS:  

                 {

                    //.... etc

                    MessageBox("PLUS");

                 }

               break;


          case KEY_MINUS: 

                 {

                    //.... etc

                    MessageBox ("MINUS");

                 }

               break;

        }


     }

  }

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


Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • www.mql5.com
Dozens of new automated trading applications appear in the MQL5 Market every day. Choose the right app among 10,000 products and forget about unnecessary routine operations of manual trading. Sell your algorithmic trading programs through the largest store of trading applications! One Click Close The script allows users to easily close...
 

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button