...
No you can't. Why do you need that, maybe there is a workaround.
Maybe I should work around to make arrays with like CopyTime function et cetera?
Maybe I should work around to make arrays with like CopyTime function et cetera?
Yes you are right, the best way is to use CopyXXXX functions in the OnChartEvent().
Another solution would be to set a flag when OnChartEvent() is raised and to process your objects in OnCalculate() but that would be on the next tick.
Yes you are right, the best way is to use CopyXXXX functions in the OnChartEvent().
Another solution would be to set a flag when OnChartEvent() is raised and to process your objects in OnCalculate() but that would be on the next tick.
Thank you Alain! I'll try that.
Have a nice day ♫
Yes you are right, the best way is to use CopyXXXX functions in the OnChartEvent().
Another solution would be to set a flag when OnChartEvent() is raised and to process your objects in OnCalculate() but that would be on the next tick.
Hi Alain
How can I set a flag of "OnCalculate" On so that I could call it again?
in MQL4, the "Start" can be called in functions like this :
void handleButtonClicks() { if(ObjectGetInteger(ChartID(), buttonId, OBJPROP_STATE)) { ObjectSetInteger(ChartID(), buttonId, OBJPROP_STATE, false); show_data = !show_data; start(); } }
but in MQL5, since it's "OnCalculate" function, we won't able to do like :
void handleButtonClicks() { if(ObjectGetInteger(ChartID(), buttonId, OBJPROP_STATE)) { ObjectSetInteger(ChartID(), buttonId, OBJPROP_STATE, false); show_data = !show_data; OnCalculate(); } }
my main objective is to "hide/show" lines of zigzag indicator by clicking on a button,
You don't need to call OnCalculate() at all to hide/show a line.
You can just play with DRAW_TYPE :
PlotIndexSetInteger(plotIndex,PLOT_DRAW_TYPE,DRAW_NONE);
I also tried below code, it hiding the line correctly, but it won't replace (show) the line afterwards :
void handleButtonClicks() { if(ObjectGetInteger(ChartID(), buttonId, OBJPROP_STATE)) { ObjectSetInteger(ChartID(), buttonId, OBJPROP_STATE, false); show_data = !show_data; if(show_data) { ObjectSetInteger(ChartID(),buttonId,OBJPROP_COLOR,btn_text_ON_color); ObjectSetString(ChartID(),buttonId,OBJPROP_TEXT,btn_unpressed); PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_SECTION); // PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_LINE); ChartRedraw(0); } else { ObjectSetInteger(ChartID(),buttonId,OBJPROP_COLOR,btn_text_OFF_color); ObjectSetString(ChartID(),buttonId,OBJPROP_TEXT,btn_pressed); PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_NONE); } } }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Example: