I want my EA to have a custom button on screen. When I press this button it should allow me to place a horizontal line on the chart.
However, whenever I click on my button, the Hline(s) is/are also immediately placed.
It seems the CHAREVENT_CLICK gets triggered anyways.
Anyone can help me fix this? I am using MT4
Check out this test code:
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { static int iCnt = 0; Print ("iCnt = ", iCnt++, ", id = ", id); }
You'll see that one click on the chart object can trigger-off multiple calls to OnChartEvent() one right after the other. So what you observed is not unexpected.
To separate them, you can perhaps check time...
Check out this test code:
You'll see that one click on the chart object can trigger-off multiple calls to OnChartEvent() one right after the other. So what you observed is not unexpected.
To separate them, you can perhaps check time...
Thank you for your reply. This will indeed help me further.
Thank you for your reply. This will indeed help me further.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I want my EA to have a custom button on screen. When I press this button it should allow me to place a horizontal line on the chart.
However, whenever I click on my button, the Hline(s) is/are also immediately placed.
It seems the CHAREVENT_CLICK gets triggered anyways.
Anyone can help me fix this? I am using MT4
See my code: