Errors, bugs, questions - page 2968

 
Mihail Matkovskij:

You have an invalid deletion! Your code:

As you delete each item, the list gets smaller! That's why you should do it like this:

Or even simpler:

Thank you for your answer. The problem is still adding items

 
Mihail Matkovskij:

Decided to find out how much 2 agents in MQL5 Cloud Network service will earn in order to build an iron with a multi-core processor in the future. I added the agents using Agent Manager. Seems to have added them fine.

Nothing seems to besuspicious... I logged into my MQL5.COM account. I have seen the agents created in my account under "Agents". I also found two services, MetaTester-1 and MetaTester-2 in the task manager. But for half a day there is no tasks for agents. Everything is null. Why don't agents work?

And now I see that all agents were deleted from my office.


Services MetaTester-1 andMetaTester-2 in Task Managershows and in Agent Manager. However, Agent Manager shows that the services are disabled. And they are not in the cabinet, even though they were there yesterday... What is the reason for such behavior of MQL5 Cloud Network?

Распределенные вычисления в сети MQL5 Cloud Network
Распределенные вычисления в сети MQL5 Cloud Network
  • cloud.mql5.com
Заработать деньги, продавая мощности своего компьютера для сети распределенных вычислений MQL5 Cloud Network
 
Mihail Matkovskij:

And now I see that the agents have been deleted in my cabinet.


The services MetaTester-1 andMetaTester-2 in the Task Managershows and in the Agent Manager. However, the Agent Manager shows that the services are disabled. And they are not in the Cabinet, even though they were there yesterday... What is the reason for MQL5 Cloud Network to behave this way?

No one is deleted - uncheck this box...

 
Vladimir Karputov:

No one has gone anywhere - uncheck the box ...

А... Right! My agents have zero activity...

 

Help me solve the problem with the size of the content, I can't get it to change. When the chart window is resized, it has to be resized in height.

And scrolling is lost whenOnCalculate() is triggered again


//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#include <Controls\Dialog.mqh>
#include <Controls\ListView.mqh>

//+------------------------------------------------------------------+
//| Class CPanelDialog                                               |
//| Usage: main dialog of the SimplePanel application                |
//+------------------------------------------------------------------+
class CPanelDialog : public CAppDialog
  {
public:
   CListView         m_list_view1; // the list object
   CListView         m_list_view2; // the list object

public:
                     CPanelDialog(void);
                    ~CPanelDialog(void);

   virtual bool      Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2);
   virtual bool      OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam);
   virtual void      OnChangeListView(void);
protected:
   bool              CreateListView(void);
   virtual bool      OnResize(void);
   bool              OnDefault(const int id,const long &lparam,const double &dparam,const string &sparam);
  };

//+------------------------------------------------------------------+
//| Event Handling                                                   |
//+------------------------------------------------------------------+
EVENT_MAP_BEGIN(CPanelDialog)
ON_EVENT(ON_CHANGE,m_list_view1,OnChangeListView)
ON_OTHER_EVENTS(OnDefault)
EVENT_MAP_END(CAppDialog)
//+------------------------------------------------------------------+
//| Constructor                                                      |
//+------------------------------------------------------------------+
CPanelDialog::CPanelDialog(void)
  {
  }
//+------------------------------------------------------------------+
//| Destructor                                                       |
//+------------------------------------------------------------------+
CPanelDialog::~CPanelDialog(void)
  {
  }
//+------------------------------------------------------------------+
//| Create                                                           |
//+------------------------------------------------------------------+
bool CPanelDialog::Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2)
  {
   if(!CAppDialog::Create(chart,name,subwin,x1,y1,x2,y2))
      return(false);
//--- create dependent controls
   if(!CreateListView())
      return(false);
//--- succeed
   return(true);
  }
//+------------------------------------------------------------------+
//| Create the "ListView" element                                    |
//+------------------------------------------------------------------+
bool CPanelDialog::CreateListView(void)
  {
//--- coordinates
   int x1=0;
   int y1=0;
   int x2=ClientAreaWidth();
   int y2=ClientAreaHeight();
//--- create
   m_list_view1.Create(0,m_name+"ListView",0,x1,y1,x2,y2);
   m_list_view1.ColorBackground(clrMistyRose);
   Add(m_list_view1);
   m_list_view1.Alignment(WND_ALIGN_HEIGHT,0,0,0,0);
//--- succeed
   return(true);
  }
//+------------------------------------------------------------------+
//| Handler of resizing                                              |
//+------------------------------------------------------------------+
bool CPanelDialog::OnResize(void)
  {
//--- call method of parent class
   if(!CAppDialog::OnResize())
      return(false);

//--- succeed
   return(true);
  }
//+------------------------------------------------------------------+
//| Event handler                                                    |
//+------------------------------------------------------------------+
void CPanelDialog::OnChangeListView(void)
  {

//+------------------------------------------------------------------+
  }
//+------------------------------------------------------------------+
//| Rest events handler                                                    |
//+------------------------------------------------------------------+
bool CPanelDialog::OnDefault(const int id,const long &lparam,const double &dparam,const string &sparam)
  {

//--- let's handle event by parent
   return(false);
  }

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#property version "1.00"
#property strict

#property indicator_chart_window

string symbols[];
//+------------------------------------------------------------------+
//| Global Variables                                                 |
//+------------------------------------------------------------------+
CPanelDialog ExtDialog;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create application dialog
   if(!ExtDialog.Create(0,"Spread",0,12,12,250,300))
      return(INIT_FAILED);
//--- run application
   if(!ExtDialog.Run())
      return(INIT_FAILED);
//--- ok
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy application dialog
   ExtDialog.Destroy(reason);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
//---
   ExtDialog.m_list_view1.ItemsClear(); // Очистим список

   int k=MarketWatch();
   for(int i=0; i<k; i++)
     {
      string str = (string)(i+1)+" из "+(string)k+": "+symbols[i]+" = "+(string)SymbolInfoInteger(symbols[i],SYMBOL_SPREAD);
      ExtDialog.m_list_view1.ItemAdd(str); // Заполним строками
     }

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
   ExtDialog.OnEvent(id,lparam,dparam,sparam);

   if(id==CHARTEVENT_CHART_CHANGE || (id==CHARTEVENT_OBJECT_CLICK && StringFind(sparam,"MinMax")>0))
     {
      if(ExtDialog.Height()>40) // Если окно не свёрнуто
        {
         ExtDialog.Height((int)ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS)-50); // Изменим высоту диалог-окна
         ExtDialog.m_list_view1.Height(ExtDialog.Height()-40); // Изменим высоту содержимого в диалог-окне
        }
     }
//---
  }
  
//+--- Список символов с MarketWatch --------------------------------+
int MarketWatch()
  {
   int s=SymbolsTotal(true);
   ArrayResize(symbols,s);
   for(int i = 0; i < s; i++)
      symbols[i] = SymbolName(i,true);
   return(s);
  }
//+------------------------------------------------------------------+
 
Vitaly Muzichenko:

Help me solve the problem with the size of the content, I can't get it to change. When the chart window is resized, it has to be resized in height.

And scroll is lost whenOnCalculate() is triggered again.


Try the patched version of the ControlsPlus windows and controls library described in this article. The rubber properties are automatically supported there.

Язык MQL как средство разметки графического интерфейса MQL-программ (Часть 3). Дизайнер форм
Язык MQL как средство разметки графического интерфейса MQL-программ (Часть 3). Дизайнер форм
  • www.mql5.com
В этой статье мы завершаем описание концепции построения оконного интерфейса MQL-программ с помощью конструкций языка MQL. Специальный графический редактор позволит интерактивно настраивать раскладку, состоящую из основных классов элементов GUI, и затем экспортировать её в MQL-описание для использования в вашем MQL-проекте. Представлено внутреннее устройство редактора и руководство пользователя. Исходные коды прилагаются.
 
Is there any way to know that an MQL program is started as a result of the terminal start itself (i.e. automatically at the start of the session), rather than interactively by the user?
 
Stanislav Korotky:
Is there a way to find out that the MQL program is started as a result of terminal start (i.e. automatically at the beginning of the session) and not interactively by the user?

Services, without a loop.
When the terminal starts, the service will be executed once, if it is not looped.
What kind of logic is put into the service is a specific task for the required requirements.

 
Stanislav Korotky:
Is there a way to detect that an MQL program is started as a result of terminal start (i.e. automatically at the beginning of a session) and not interactively by a user?

Searching, not found.

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

fxsaber, 2021.02.02 19:34

I have to determine whether the EA is run in the standard way or via template at the stage of startup.

Any thoughts on how to solve this problem? By the way, there is a subtask of determining the lifetime of the chart - when it was created.

 
fxsaber:

Searched, couldn't find it.

I found this solution for my purposes:

ChartPriceOnDropped()=0.0
ChartTimeOnDropped()=1970.01.01 00:00:00
ChartXOnDropped()=0
ChartYOnDropped()=0

These functions give zeros when the terminal starts.

PS. Unfortunately, this method only works with a mouse. If the user runs the "Attach to chart" command, the problem remains.

Reason: