I was able to answer my own question, but leaving the answer here in case anyone else runs into the same issue. The keystroke needed to be translated using the TranslateKey() function.
https://docs.mql4.com/common/translatekey
#property strict #property indicator_chart_window //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- if(id == CHARTEVENT_KEYDOWN) Print("ShortToString("+ShortToString(TranslateKey((int)lparam))+")"); } //+------------------------------------------------------------------+
TranslateKey - Common Functions - MQL4 Reference
- docs.mql4.com
TranslateKey - Common Functions - MQL4 Reference
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
I'm not getting the correct characters to display for the corresponding keystroke events. For example when I press the "," key I get "1/4". Am I doing something wrong?
Here is my sample code: