Forum on trading, automated trading systems and testing trading strategies
When you post code please use the CODE button (Alt-S)!
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
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;
}
}
}
//+------------------------------------------------------------------+