Troubled by the error there are no trading operations - page 6

 

This problem is even more interesting. I built a simple EA based on the code from the post above. It also opens 5 trades, each in the market for 5 minutes, and then closes. Here is the code:

#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   static int test_ticket[2]={0,0};
   if(test_ticket[1]<5 && test_ticket[0]==0) {
      test_ticket[0]=OrderSend(_Symbol,OP_BUY,SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN),NormalizeDouble(Ask,_Digits),30,0.0,0.0,"test",33333,0,clrNONE);
      if(test_ticket[0]>0) test_ticket[1]++;
   }   
   if(OrderSelect(test_ticket[0],SELECT_BY_TICKET))
      if(OrderCloseTime()==0 && OrderOpenTime()+300<TimeCurrent())
         if(OrderClose(test_ticket[0],OrderLots(),NormalizeDouble(Bid,_Digits),30,clrNONE)) {
            printf("Test order closed, ticket #%d",test_ticket[0]);
            test_ticket[0]=0;
         }   
   
  }
//+------------------------------------------------------------------+

It passed validation on the first try, but there are no trades on NZDUSD. Why?


Even if validator sets deposit insufficient for opening with minimal lot, error 134 will appear like in above message. But there are just no trades! Why?

Maybe the validator is malfunctioning or there is a reasonable explanation?

 
Renat Akhtyamov:

and you put the validator's full response here first

And what makes you think that the validator assigns tickets according to the principle you came up with?

to open 5 trades, you need to count the number of open trades, not bother with tickets

Renat, that's what I think the transactions are, take a closer look. You can even run my code in the tester. There is an array of two values: test_ticket[0] - stores the ticket order, test_ticket[1] - number of attempts.

By changing number of attempts in the first condition you can open different number of deals

if(test_ticket[1]<5 && test_ticket[0]==0) {
 

This is the story on the following attempts with different numbers of orders


And here, on one of the following attempts, the validator actually uses the minimum lot, which knowingly cannot open with a $1 deposit. The question is, why were there no trades on the attempts earlier? And why does this run use a knowingly wrong minimum lot and deposit that initiates a validation error?

Vladimir Karputov:

...

All in all, the validator has so far coped with its main task: sifting out incomplete code from Market.

Mmm...

And it's not a random shot. Here are the next three attempts.


 

The error in the log "No money to open such-and-such transaction..." indicates that you did send a trade order, but did not check anything (or not everything) completely beforehand. The article provides a clear algorithm for checking.


Remember - the error "there is no money to open such and such a deal ...". - is 99% of the error in the logic of the Expert Advisor. It's missing checks (or complete lack of them). This is a sign of insufficient understanding of the coding principles.


Remember: in the real world, the deposit may be $1, and the leverage is not always 1:100, and the minimum lot can be 0.01 and 0.02 and 0.30 and 1.0, and a lot of other stuff...

 
Vladimir Karputov:

The error in the log "No money to open such-and-such transaction..." indicates that you did send a trade order, but did not check anything (or not everything) completely beforehand. The article provides a clear algorithm for checking.


Remember - the error "there is no money to open so-and-so trade..." - is 99% of the error in the logic of the Expert Advisor. It's missing checks (or complete lack of them). This is a sign of insufficient understanding of the coding principles.


Remember: in the real world, the deposit may be $1, and the leverage is not always 1:100, and the minimum lot can be 0.01 and 0.02 and 0.30 and 1.0, and a lot of other stuff...

Vladimir, you missed the elephant. The main mistake was.

I can answer in your language and give you a lecture.

 
Vladimir Karputov:

The error in the log "No money to open such-and-such transaction..." indicates that you did send a trade order, but did not check anything (or not everything) completely beforehand. The article provides a clear algorithm for checking.


Remember - the error "there is no money to open such and such a deal ...". - is 99% of the error in the logic of the Expert Advisor. It's missing checks (or complete lack of them). This is a sign of insufficient understanding of the coding principles.


Remember: in the real world, the deposit may be $1, and the leverage is not always 1:100, and the minimum lot can be 0.01 and 0.02 and 0.30 and 1.0, and a lot of other stuff...

Vladimir, I don't understand if you read posts in general or just pick out interesting pictures. Read everything carefully again or a couple of times from the beginning of the page at least. And read the code! I don't even want to bother explaining it all to you!

 
Andrey Kaunov:

I don't even want to bother explaining everything to you!

Andrew, no one wants to repeat what has already been written and chewed up.

 
Yes, but the problem is obvious. Maybe someone from this strong website will try to analyze it and check the validator. The simple transparent code without parameters does not perform deal on NZDUSD and GBPUSD check sometimes. And if we add some conditions and there will be no trades on gold as well, then again we will receive error ofno trading operations and missed check.
 
Andrey Kaunov:
Yes, but the problem is there. Maybe someone from this strong site will try to understand it all the same and check the validator. The simple transparent code without parameters does not work at all for NZDUSD and GBPUSD Check sometimes. And if we add some conditions and there will be no trades on gold as well, then again we will receive error ofno trading operations and missed check.

Do not rely on the validator returning an error code from the trade server error list. Always log the error message yourself. Read carefully what is written in the article you know about the inability to execute the order and what you need to do in this case.

It is quite possible that the absence of an error message in the log, for example the calculation of the lot size, is the cause of validation errors.

 
Andrey Kaunov:

This is the story on the following attempts with different numbers of orders


And here, on one of the following attempts, the validator actually uses the minimum lot, which knowingly cannot open with a $1 deposit. The question is, why were there no trades on the attempts earlier? And why does this run use a knowingly wrong minimum lot and deposit that initiates a validation error?

Hmmm...

And it's not a random shot. Here are the next three attempts.


Error sending a trade order 134 ...

Did the tester write this error? If yes, this is also one of the causes of validation errors. You must calculate the possibility of opening a position yourself and, if this is impossible, write your own message about the inability to trade with the set parameters in the journal, instead of sending a knowingly incorrect order to the server relying on the terminal and the server to do everything for you. With such incorrect orders, you can flood the server and then be safely banned from auto-trading. This is your fault, not the validator's.

Reason: