Hi everybody,
I found a strange behavior on MT5 with ChartIndicatorAdd function :
- in my EA, a use ChartIndicatorAdd function and the indicator is showed perefctly on the chart (with the good parameters "Apply" at [Median Price])
- I change the Period of the Chart (for exemple from Daily to H4)
- The indicator parameter "Apply" has changed to [Close] !!
Is there something wrong with ChartIndicatorAdd function ?
Thx for your reply,
Erwann.
Please show all the relevant code to reproduce this issue.
Here is the code you just have to copy in a new EA :
//+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- if (id == CHARTEVENT_KEYDOWN) { MqlParam params[10]; params[0].type = TYPE_STRING;params[0].string_value = "Examples\\Custom Moving Average.ex5"; params[1].type = TYPE_INT;params[1].integer_value = 9; params[2].type = TYPE_INT;params[2].integer_value = 0; params[3].type = TYPE_INT;params[3].integer_value = 2; params[4].type = TYPE_INT;params[4].integer_value = 5; int my_handle = IndicatorCreate(NULL,0,IND_CUSTOM,5,params); Print(my_handle); ChartIndicatorAdd(0,0,my_handle); } }
I provide EA in attached document.
You just have to launch EA in a new graphic and press any Key (that create indicator and add it into chart) :
After, just change the Timeframe of the Chart and here is the result :
Try several times this procedure because sometimes the problem doesn't appear...
Any idea ?
Erwann.
Erwann Pannerec:
Any idea ?
I can replicate the problem.
A work-around is to delete the indicator in OnDeinit(), then re-create it by pressing a key again.
ChartIndicatorDelete(0,0,"Custom Moving Average");
Yes, it could be a solution. I hope this bug will be corrected soon...

- 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 everybody,
I found a strange behavior on MT5 with ChartIndicatorAdd function :
- in my EA, a use ChartIndicatorAdd function and the indicator is showed perefctly on the chart (with the good parameters "Apply" at [Median Price])
- I change the Period of the Chart (for exemple from Daily to H4)
- The indicator parameter "Apply" has changed to [Close] !!
Is there something wrong with ChartIndicatorAdd function ?
Thx for your reply,
Erwann.