Errors, bugs, questions - page 2107

 
Vladislav Andruschenko:

I agree. we have to change it.

There is a branch on this rule.

Организация цикла перебора ордеров
Организация цикла перебора ордеров
  • 2017.09.16
  • www.mql5.com
MQL4 и MetaTrader 4: Организация цикла перебора ордеров
 
fxsaber:

There is a branch on this rule.


yes i have read snippets about the history access function only when the environment is changed, and i've seen your links in other threads.

just to the point, the error appeared after reading your option.

 
fxsaber:

This is incorrect logic. After OrderSend fails and OrderSend succeeds, the current trading environment must be read completely again. This rule should always be in effect.

About return codes. I do not analyze them in my EAs. I think the trading logic should not depend on them.

Theoretically, a timeout can occur during a loss of connection with the broker's server.

In this case, it is better not to do anything at all until it is restored and the trading environment is fully synchronised with the server.

How can you avoid getting into such a situation without analysing the return code?

 

Compilation error.


Test.mqh file.

int Tmp = 1;


Main code

#include "Test.mqh"

void OnStart()
{
  Print(Tmp);
  Print(Tmp2); // 'Tmp2' - undeclared identifier
}

#define  Tmp Tmp2
#include "Test.mqh"


It turns out that repeated inludes are ignored. But it is wrong in this situation!

We need such a construct for the following purpose. An Expert Advisor is contained in an .mqh file. But I need to be able to run it on a real account (first incloud) and in my tester (second incloud).

 
Andrey Khatimlianskii:

Theoretically, a timeout can happen during a loss of communication with the broker's server.

In this case, it is better not to do anything at all until it is restored and the trading environment is fully synchronised with the server.

How can you avoid getting in such a situation without analysing the return code?

We have sent an OrderSend and have not waited for a reply from the server, getting a timeout in the log and _LastError. We ignore _LastError and receive only false.

After that, if we have a connection, we reassemble the trading environment and make a decision.

Of course, it is always desirable to check the selected environment before collecting the information.

 
fxsaber:

Sent OrderSend and didn't wait for a response from the server, getting a timeout in the log and _LastError. We ignore _LastError and receive only false.

After that, if we have a connection, we reassemble the trading environment and make a decision.

Of course, it is always desirable to check the selected environment before collecting information.

This is possible if we are working with OnTick. And if not?

How to check the connection?

 
Andrey Khatimlianskii:

This will work if you work in OnTick. And if not?

How do you check the connection?

TerminalInfoInteger(TERMINAL_CONNECTED);
 
fxsaber:
TerminalInfoInteger(TERMINAL_CONNECTED);

Historically, I don't trust it. I'll have to test it in 5...

 

The problem with timeouts is not that there is no connection, but that the request has received a timeout.

On the one hand, I see it this way: there is a signal to open a trade, we make a request, we get a timeout - but the trade is opened.

although the Expert Advisor has received an error.

check the trading environment - we see an open deal.

but how to understand that the deal was opened by this signal? if there were e.g. 10 signals?

i.e. check if a new deal appeared in the history (in the terminal).


i have not yet understood the idea

@A100

what solution do you see?

 
fxsaber:

It turns out that the re-incode is ignored. But this is wrong in this situation!

I need such a construct for the following one. An Expert Advisor is contained in an mqh-file. But I need to be able to run it on a real account (first incloud) and in my tester (second incloud).

Everything is correct and it is properly ignored.

Cish hacks don't go through.