Errors, bugs, questions - page 541

 
220Volt:

So as not to be unfounded, I simulated the situation I mentioned above (I can't quote it as I can't get out of quote :) ).

I ran the following code on M15:

While the script was running I connected and disconnected from the Internet. The pictures show the result.

I see. We will correct it.
 

Is it in servicedesk or a bug in the code?

The indicator should build 5 point levels from the closing price downwards in red.

But only two buffers are displayed (although it counts all of them) and not red, but green (after compilation black).

Please check if it's just me or if it's just me in general...?


#define  N      5
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_plots   5
#property indicator_color1 clrRed
#property indicator_color2 clrRed
#property indicator_color3 clrRed
#property indicator_color4 clrRed
#property indicator_color5 clrRed

#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 3
#property indicator_width4 3
#property indicator_width5 3

#property indicator_type1 DRAW_COLOR_ARROW
#property indicator_type2 DRAW_COLOR_ARROW
#property indicator_type3 DRAW_COLOR_ARROW
#property indicator_type4 DRAW_COLOR_ARROW
#property indicator_type5 DRAW_COLOR_ARROW

//------------------------------------------------------------------    class CClrHist
class CClrHist
{
public:
        double buf[];
        CClrHist() { };
};

CClrHist bufs[N]; // массив буферов

//------------------------------------------------------------------    OnInit
int OnInit()
{
        for (int i=0; i<N; i++) SetIndexBuffer(i, bufs[i].buf, INDICATOR_DATA);
        return(0);
}
//------------------------------------------------------------------    OnCalculate
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[])
{
        for (int i=0; i<N; i++) for (int j=rates_total-1; j>=0; j--)
        {
                bufs[i].buf[j]=close[j];
                bufs[i].buf[j]-=i*100*Point();
        }
        return(rates_total);
}
 
sergeev:

Is it in servicedesk or a bug in the code?

The indicator should build 5 point levels from the closing price downwards in red.

But only two buffers are displayed (although it counts all of them) and not red, but green (after compilation black).

Please check if it's just me or if it's just me in general...?

#property indicator_type1 DRAW_ARROW
#property indicator_type2 DRAW_ARROW
#property indicator_type3 DRAW_ARROW
#property indicator_type4 DRAW_ARROW
#property indicator_type5 DRAW_ARROW
 
masharov:

...I believe that standard libraries are ideal code that should serve as a model for others.

I can only say that it would be desirable to get rid of such notions as soon as possible.

I have nothing against standard libraries but trusting somebody else's code "to make writing programs easier" without verifying it? - Except at the stage of initial drafting of an Expert Advisor. To speed up routine processes, so to speak.

 

I get the message: Abnormal termination quite often in my logbook. Has anyone noticed when there might be such a conflict?

I can't find the cause yet. The only thing I can say is that if I leave the terminal idle for a while or just use another program at that moment (e.g., Excel), the Expert Advisor I am testing starts working incorrectly after I get back to the terminal. That is, trading operations are performed without any problems. The only problem is in interacting with the trading and information panels. It seems that OnChartEvent() is glitchy. Switching between the panels starts to slow down a lot, as if the process is very busy with something else. I don't use eternal loops. Also CPU load at this moment doesn't indicate that something is actively used. Recompilation of the Expert Advisor helps. At the moment of recompilation, before the EA is deinitialized theAbnormal termination message appears in the journal. Then the program is successfully initialized and everything starts working like clockwork.

Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Типы торговых операций
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Типы торговых операций
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Типы торговых операций - Документация по MQL5
 
tol64:

I get the message: Abnormal termination quite often in my logbook. Has anyone noticed when there might be such a conflict?

I can't find the cause yet. The only thing I can say is that if I leave the terminal idle for a while or just use another program at that moment (e.g., Excel), the Expert Advisor I am testing starts working incorrectly after I get back to the terminal. That is, trading operations are performed without any problems. The only problem is in interacting with the trading and information panels. It seems that OnChartEvent() is glitchy. Switching between the panels starts to slow down a lot, as if the process is very busy with something else. I don't use eternal loops. Also CPU load at this moment doesn't indicate that something is actively used. Recompilation of the Expert Advisor helps. At the moment of recompilation, before the EA is deinitialized theAbnormal termination message appears in the journal. Then the program is successfully initialized and everything starts working like clockwork.

Do we use IsStopped() in loops?

You may read about such problems here, here and here. You should also think about where in the code there are "bottlenecks"...

As far as I understand, this error occurs in case of "early" program termination (when the chart/terminal is closed or the Expert Advisor is recompiled), and during this operation the Expert Advisor performs some work.

 
Interesting:

Do we use IsStopped() in loops?

Read about similar problems here, here and here. Also think about bottlenecks in the code...

As far as I understand, this error occurs in the case of "early" termination of a program (when the chart/terminal is closed or the Expert Advisor is recompiled), while the Expert Advisor performs some work.

Thank you. The links show the same situation. I never use IsStopped() in loops, only break, continue and return.

So far, I have not seen any connection betweenIsStopped() and the program slowing down. After all, if the program would freeze, no other operations would be performed. Or am I mistaken?

One more thing.IsStopped() is useful when you need to stop execution of a program forcibly, for example, to close the terminal or delete Expert Advisor from chart. And I need to continue using the Expert Advisor.

 
tol64:

Thank you. The links show the same situation. I don't use IsStopped() in loops anywhere, only break, continue and return.

So far, I have not seen a connection betweenIsStopped() and the slowing down of the program. If the program would freeze, no other operations would be performed. Or am I mistaken?

One more thing.IsStopped() is useful when you need to stop execution of a program forcibly, for example, to close the terminal or delete the Expert Advisor from the chart. And I need to continue to use the Expert Advisor.

IsStopped(), it's about the error. Why the terminal/expert is slowing down is not even guessed (no runtime conditions are known, nothing about the Expert Advisor either).
 
tol64:

I get the message: Abnormal termination quite often in my logbook. Has anyone noticed when there might be such a conflict?

I can't find the cause yet. The only thing I can say is that if I leave the terminal idle for a while or just use another program at that moment (e.g., Excel), the Expert Advisor I am testing starts working incorrectly after I get back to the terminal. That is, trading operations are performed without any problems. The only problem is in interacting with the trading and information panels. It seems that OnChartEvent() is glitchy. Switching between the panels starts to slow down a lot, as if the process is very busy with something else. I don't use eternal loops. Also CPU load at this moment doesn't indicate that something is actively used. Recompilation of the Expert Advisor helps. At the moment of recompilation, before the EA is deinitialized theAbnormal termination message appears in the journal. Then the program is successfully initialized and everything starts working like clockwork.

Abnormal termination means that you have interfered with the program unnaturally, namely, recompiling it at runtime, which leads to program interruption and reinitialization.

The same happens if you hit a division by zero or interrupt the program at runtime, but if the program is retuned, you won't get such an entry. This is why you are advised to check for IsStopped so that the program can exit on its own return instead of being forced to do so.

 

Are there any plans to add the following items:

Double click on a position on the chart to bring up the position management menu.

Highlighting multiple positions to close at once

????

Thank you.