Ea that imports my indicator with iCustom doesn't show it in a separate window

 

I made my own indicator that has a separate window where it shows buttons. Alone it works like it should.

When i import it with the iCutsom function, the indicator doesn't get shown at all and also the Buffer Values stay empty.

What can i do to make it work?

int Gui;

int OnInit()
  {
   Gui = iCustom(_Symbol,_Period,"gui_test5");
   //Gui = iAMA(_Symbol,_Period,10,10,10,0,PRICE_CLOSE);
   EventSetTimer(1);
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
      double Buffer0[];
      ArraySetAsSeries(Buffer0,true);
      CopyBuffer(Gui,0,0,1,Buffer0);
      double Buffer1[];
      ArraySetAsSeries(Buffer1,true);
      CopyBuffer(Gui,0,0,1,Buffer1);
      double Buffer2[];
      ArraySetAsSeries(Buffer2,true);
      CopyBuffer(Gui,0,0,1,Buffer2);
      double Buffer3[];
      ArraySetAsSeries(Buffer3,true);
      CopyBuffer(Gui,0,0,1,Buffer3);
      double Buffer4[];
      ArraySetAsSeries(Buffer4,true);
      CopyBuffer(Gui,0,0,1,Buffer4);
      
      Comment("Buffer0: ",Buffer0[0],"\nBuffer1: ",Buffer1[0],"\nBuffer2: ",Buffer2[0],"\nBuffer3: ",Buffer3[0],"\nBuffer4: ",Buffer4[0]);
  }
//+------------------------------------------------------------------+

Little addition: It also says the custum indicator has been loaded succesfully

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...
 

Why don't you look at the Terminal Log? There is an entry like this:

CAppDialog: find subwindow error

And also help:  ChartWindowFind

Note

If the second variant of the function (without parameters) is called from a script or Expert Advisor, the function returns -1.


And code:


//+------------------------------------------------------------------+
//| Initialize in Indicator                                          |
//+------------------------------------------------------------------+
bool CAppDialog::CreateIndicator(const int x1,const int y1,const int x2,const int y2)
  {
   int width=m_chart.WidthInPixels();
//--- geometry for the minimized state
   m_min_rect.LeftTop(0,0);
   m_min_rect.Width(width);
   m_min_rect.Height(CONTROLS_DIALOG_MINIMIZE_HEIGHT-2*CONTROLS_BORDER_WIDTH);
//--- determine subwindow
   m_subwin=ChartWindowFind();
   if(m_subwin==-1)
     {
      Print("CAppDialog: find subwindow error");
      m_chart.Detach();
      return(false);
     }
//---

Documentation on MQL5: Chart Operations / ChartWindowFind
Documentation on MQL5: Chart Operations / ChartWindowFind
  • www.mql5.com
1. The function searches in the indicated chart for the subwindow with the specified "short name" of the indicator (the short name is displayed in the left top part of the subwindow), and it returns the subwindow number in case of success. Don't mix up the short name of an indicator and a file name, which is specified when an indicator is...
 
Vladimir Karputov:

Why don't you look at the Terminal Log? There is an entry like this:

And also help:  ChartWindowFind

Note

If the second variant of the function (without parameters) is called from a script or Expert Advisor, the function returns -1.


And code:


Do you mean the Journal? There is no error entry. The only thing there is is:

expert xxxxx (EURUSD,M5) loaded successfully

custum indicator gui_test5 (EURUSD,M5) loaded succesfully

I also attached a file on how the indicator should look like if that matters

Files:
Unbenannt.PNG  31 kb
 
tobqas :

Do you mean the Journal? There is no error entry. The only thing there is is:

expert xxxxx (EURUSD,M5) loaded successfully

custum indicator gui_test5 (EURUSD,M5) loaded succesfully

I also attached a file on how the indicator should look like if that matters

Watch and study TWO tabs - these are the tabs of the log files: 

 
Vladimir Karputov:

Watch and study TWO tabs - these are the tabs of the log files: 

Thanks for replying!

That tab (log files) is always empty.

Also, when i try to Comment ChartWindowFind(0,"TestButtons") it prints -1.

string            subwindow_shortname        ="TestButtons";  
//In OnInit:
IndicatorSetString(INDICATOR_SHORTNAME,subwindow_shortname);

It shoould be the right shortname.

But as i said, no error messages

 

Want to get an answer - ask the right question. I do not know what you have done there in your indicator - how many errors it contains and the like. BUT we always have a STANDARD: *** \ MQL5 \ Indicators \ Examples \ Panels \ SimplePanel \ SimplePanel.mq5

We start it in the EA

//+------------------------------------------------------------------+
//|                                                            1.mq5 |
//|                              Copyright © 2020, Vladimir Karputov |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2020, Vladimir Karputov"
#property version   "1.00"
//--- input parameters
input int      Input1=9;
//---
int      handle_iCustom;            // variable for storing the handle of the iCustom indicator
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
//--- create handle of the indicator iCustom
   handle_iCustom=iCustom(Symbol(),Period(),"Examples\\Panels\\SimplePanel\\SimplePanel");
//--- if the handle is not created
   if(handle_iCustom==INVALID_HANDLE)
     {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iCustom indicator for the symbol %s/%s, error code %d",
                  Symbol(),
                  EnumToString(Period()),
                  GetLastError());
      //--- the indicator is stopped early
      return(INIT_FAILED);
     }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  }
//+------------------------------------------------------------------+

and see the result:

2020.10.08 16:24:04.095 SimplePanel (EURUSD,H1) CAppDialog: find subwindow error



Now read my first post carefully.

 
Vladimir Karputov:

Want to get an answer - ask the right question. I do not know what you have done there in your indicator - how many errors it contains and the like. BUT we always have a STANDARD: *** \ MQL5 \ Indicators \ Examples \ Panels \ SimplePanel \ SimplePanel.mq5

We start it in the EA

and see the result:



Now read my first post carefully.

Thanks, but i don't understand what the problem is.

I read your first post again, and the indicator doesn't need any input parameters, so it shouldn't be -1.

Also i tried the test for the invalid handle, and the handle that is being created is not invalid.

 

@Vladimir Karputov i tried loading another graphic indicator instead of my own (that doesn't have buttons but shows a graph in a separate window), which had the same problem in a normal window.

But when i tried it in the strategy tester, the indicator got loaded like it should and i could use the buffers. So it seems like it gets loaded currectly but there is just the problem opening the separate window.

The same happens when i use the Example-Indicator "Volumes", so it should not be a problem of my indicator itself but of the way i import it. And the handles seem to work, so ONLY the missing indicator window is the problem.

 
tobqas :

@Vladimir Karputov i tried loading another graphic indicator instead of my own (that doesn't have buttons but shows a graph in a separate window), which had the same problem in a normal window.

But when i tried it in the strategy tester, the indicator got loaded like it should and i could use the buffers. So it seems like it gets loaded currectly but there is just the problem opening the separate window.

The same happens when i use the Example-Indicator "Volumes", so it should not be a problem of my indicator itself but of the way i import it. And the handles seem to work, so ONLY the missing indicator window is the problem.

No open MQL5 code - no help. This is a technical forum

 
Vladimir Karputov:

No open MQL5 code - no help. This is a technical forum

I got it now! Had to use ChartIndicatorAdd in the Ea that uses the indicatoor
Reason: