Questions from a "dummy" - page 197

 
FiftyStars:

How do I determine when the next bar will open, i.e. the one that hasn't yet formed?

In general, you can't; although in the case of timeframes of half an hour or more, the probability of a correct prediction exceeds 99.9%
 

Is it possible to loop a request like this to open an order? )

      while(result.retcode!=TRADE_RETCODE_DONE)
      {
        if(OrderCheck(request,check))
        {
          OrderSend(request,result);
        }
        if((MQL5InfoInteger(MQL5_TESTING)||MQL5InfoInteger(MQL5_OPTIMIZATION)))break;
      }
 
G001: Is it possible to loop a request like this to open an order? )
Not desirable. Imagine, for example, that instead of TRADE_RETCODE_DONE the server returns the answer that the order has been placed. Then your code would overload the server with the same kind of requests.
 
Yedelkin:
Not desirable. Imagine, for example, that instead of TRADE_RETCODE_DONE the server returns a response that an order has been placed. Then your code would overload the server with the same kind of requests.

Would that be better?

      int ResBear = -1;
      while(ResBear == -1)
      {
        if(OrderCheck(request,check))
        {
          ResBear = OrderSend(request,result);
        }
        if((MQL5InfoInteger(MQL5_TESTING)||MQL5InfoInteger(MQL5_OPTIMIZATION)))break;
      }
 
G001: Will it be better this way?

Unlikely. Look at the description of the OrderSend() function. It should tell you that if it is executed successfully, you still need to check the return code. So we will have to go the most tedious way: take a list of return codes and think out the program behavior for each of these codes. I.e. "we send OrderSend(), get the return code, react to the retcode we get".

The second point. It's better to use the event model. I.e. don't loop the function's execution after one tick arrives, and after several unsuccessful attempts, exit the function and wait for a new tick.

 
Thanks, really tedious, I'll put a better limit on attempts.
 
G001: Thanks, really tedious, I'll put a better limit on attempts.

You'll have to do it one day anyway :) Speaking from my own experience.

 
I'm sure, but so far the knowledge is lacking.
 

Sorry, how do I make a condition so that in the tester there is no condition, but in the tester in visual mode there is a condition?

The property list doesn't allow this, and for some reason this condition doesn't work for me:

if(MQL5InfoInteger(MQL5_TESTER)!=1 || MQL5InfoInteger(MQL5_TESTER)==1 && MQL5InfoInteger(MQL5_VISUAL_MODE)==1)

 
if(MQL5InfoInteger(MQL5_TESTER)!=1 || MQL5InfoInteger(MQL5_TESTER)==1 && MQL5InfoInteger(MQL5_VISUAL_MODE)==1)

from this condition comes out that it will perform in three situations:

1)When the tester is working

2)When the tester is NOT working

3)When visual tester works

so the function will always work, most likely you should remove the second condition and connect the first and third with &&

Reason: