Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1461

 
In MT4 in the tester how to trace a stop button press for an indicator. OnDeanit is not called although the test is finished. Or how to close open files when the stop button is pressed in the tester.
 
Valeriy Yastremskiy:
In MT4 in the tester how to trace a stop button press for an indicator. OnDeinit is not called although the test is finished. Or how to close open files when stop button is pressed in tester.

open files should be automatically closed anyway

if not, try to create files with SB, there are CFile, CFileTxt as OOP - objects will be destroyed during deinitialization and destructors will close the files

https://www.mql5.com/ru/docs/standardlibrary/fileoperations


HH: Why do you think OnDeinit() is not called? - try to open and write a file in it

 
Igor Makanu:

open files should be automatically closed anyway

if not, try to create files with SB, there are CFile, CFileTxt as OOP - objects will be destroyed during deinitialization and destructors will close the files

https://www.mql5.com/ru/docs/standardlibrary/fileoperations


HH: Why do you think OnDeinit() is not called? - Try to open and write a file in it.

By experience. I was surprised myself. Although, it is logically correct, it is an indicator and it should not be unloaded like an Expert Advisor. I have to delete the indicator from the tester chart manually or close the window. And only then I see Alerts after closing files)))

The tests are simple, I do not want to use bibbles. Yes and I think there is something other than mouse events on the stop button in the indicator tester. Superficial search cuts did not give unfortunately.

Zy, the files, if not closed, no access to them, and if OnDeinit() suddenly does not work, they will be closed by closing the terminal only.

Experienced way, forgot to record the closure of files)))

 
Valeriy Yastremskiy:

Experienced. I was surprised myself. Although logically everything is correct, it is an indicator, and it should not unload like an Expert Advisor. I have to manually delete the indicator from the tester chart or close the window. And only then I see Alerts after closing files)))

The tests are simple, I do not want to use bibbles. Yes and I think there is something other than mouse events on the stop button in the indicator tester. Superficial search cuts did not give unfortunately.

Zy, the files, if not closed, no access to them, and if OnDeinit() suddenly does not work, they will be closed by closing the terminal only.

Experienced way, forgot to record file closing)))

You haven't described the whole process of testing the indicator before

as far as i understood you run the indicator in the tester of MT4 in visual mode, although you can add the indicator..... in the visualizer of MT4

i have never tested an indicator in MT4, i just check it in EA in the TS code


as an alternative, set the date in the indicator, when you end the test as a variable and after reaching this date, save the file and exit OnCalculate() - the code is a couple of lines, but it will definitely work

 
Igor Makanu:

You haven't described the whole process of testing the indicator before

as far as i understood you run the indicator in MT4 tester in visual mode, but you can also fill it in MT4 in the visualizer with indicator.....

i have never tested an indicator in MT4, i just check it in EA in the TS code


as an alternative, set the date in the indicator, when you end the test as a variable and after reaching this date, save the file and exit OnCalculate() - the code is a couple of lines, but it will definitely work

Yes, the tester window doesn't care if the indicator is being tested or if the indicator is overlaid on the tester window.

Thanks for that not so obvious crutch)

boolIsTesting();

I'll have to try it, I think it's supposed to return by a stop lie)
 
Valeriy Yastremskiy:

Yes, the tester window doesn't care if the indicator is being tested or if the indicator is overlaid on the tester window.

Thanks for that not so obvious crutch)

boolIsTesting();

i should try it, it seems it should return false by stop)

No, it didn't.

I have an open question, how to trace the event 2021.04.29 08:55:41.177 2020.10.01 08:23:13 Tester: stop button pressed

did so)

int OnInit()
{
if(IsTesting()) FlagTest=true;
....
}

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[])
  {

if(!IsTesting() && FlagTest) { Print("Окончание тестирования"); OnDeinit(1);}
....
}

 
Igor Makanu:

search for articles from Metacquot :"Cloud"

read a long time ago, should remote agents download the history from your PC or if connected to the same broker - take real ticks from the broker


but i may be wrong, i have not used it.


one of the articles from Metacquot on this subject, maybe there is information therehttps://www.mql5.com/ru/articles/2612

Igor, thanks. Documentation, forum, articles - haven't found an answer yet.

In the log there is:

"REGRES_EURGBP: ticks synchronized already [57 bytes]".

I hope this is what I need.

 
Valeriy Yastremskiy:

No, it did not.

Anyway, the question is open, how to track in the indicator test the event 2021.04.29 08:55:41.177 2020.10.01 08:23:13 Tester: stop button pressed

did so)


you have to write something like this:

datetime t_stop=D'20.04.2021'; 
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[])
  {
if(time[0]>=t_stop)
{
        if(f_handle<0) return;
        FileClose(f_handle);
        f_handle = -1;
}
can't remember MT4 lets test last day (today) - need to pick up t_stop
 
HimOrik:

Igor, thank you. Documentation, forum, articles - haven't found the answer yet.

In the log there is:

"REGRES_EURGBP: ticks synchronized already [57 bytes]".

I hope this is what I need.

moderators are silent, there are few active users

create a topic with your question in the general discussion, I think you will solve your problem faster

 
Igor Makanu:

you have to write something like this:

I don't remember MT4 lets me test last day (today) - I need to pick t_stop

I understand this idea, it's useful, but it doesn't work for me in this case. I need to time the Tester: stop button pressed in the indicator

Reason: