Getting into the body of the Destroy() procedure does not at all mean that it (the procedure) is working correctly.
After the actual destruction of an object, we couldn't add new graphs to it, and they do!
About the hitting, I agree. But nevertheless... Well, firstly,voidCGrafic::Destroy(). That is, the method does not owe us anything. And secondly, maybe it's up to the programmer to add checks? You can't configure SB for all tasks...
About the hitting, I agree. But nevertheless... Well, first of all,voidCGrafic::Destroy(). That is, the method doesn't owe us anything. And secondly, maybe it's up to the programmer to add checks? You can't configure SB for all tasks.
I plot the graphs and output the text using CGraphic. If one instance of the EA is running, everything is fine. If I run the same EA on different charts, I get the impression that the output is always on the chart which is currently on the screen. And not on the chart that is specified in the Create method. Here is the code of the EA to demonstrate the problem:
#include <Graphics\Graphic.mqh>
CGraphic Graphic; // Для вывода графика.long ChartId;
intOnInit()
{
ChartId= ID_Grafika_S_Expertom(); // Узнаем Id графика на котором запущен советник.
Graphic.Create(ChartId,"CPrecieIdealnayFast ", 0, 10, 30, 500, 500);
Print("OnInit ",Symbol()," ChartId=",ChartId);
EventSetMillisecondTimer(1000);
return(INIT_SUCCEEDED);
}
voidOnTimer()
{
string Str;
StringConcatenate(Str,ChartId," ",Symbol()," ",TimeLocal());
Graphic.FontSet("Arial",20);
Graphic.TextAdd(20,30, Str, ColorToARGB(clrRed), TA_LEFT|TA_TOP);
Graphic.Update();
Graphic.Redraw(true);
}
voidOnDeinit( constint Reanson )
{
Graphic.Destroy();
}
long ID_Grafika_S_Expertom()
{
string MaskaNameExpert= MQLInfoString(MQL_PROGRAM_NAME);
int SekyndNaGrafikeSTekygemExpertom= PeriodSeconds();
string SimvolExpert= Symbol();
//--- 1. Настраиваемся на первый график. Если не получилось возращаем советник не найден. //--- В цикле.//--- 2. Получаем Имя эксперта.//--- --- 2.1 Если не удалось получить имя эксперта смотрим следующий график.//--- --- --- 2.2 Если не удалось получить слеюущий график выходим из цикла.//--- 3.A Если на графике есть эксперт И в его названии есть маска: Запоминаем Id и выходим из цикла.//--- 3.B Если Нет эксперта или НЕ нашли смотрим следующий график. //--- --- 3.B.A Если не удалось получить слеюущий график выходим из цикла. //--- --- 3.B.B Если Удалось получить слеюущий график ищем в начало цикла. long ID_Chart= -1;
string NameExpert="";
long IskomoeIdChart= -1;
int LimitChatr= 1000; // Наверняка ведь не 1000 графиков.int i=0; // Cчетчик графиков//--- 1. Настраиваемся на первый график. Если не получилось возращаем советник не найден.
ID_Chart= ChartFirst();
if( ID_Chart < 0 ) return -1;
string Simvol;
int KolichestvoSekynd;
while( i < LimitChatr )
{
//--- 2. Получаем Имя эксперта.
NameExpert= ChartGetString( ID_Chart, CHART_EXPERT_NAME );
Simvol= ChartSymbol(ID_Chart);
KolichestvoSekynd= PeriodSeconds( ChartPeriod(ID_Chart) );
// Print("На графике ",ChartSymbol(ID_Chart)," Period=",ChartPeriod(ID_Chart)," Расположен советник (",NameExpert,")");//--- 3.A Если на графике есть эксперт И в его названии есть маска: Запоминаем Id и выходим из цикла. if( NameExpert != "" &&
StringFind(NameExpert,MaskaNameExpert) > -1 &&
Simvol == SimvolExpert &&
KolichestvoSekynd == SekyndNaGrafikeSTekygemExpertom )
{
// Print("НАШЛИ На графике ",ChartSymbol(ID_Chart)," Period=",ChartPeriod(ID_Chart)," Расположен советник (",NameExpert,")");
IskomoeIdChart= ID_Chart; break;
}
//--- 3.B Если Нет эксперта или НЕ нашли смотрим следующий график. else
{
// Print("Не удалось найти маску (",MaskaNameExpert," в названии эксперта (",NameExpert,") ",ChartSymbol(ID_Chart)," Period=",ChartPeriod(ID_Chart)," ID=",ID_Chart);
ID_Chart= ChartNext(ID_Chart);
i++;
//--- --- 3.B.A Если не удалось получить слеюущий график выходим из цикла. if( ID_Chart < 0 ) {/*Print("Закончились графики.");*/break;}
//--- --- 3.B.B Если Удалось получить слеюущий график ищем в начало цикла. else {/* Print("Получили новое Id графика ",ChartSymbol(ID_Chart)," Period=",ChartPeriod(ID_Chart)," ID=",ID_Chart);*/continue;}
}
}
return IskomoeIdChart;
}
If Expert Advisor 1 works, everything is fine
But if you open the second EA in another chart, the first chart starts receiving information from the first EA and the second one at the same time.
It means that it starts flickering, because several Expert Advisors work on one and the same chart. However, in the Init function, each Expert Advisor receives the Id of the chart it has been launched in. Then I get a call to Create.
intOnInit()
{
ChartId= ID_Grafika_S_Expertom(); // Узнаем Id графика на котором запущен советник.
Graphic.Create(ChartId,"CPrecieIdealnayFast ", 0, 10, 30, 500, 500);
Print("OnInit ",Symbol()," ChartId=",ChartId);
EventSetMillisecondTimer(1000);
return(INIT_SUCCEEDED);
}
Please help me to understand what is the problem ?
При исследовании и изучении закономерностей важную роль играет визуальное отображение с помощью графиков. В популярных среди научного сообщества языках программирования, таких как R и Python, для визуализации предназначена специальная функция plot. С её помощью можно рисовать линии, точечные распределения и гистограммы для наглядного представления закономерностей. В MQL5 вы можете делать всё то же самое с помощью класса CGraphics.
I plot the graphs and output the text using CGraphic. If one instance of the EA is running, everything is fine. If I run the same EA on different charts, I get the impression that the output is always on the chart which is currently on the screen. And not on the chart that is specified in the Create method. Here is the code of the EA to demonstrate the problem:
If Expert Advisor 1 works, everything is fine
But if you open the second EA in another chart, the first chart starts receiving information from the first EA and the second one at the same time.
It means that it starts flickering, because several Expert Advisors work on one and the same chart. However, in the Init function, each Expert Advisor receives the Id of the chart it has been launched in. Then I get a call to Create.
Please help me to understand what the problem is?
In the name of the object, do not need to add ChartId? I don't remember if it is added inside the function.
CGrafic::Destroy() - Doesn't work!
CGrafic::Destroy() - Doesn't work!
How did you detect it? What are the symptoms?
How have you identified it? What are the symptoms?
Well, the code is attached for playback :)
And on the picture you can see that after Destroy() graphs are added
with prefix
_existsBut the code for playback is attached :)
And on the picture you can see that after Destroy() graphs are added
with prefix
Well my question was aboutCGrafic::Destroy(). It works - I checked it with the debugger... Maybe something is wrong in your code?
Well, the question was specifically aboutCGrafic::Destroy(). It works - I checked it in the debugger... Maybe something is wrong in your code?
Getting into the body of Destroy() procedure does not mean that it (the procedure) works correctly.
Afteractual destroying of an object we couldn't add new graphs to it, and they are added!
Getting into the body of the Destroy() procedure does not at all mean that it (the procedure) is working correctly.
After the actual destruction of an object, we couldn't add new graphs to it, and they do!
About the hitting, I agree. But nevertheless... Well, firstly,voidCGrafic::Destroy(). That is, the method does not owe us anything. And secondly, maybe it's up to the programmer to add checks? You can't configure SB for all tasks...
About the hitting, I agree. But nevertheless... Well, first of all,voidCGrafic::Destroy(). That is, the method doesn't owe us anything. And secondly, maybe it's up to the programmer to add checks? You can't configure SB for all tasks.
Moreover, I altered the Destroy method.
And it still adds charts!
I plot the graphs and output the text using CGraphic. If one instance of the EA is running, everything is fine. If I run the same EA on different charts, I get the impression that the output is always on the chart which is currently on the screen. And not on the chart that is specified in the Create method. Here is the code of the EA to demonstrate the problem:
If Expert Advisor 1 works, everything is fine
But if you open the second EA in another chart, the first chart starts receiving information from the first EA and the second one at the same time.
It means that it starts flickering, because several Expert Advisors work on one and the same chart. However, in the Init function, each Expert Advisor receives the Id of the chart it has been launched in. Then I get a call to Create.
Please help me to understand what is the problem ?
I plot the graphs and output the text using CGraphic. If one instance of the EA is running, everything is fine. If I run the same EA on different charts, I get the impression that the output is always on the chart which is currently on the screen. And not on the chart that is specified in the Create method. Here is the code of the EA to demonstrate the problem:
If Expert Advisor 1 works, everything is fine
But if you open the second EA in another chart, the first chart starts receiving information from the first EA and the second one at the same time.
It means that it starts flickering, because several Expert Advisors work on one and the same chart. However, in the Init function, each Expert Advisor receives the Id of the chart it has been launched in. Then I get a call to Create.
Please help me to understand what the problem is?
In the name of the object, do not need to add ChartId? I don't remember if it is added inside the function.