Questions from Beginners MQL5 MT5 MetaTrader 5 - page 77

 
FinEngineer: 2012.12.22 11:40:32 Pair_delta_RSI (EURGBP,M1) array out of range in 'Pair_delta_RSI.mq5' (92,37)
it turns out this error also appears... i.e. there are two errors...
In addition, you are concerned about two errors: "insufficient calculated data" and " array out of range )". But for some reason you haven't written anything about the second error (you haven't given an example code with line 92), although you've emphasized it several times.
 
Yedelkin:

Insert the code correctly.

It worked fine there, that "piece of code which is responsible for insufficient data". And correctly reported that when the first tick arrives, the data for RSI is not yet calculated by the terminal. If you do not like to receive error messages, try to do as above, namely to check for calculated data not only in OnCalculate(), but also in OnInit(). In other words, try to wait for data calculation for selected technical indicators in OnInit() and then move to the ticks processing in OnCalculate() when the data for indicators is guaranteed to be calculated.

Adding. In the end, the removal of a part of the check code doesn't increase the amount of calculated indicator data :)

I have inserted this check in the OnInit function, but in this function we don't know what 'rates_total' is... The error appears...'rates_total' - undeclared identifier... What to do?
 
Yedelkin:
You are also concerned about two errors: "insufficient calculated data" and "array out of range". But for some reason you didn't write anything about the second error (you didn't give a code example with line 92), although you emphasized it several times.
int limit;
   if(prev_calculated==0)
      limit=0;
   else limit=prev_calculated-1;
//считаем индикатор дельта рси
   for(int i=limit;i<rates_total; i++)
      DeltaRSI_Buffer[i]=RSI1_Buffer[i]-RSI2_Buffer[i];
   return(rates_total);
Here is line 92 somewhere around here...here is a code fragment...there must be an error somewhere)
 
FinEngineer: I inserted this check into OnInit function, but in this function we don't know what 'rates_total' is... the error comes out...'rates_total' - undeclared identifier... what to do?
Did you handle the example from the BarsCalculated() function as previously advised? There is no rates_total
 
FinEngineer somewhere around here on line 92... here's a piece of code... there's a mistake somewhere... it turns out)

I see. On the line

DeltaRSI_Buffer[i]=RSI1_Buffer[i]-RSI2_Buffer[i];
there is an exit outside the array. And the output is in RSI1_Buffer[i]. ...It's hard to answer yet, there should be no output outside the array.
 
Hi all ...who can tell me how the following code would look like in mql5 :
for (int i=3; i<Bars; i++)
{
Up=iFractals(NULL, 0, MODE_UPPER, i); if (Up>0) break;
}
 
i999i:
Hi all ...who can tell me how the following code would look like in mql5 :
for (int i=3; i<Bars; i++)
{
Up=iFractals(NULL, 0, MODE_UPPER, i); if (Up>0) break;
}

This article is to help.

Change double iFractals(string symbol, int timeframe, int mode, int shift) in fours to

double iFractalsMQL4(string symbol,
                     int tf,
                     int mode,
                     int shift)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   int handle=iFractals(symbol,timeframe);
   if(handle<0)
     {
      Print("Объект iFractals не создан: Ошибка ",GetLastError());
      return(-1);
     }
   else
      return(CopyBufferMQL4(handle,mode-1,shift));
  }

 
Question about strategy tester: I need to choose a set of parameters with max percentage of profitable trades - how do I do that? The "Balance + min DD" optimization criterion seems to be more or less suitable, but profit as a multiplier blocks everything else...
 
f2011:
Question about strategy tester: I need to select a set of parameters with max percentage of profitable trades - how can I do that? I think "Balance + min DD" is more or less suitable as an optimization criterion, but profit as a multiplier nullifies everything else...

What does this have to do with the balance and the percentage of profit trades?

I think there was an article, google "How to create your own criteria for optimizing a trading robot site:mql5.com".

 
R0MAN:

What does this have to do with the balance and the percentage of profit trades?

I think there was an article, google "How to make your own optimization criteria for a trading robot site:mql5.com".


Found it, thanks.

https://www.mql5.com/ru/articles/286

Создание собственных критериев оптимизации параметров эксперта
Создание собственных критериев оптимизации параметров эксперта
  • 2011.06.24
  • Dmitriy Skub
  • www.mql5.com
Терминал МetaTrader 5 дает новые возможности для оптимизации параметров создаваемых экспертов. Кроме уже имеющихся в тестере критериев оптимизации, разработчики получили инструмент для создания собственных критериев. Это открывает поистине безграничные возможности в тестировании и оптимизации экспертов. В статье рассматриваются практические способы построения таких критериев - как простых, так и достаточно сложных.
Reason: