Some chart my Indicator only Calculation when chart window is visible. So I using the code bellow for determine my indicator Visible or Invisible. I opened more than two Chart Window and on every Chart Window I added my indicator but the result is alway Invisible.
It mean ChartGetInteger(_ChartID, CHART_WINDOW_IS_VISIBLE, 0, result) always returns the result as false. Please help me!
Hello
long _ChartID; void OnInit() { _ChartID = ChartID(); //Create a timer with a 1 second period EventSetTimer(1); } //+----------------------------------------------------------------------------+ //| Timer function | //+----------------------------------------------------------------------------+ void OnTimer() { bool result=false; bool feed=ChartGetInteger(_ChartID, CHART_WINDOW_IS_VISIBLE, 0, result); if (feed&&result==false) Print (_ChartID + ": InVisible!"); else Print ("Visible!"); }
Some chart my Indicator only Calculation when chart window is visible. So I using the code bellow for determine my indicator Visible or Invisible. I opened more than two Chart Window and on every Chart Window I added my indicator but the result is alway Invisible.
It mean ChartGetInteger(_ChartID, CHART_WINDOW_IS_VISIBLE, 0, result) always returns the result as false. Please help me!
Indicator calculation doesn't depend of the visibility of a chart. Please give more details about your real problem.
Hello
Thank you for helping me! If declare bool result=false; then occur error:
'ChartGetInteger' - no one of the overloads can be applied to the function call gOscillator.mq5 400 16
If change bool result=false; by long result; then same the may way.
Example in MQL Reference not work also
//+------------------------------------------------------------------+ //| Checks if the current chart window or subwindow is visible | //+------------------------------------------------------------------+ bool ChartWindowsIsVisible(bool &result,const long chart_ID=0,const int sub_window=0) { //--- prepare the variable to get the property value long value; //--- reset the error value ResetLastError(); //--- receive the property value if(!ChartGetInteger(chart_ID,CHART_WINDOW_IS_VISIBLE,sub_window,value)) { //--- display the error message in Experts journal Print(__FUNCTION__+", Error Code = ",GetLastError()); return(false); } //--- store the value of the chart property in memory result=value; //--- successful execution return(true); }
Indicator calculation doesn't depend of the visibility of a chart. Please give more details about your real problem.
Thank you for helping me! I know Indicator calculation doesn't depend of the visibility of a chart by OnCalculate() functions. But I want to limit some calculations only when Chart Window is visible. But ChartGetInteger(chart_ID,CHART_WINDOW_IS_VISIBLE,sub_window,value) always returns the result as true.
The problem is you have a wrong idea about what is a visible/invisible window. Not your fault as the documentation is unclear about this.
You can only have an invisible window by changing the visualization settings of an indicator.
Your indicator window will be invisible on H1 chart.
The problem is you have a wrong idea about what is a visible/invisible window. Not your fault as the documentation is unclear about this.
You can only have an invisible window by changing the visualization settings of an indicator.
Your indicator window will be invisible on H1 chart.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Some chart my Indicator only Calculation when chart window is visible. So I using the code bellow for determine my indicator Visible or Invisible. I opened more than two Chart Window and on every Chart Window I added my indicator but the result is alway Invisible.
It mean ChartGetInteger(_ChartID, CHART_WINDOW_IS_VISIBLE, 0, result) always returns the result as false. Please help me!