[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 563

 
try performing an invalid operation. e.g. dividing by 0.
 
sergeev:
try performing an invalid operation. e.g. dividing by 0.
nonsense.
 
ditrader:
nonsense.

nonsense.
 
sss2019:

Tell me why there may be an error 130

ticket1 = OrderSend(Symbol(),OP_BUYLIMIT,Lot,Level,Slippage,0,0,0,MagicNumber,0,Green);

Definitely Level. Check for the correctness of the price and its normalization.

For a Buy Limit, the Level should be lower than the Ask price, and at a distance no smaller than the StopLevel of your brokerage company.

I.e. if (Ask - StopLevel*Point < Level) Level = NormalizeDouble(Ask - StopLevel*Point, Digits);

Level must be normalized to Digits before passing it as a parameter to OrderSend();

 
takeda:

How to terminate an Expert Advisor programmatically - something like terminate(0) ?

Does MQL4 have such a possibility, or is it only possible to terminate an Expert Advisor manually?

Thanks in advance.


Close your window, give yourself a command to delete...

PostMessageA(WindowHandle(Symbol(),Period()), WM_COMMAND, 33050, 0);
 
FAQ:


Close your window, give yourself a command to delete it...


This is also crooked.

First, the chart window will close (and there may be useful indicators on it at that time).

Second, what will happen if several windows with the same period are opened for one symbol? Will the window, in which the Expert Advisor has been launched, close?

 
I gave an example of a command to delete myself as an EA. You can close your window, and only the window on which the exp is standing will be closed. But this is another code.
 
takeda:

How to terminate an Expert Advisor programmatically - something like terminate(0) ?

Does MQL4 have such a possibility, or is it only possible to terminate an Expert Advisor manually?

Thank you very much.


Hence, draw your variant: "programmatically":

"Termination of the current session of the special start() function for programs of all kinds may be due to It is possible to terminate the program from a chart, change of a symbol and/or a chart period, change of account, closing of a chart or as a result of terminating the client terminal. If the special function start() was running when the exit command was given, the time allowed by the terminal to terminate the function is 2.5 seconds. If the special function start() continues to run for more than the specified time after receiving the exit command, it will be forced to stop by the client terminal.

Special function deinit().


A special function deinit() has its own property - it is executed when the program is closed (deinitialized). If the special function deinit() is described in a program, it will be called (and executed) when the program is closed. If there is no special deinit() function in the program, no action is performed when the program is closed.

Special function deinit() is called for execution by the client terminal also at closing of the client terminal, at closing of the financial instrument window, right before the change of a financial instrument and/or period of a chart, at successful recompilation of the program in MetaEditor, at changing of input parameters and also at changing of an account.

In Expert Advisors and scripts, program closing with the need to call the special function deinit() also occurs due to joining of a new program of the same type to the financial instrument window, replacing the previous one.

 
Roman.:



The special function deinit().


Calling deinit() does not cause the program to end. The EA/indicator will remain on the chart and continue to process ticks.
 
PapaYozh:

A call of the deinit() function does not cause program termination. The Expert Advisor/indicator will stay on the chart and continue processing ticks.


And if you call a different owl to work programmatically:

"In EAs and scripts, program closing with the need to call the special function deinit() also occurs because a new program of the same type has been attached to the financial tool window, replacing the previous one."

Reason: