I'm tired of these infinite errors. What's wrong here?

 
//+------------------------------------------------------------------+
//|                                                  BreakevenEA.mq4 |
//|                                                     Igor Muratov |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Igor Muratov"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property description "TEST ON DEMO THEN ON REAL ACCOUNT TO OBTAIN ASCENDING PROFIT CURVE. LET'S SMASH THE MARKET."

#define MAGICMA 22813379

extern double BreakEvenProfit = 25
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Comment("Equity is" + AccountEquity());
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   for(i=0; i<=OrdersTotal()-1; i++)
   {
     OrderSelect(Symbol(), SELECT_BY_POS);                // EA HASN'T BEEN MADE YET. JUST SENDING YOU THE PART OF THE CODE WHICH HAS 11 ERRORS.
     RefreshRates();
   
   
  }
//+------------------------------------------------------------------+
Открой новые возможности в MetaTrader 5 с сообществом и сервисами MQL5
Открой новые возможности в MetaTrader 5 с сообществом и сервисами MQL5
  • 2022.08.16
  • www.mql5.com
MQL5: язык торговых стратегий для MetaTrader 5, позволяет писать собственные торговые роботы, технические индикаторы, скрипты и библиотеки функций
 

Learn to code.


//+------------------------------------------------------------------+
//|                                                  BreakevenEA.mq4 |
//|                                                     Igor Muratov |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Igor Muratov"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property description "TEST ON DEMO THEN ON REAL ACCOUNT TO OBTAIN ASCENDING PROFIT CURVE. LET'S SMASH THE MARKET."

#define MAGICMA 22813379

extern double BreakEvenProfit = 25;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Comment(StringFormat("Equity is %f", AccountEquity()));
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   for(int i=0; i<=OrdersTotal()-1; i++)
   {
     if(!OrderSelect(i, SELECT_BY_POS))
     { continue; }                // EA HASN'T BEEN MADE YET. JUST SENDING YOU THE PART OF THE CODE WHICH HAS 11 ERRORS.
     RefreshRates();
   }
   
  }
//+------------------------------------------------------------------+
 
Dominik Christian Egert #:

Learn to code.


Thanks. 

 
IgorFX Trading #:

Thanks. 

Welcome.

 
Dominik Christian Egert #:

Welcome.

 Just reading the book and decided to practice. I copied the code from here. So is it not true? 

  
Files:
 
IgorFX Trading #:

 Just reading the book and decided to practice. I copied the code from here. So is it not true? 

  

Your code differes from the one in the book, at least related to the first post.


Checking the result of your "OrderSelect" statement should be done. - This way you continue to check all orders by position, even if a call fails. 


Also, you should change the for-loop as follows, as the amount of open orders could shrink while processing.

   for(int cnt = OrdersTotal() - 1; (cnt >= 0) && !_StopFlag; cnt--)
   {
     if(!OrderSelect(cnt, SELECT_BY_POS))
     { continue; }                // EA HASN'T BEEN MADE YET. JUST SENDING YOU THE PART OF THE CODE WHICH HAS 11 ERRORS.
     RefreshRates();
   }
Reason: