Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1244

 
Nikita Bushuev:

Vladimir, I generated the code with MQL5 wizard as well. I tried your EA, it also does not work for me when I run it on GBPUSD currency.

The log says the following:

Read what it says in the log. There is a description of YOUR error. (if it is a tester there is one log, if it is a terminal there are two logs).


Also specify: on what symbol and on what timeframe you start. Today the telepaths are on holiday and there is no one to read your mind.

 
Vladimir Karputov:

Read what is written in the logbook. There is a description of YOUR error. (if it is a tester - there is one log, if it is a terminal - there are TWO logs).

The tester crashes in this place when creating an indicator handle, i.e. it = INVALID_HANDLE. In the symbol variable "EURUSD", the period is also set. How can it be and what does error 4804 mean?

ERR_INDICATOR_CANNOT_APPLY

4804

Indicator cannot be applied to another indicator

m_handle=iAC(symbol,period);
bool CiAC::Create(const string symbol,const ENUM_TIMEFRAMES period)
  {
//--- check history
   if(!SetSymbolPeriod(symbol,period))
      return(false);
//--- create
   m_handle=iAC(symbol,period);
//--- check result
   if(m_handle==INVALID_HANDLE)
      return(false);
//--- idicator successfully created
   if(!Initialize(symbol,period))
     {
      //--- initialization failed
      IndicatorRelease(m_handle);
      m_handle=INVALID_HANDLE;
      return(false);
     }
//--- ok
   return(true);
  }
Документация по MQL5: Предопределенные переменные / _Symbol
Документация по MQL5: Предопределенные переменные / _Symbol
  • www.mql5.com
Предопределенные переменные / _Symbol - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Nikita Bushuev:

The tester crashes here when creating an indicator handle, i.e. it = INVALID_HANDLE. In the symbol variable "EURUSD", the period is also set. How can it be and what does error 4804 mean?

ERR_INDICATOR_CANNOT_APPLY

4804

The indicator cannot be applied to another indicator

Read the log - there is a description of YOUR error. The sooner you read it, the sooner you will understand.

Also specify: on which symbol and on which timeframe you are launching. The telepaths are on holiday today and there is no one to read minds.
 
Vladimir Karputov:

Read the magazine - there is a description of YOUR error. The sooner you read it, the sooner you will understand.

Also clarify: on which symbol and on which timeframe you are launching. Today the telepaths are on holiday and there's no one to read your mind.

The issue was resolved by reinstalling the platform.

 
Vladimir Pastushak:

Dear developers, products in the marketplace cannot be verified

Code attached

CopyRates causes a hang, resulting in the market writing

test on EURUSD,H1 (netting)

tester takes too long time

Strategy tester report not found

And the validator has correctly passed the cutoff: You're probably not thinking too much, when you want to ask for 1440 elements at each TICK for all symbols in the terminal? You didn't even think: the server can easily have more than five thousand symbols, a symbol can have NO 1440 bars...


All in all, a topic for newbies. Definitely.

 
Hello, Could you please tell me why the charts are not loading? 14.08 registered on MT5 trading platform 4 charts out of 7 are still hanging waiting for update. Although on the previously registered demo account all charts are updated in time.
 
Vladimir Karputov:

Example

Result:


Thank you, Vladimir. I totally understand the logic behind your example. Do you believe it?

 
Сергей Таболин:

Thank you, Vladimir. I totally understand the logic behind your example. Do you believe it?

I'm not Vladimir, but I'll ask you: what doesn't work? Everything is long gone, and I don't feel like looking for your example. Please duplicate it again.

 
Artyom Trishkin:

I'm not Vladimir, but I have to ask: what's not working out? It's long gone, and I don't want to look for your example. Please duplicate it again.

Here is my example:

//+------------------------------------------------------------------+
//|                                                        cTest.mq5 |
//|                                     Copyright 2020, Tabolin S.N. |
//|                           https://www.mql5.com/ru/users/vip.avos |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, Tabolin S.N."
#property link      "https://www.mql5.com/ru/users/vip.avos"
#property version   "1.00"
//#property indicator_separate_window
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_plots   1
//--- plot bars
#property indicator_label1  "bars"
#property indicator_type1   DRAW_CANDLES
#property indicator_color1  clrGold
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- indicator buffers
double   barsBuffer1[];
double   barsBuffer2[];
double   barsBuffer3[];
double   barsBuffer4[];
//+------------------------------------------------------------------+
double   newCandles_Open[5]   = {106.785, 106.724, 106.760, 106.767, 106.769};
double   newCandles_High[5]   = {106.792, 106.765, 106.780, 106.781, 106.769};
double   newCandles_Low[5]    = {106.716, 106.719, 106.746, 106.758, 106.715};
double   newCandles_Close[5]  = {106.724, 106.760, 106.766, 106.769, 106.725};

int      tick_count           = 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
   SetIndexBuffer(0, barsBuffer1, INDICATOR_DATA);
   SetIndexBuffer(1, barsBuffer2, INDICATOR_DATA);
   SetIndexBuffer(2, barsBuffer3, INDICATOR_DATA);
   SetIndexBuffer(3, barsBuffer4, INDICATOR_DATA);
   
   ArraySetAsSeries(barsBuffer1  ,true);
   ArraySetAsSeries(barsBuffer2  ,true);
   ArraySetAsSeries(barsBuffer3  ,true);
   ArraySetAsSeries(barsBuffer4  ,true);
   
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,0);
   
   ArrayInitialize(barsBuffer1   ,0);
   ArrayInitialize(barsBuffer2   ,0);
   ArrayInitialize(barsBuffer3   ,0);
   ArrayInitialize(barsBuffer4   ,0);
//---
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int  OnCalculate(
   const int        rates_total,       // размер входных таймсерий
   const int        prev_calculated,   // количество обработанных баров на предыдущем вызове
   const datetime&  time[],            // массив Time
   const double&    open[],            // массив Open
   const double&    high[],            // массив High
   const double&    low[],             // массив Low
   const double&    close[],           // массив Close
   const long&      tick_volume[],     // массив Tick Volume
   const long&      volume[],          // массив Real Volume
   const int&       spread[]           // массив Spread
   )
{
   if(rates_total - prev_calculated > 1)
   {
      if(prev_calculated == 0)
      {
         Print("~~~~ Предварительный расчёт индикатора.");
         for(int i = 0; i < 5; i++)
         {
            barsBuffer1[0] = newCandles_Open[i];
            barsBuffer2[0] = newCandles_High[i];
            barsBuffer3[0] = newCandles_Low[i];
            barsBuffer4[0] = newCandles_Close[i];
         }
         Print("~~~~ Предварительный расчёт индикатора закончен.");
      }
      else return(0);
   }
   else Print("tick_count = ",++tick_count);
//--- return value of prev_calculated for next call
   return(rates_total);
}
//+------------------------------------------------------------------+
If I change barsBuffer1[0] to barsBuffer1[i], it is drawn. But then how do I add a new candle?
 
Сергей Таболин:

Here is my example:

If I change barsBuffer1[0] to barsBuffer1[i], it is drawn. But then how to add a new candle?

Not all arrays have the same focus.

Reason: