Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1745

 
Sergey Zhukov #:

Rename any *.mq4 file to any extension and try to compile it, it won't work, the compiler will try to compile it as if it were MT5.

Whatever I wrote there inside file, like(

does not work until I rename the file back to *.mq4.

How to bypass this, maybe someone knows from the pros?

Take a screenshot of the file folder


 

Good evening programmers! Help me understand!

Here are two functions when testing an EA to determine the maximum profit for the account and for a currency pair.

When testing, there are fundamentally different values and it's not swap and commission.

Please help me to understand the error. Thanks in advance !!!!

//+----------------------------------------------------------------------------+
//|Расчет максимального абсолютного профита сетки ордеров (по инструменту)     |
//+----------------------------------------------------------------------------+
double GetMaxProfitSymbol()
  {
   double oProfitSymbol = 0;
   for(int i = OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
        {
         if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
           {
            if(OrderType() == OP_BUY || OrderType() == OP_SELL)
              {
               oProfitSymbol += OrderProfit();
               if(oProfitSymbol > MaxProfitSymbol)
                  MaxProfitSymbol = oProfitSymbol;
              }
           }
        }
     }
   return(MaxProfitSymbol);
  }
//+----------------------------------------------------------------------------+
//|Расчет максимальной абсолютной прибыли сетки ордеров (по счету)             |
//+----------------------------------------------------------------------------+
double GetMaxProfit()
  {
   Profit = AccountProfit();
   if(Profit > MaxProfit)
      MaxProfit = Profit;
   return(MaxProfit);
  }


 
EVGENII SHELIPOV testing an EA to determine the maximum profit for the account and for a currency pair.

When testing, there are fundamentally different values and it's not swap and commission.

Please help me to understand the error. Thanks in advance !!!!


One counts the total profit of closed trades and the other one of open trades

 
MakarFX #:

one counts the total profit of closed trades and the other one of open trades

Makar if it is not difficult for idiots which one is which ?

 
EVGENII SHELIPOV #:

Makar if it's easy for idiots which one is which ?

I wrote it in order.
 
Is there any way to upload the history for only a year or two or three? If you don't need any earlier data.
Maybe there is a script
 
Ivan Butko #:
Is there any way to download the history only for a year or two or three? If earlier data is not needed.
Maybe there is a script

https://www.mql5.com/ru/docs/series/timeseries_access

code below, if multisymbol robot, I recommend, it will load history, avoid errors of getting the handle

set from when, there is an option.

I haven't checked how history loading works now, half a year ago, this code from the help was necessary.

Документация по MQL5: Доступ к таймсериям и индикаторам / Организация доступа к данным
Документация по MQL5: Доступ к таймсериям и индикаторам / Организация доступа к данным
  • www.mql5.com
Организация доступа к данным - Доступ к таймсериям и индикаторам - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Fast235 #:

https://www.mql5.com/ru/docs/series/timeseries_access

code below, if multisymbol robot, I recommend, it will load history, avoid errors of getting the handle

set from when, there is an option.

haven't checked how the history loading works now, half a year ago, this code from the help was necessary.

Thank you very much, I will give it a try

 
Fast235 #:

https://www.mql5.com/ru/docs/series/timeseries_access

code below, if multisymbol robot, I recommend, it will load history, avoid errors of getting the handle

set from when, there is an option.

I haven't checked how history loading works now, half a year ago, this code from help was necessary.

I tried it inMT4, 2021.11.14 17:01:40.506 Load History NZDCHF,M1: Start loadNZDCHF,M1from1635465600

Unfortunately, nothing happens. Went into the quote archive, it's 16216 unchanged.



 
Ivan Butko #:

Tried inMT4, 2021.11.14 17:01:40.506 Load History NZDCHF,M1: Start loadNZDCHF,M1from1635465600

Unfortunately nothing happens. Went to the quote archive, it's 16216 unchanged.

First check this

and second - maybe the broker does not have such a volume of quotes

Reason: