Questions from Beginners MQL5 MT5 MetaTrader 5 - page 395

 
Максим Вдовицкий:
I do not see the script window on the AVERAGE RANGE script on the graph
The log usually says everything in order, when called, what I did, what I was fired for...
 
thanks all sorted out!!!
 
I've got new price, new price, and so you can poke for 3min... and then you don't have to.., and then you don't have to!!!
 
Максим Вдовицкий:
I've got new price, new price, and so you can poke for 3min... and then you don't have to.., and then you don't have to!!!
And with a script the same thing will happen, if they requote manual trades, they will requote automatic ones even better.
 
Максим Вдовицкий:
I've got new price, new price, and so you can poke for 3min... and then you don't have to.. and then you don't have to!!!
What broker?
 
Evgeny Belyaev:
Which broker?
Grand s...I can't find a panel for binary, only paid ones. I cannot find a panel for binary, only paid ones, I will be grateful to those who will help a newbie.
 

Greetings all, question about calculating MA by bid array.

Can you tell me why it doesn't calculate.

macurrent0 = 0 постоянно
macurrent1, macurrent2, macurrent3 имеют одинаковое не правильное не меняющееся значение

I.e. they are always zero in the comment.

The function

does not return the value of Moving Average technical indicator calculated using data stored in the array.

doubleiMAOnArray(

...
extern int Ma_period=15;
double     xBuffer_Bid  []; // Массив значений   динамический, в котором индекс - номер тика, значение - это бид 
                            

int SIZE=0;                 // Вспомогательная переменная для массива                                  
int tickCounter, tickCounter_Current; 
double MaxSpeed;      // максимальная средняя скорость тиков с запуска системы

//+------------------------------------------------------------------+
int init()
  {   
//--- устанавливаем размер динамического массива
   
   if(ArrayResize(xBuffer_Bid, 2000000)<0) {Print(" Ошибка в изменении размера массива "); return(false);}
//--- установим индексацию для буфера как в таймсерии для динамического массива
  // ArraySetAsSeries(xBuffer_Time,true);    
//---   Возвращает количество элементов указанного массива. 
   
   int S_Bid=ArraySize(xBuffer_Bid);   
   if (S_Bid>=0) Print("Размер массива S_Бид: ",S_Bid);
   else Print("Ошибка. Массив S_Time не создан ",S_Bid);        
   ArrayInitialize(xBuffer_Bid, 0);
   
      
   return(0);
  }  
//+------------------------------------------------------------------+
int start()
  {  
  double avgBid = 0;    // средняя цена Бид
  int k=0;              // вспомогательная переменная для цикла
  double Summ_Time = 0; // время поступления крайней котировки для расчёта 
  double avgTime;       // среднее время поступление тиков 
  double avgSpeed;      // средняя скорость их поступления
  

  
  
  ArrayResize(xBuffer_Bid,SIZE);                                         // увеличение размера массивов на 1
   
   if (SIZE>0) 
      {
       xBuffer_Bid[SIZE-1] = NormalizeDouble(MarketInfo(_Symbol, MODE_BID ), Digits);                     // заполнение массива Bid  
       if (ArraySize(xBuffer_Bid) < 2147483647) //  
           Print (" Текущее значение xBuffer_Bid [SIZE-1] = ", DoubleToStr(xBuffer_Bid[SIZE-1],Digits) );            
      } 
   Print (" Текущее значение SIZE = ", DoubleToStr(SIZE,2) );   
   SIZE ++;                                                               // счётчик индекса массивов                                                                                                      
  
...
     
      // --------------   Расчёт МА по массиву бидов  --------------------------
       
        if ( SIZE >= Ma_period)
        if (ArraySize(xBuffer_Bid) < 2147483647) 
           { 
            double macurrent0=iMAOnArray(xBuffer_Bid,0,Ma_period,0,MODE_EMA,SIZE-1);
            double macurrent1=iMAOnArray(xBuffer_Bid,0,Ma_period,0,MODE_EMA,SIZE-2);
            double macurrent2=iMAOnArray(xBuffer_Bid,0,Ma_period,0,MODE_EMA,SIZE-3);
            double macurrent3=iMAOnArray(xBuffer_Bid,0,Ma_period,0,MODE_EMA,SIZE-4);
           //Print("
           }

  
    if (time_s!=0) 
       Comment(
              
              
              "macurrent0 = ",       NormalizeDouble(macurrent0,Digits), "\n",
              "macurrent1 = ",       NormalizeDouble(macurrent1,Digits), "\n",
              "macurrent2 = ",       NormalizeDouble(macurrent2,Digits), "\n",
              "macurrent3 = ",       NormalizeDouble(macurrent3,Digits), "\n",              
              
           "") ; 
          
     
   return(0);
  }
 

My Expert Advisor from the article "TRADING HISTORY-based FILTER"( www.mql5.com/ru/articles/1441 ) worked fine, but now it compiles and generates error '[' - invalid index value when the input parameters: double virtClosedOrders[0][5]; Help me understand.

Фильтр на основании истории торговли
Фильтр на основании истории торговли
  • 2006.11.29
  • Andrey Khatimlianskii
  • www.mql5.com
В статье рассматривается использование виртуальной торговли, как составной части фильтра открытия сделок.
 
Roman Shiredchenko:

Greetings all, question about calculating MA by bid array.

Can you tell me why it doesn't calculate.

I.e. they are always zero in the comment.

The function

does not return the value of Moving Average technical indicator calculated using data stored in the array.

doubleiMAOnArray(

...

Does it fill the array correctly? Try to fill it this way:

//+------------------------------------------------------------------+
//|                                                   FillArrays.mq4 |
//|              Copyright 2015, Artem A. Trishkin, Skype artmedia70 |
//|                       https://login.mql5.com/ru/users/artmedia70 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, Artem A. Trishkin, Skype artmedia70"
#property link      "https://login.mql5.com/ru/users/artmedia70"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//|   Input variables                                                |
//+------------------------------------------------------------------+
input int NumberOfStorableTicks=20; // Количество сохраняемых тиков
int numberOfStorableTicks; // Количество сохраняемых тиков
input int PeriodOfMA=5;             // Период сглаживания
int periodOfMA; // Период сглаживания
//+------------------------------------------------------------------+
//|   Global variables                                               |
//+------------------------------------------------------------------+
string symbol;    // Symbol()
int digits;       // Digits
//+------------------------------------------------------------------+
//|   Arrays                                                         |
//+------------------------------------------------------------------+
double      Mass_ticks[];
double      Mass_smoothed_values[];
//+------------------------------------------------------------------+
//|   Structures                                                     |
//+------------------------------------------------------------------+
   MqlTick struct_tick;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   symbol=Symbol();
   digits=(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);
   //---
   numberOfStorableTicks=(NumberOfStorableTicks<2)?2:NumberOfStorableTicks;
   periodOfMA=(PeriodOfMA<1)?1:PeriodOfMA;
   //---
   ArrayResize(Mass_ticks,numberOfStorableTicks);
   ArrayInitialize(Mass_ticks,0.0);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   Comment("");
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   if(SymbolInfoTick(symbol,struct_tick)) {
      double tick_bid=struct_tick.bid;
      FillArrays(numberOfStorableTicks,tick_bid,Mass_ticks);
      }
   string txt="";
   for(int i=numberOfStorableTicks-1; i>=0; i--) {
      txt+="\nmass["+IntegerToString(i)+"]: "+DoubleToString(Mass_ticks[i],digits);
      }
   Comment(txt);
  }
//+------------------------------------------------------------------+
void FillArrays(int array_size, double price, double &mass_price[]) {
   //--- сместим данные в массиве влево
   for(int i=array_size-1; i>0; i--) {
      mass_price[i]=mass_price[i-1];
      }
   //--- запишем новый тик в массив
   mass_price[0]=price;
}
//+------------------------------------------------------------------+

First, make sure that the array is filled with ticks correctly, and then try to smooth it out with the mask.

 

So here is the situation?

How to work correctly with iMAonArray???

Here is a picture:


Here's the code:

I can't figure out why the same values are wrong here:

Alert(" macurrent0 = ",      DoubleToStr(macurrent0,Digits));
            Alert(" macurrent1 = ",      DoubleToStr(macurrent1,Digits));
            Alert(" macurrent2 = ",      DoubleToStr(macurrent2,Digits));


Here, everything counts and outputs correctly - I'm talking about the contents of the three outermost cells of a one-dimensional array.

 Alert (" Текущее значение xBuffer_Bid [SIZE-1] = ", DoubleToStr(xBuffer_Bid[SIZE-1],Digits) );        
           if (SIZE>1)  Alert (" Предыдущее значение xBuffer_Bid [SIZE-2] = ", DoubleToStr(xBuffer_Bid[SIZE-2],Digits) );    
           if (SIZE>2)  Alert (" Предпредыдущее значение xBuffer_Bid [SIZE-3] = ", DoubleToStr(xBuffer_Bid[SIZE-3],Digits) );                
          } 
ArrayResize(xBuffer_Time,SIZE); ArrayResize(xBuffer_Bid,SIZE);                                         // увеличение размера массивов на 1
   
   if (SIZE>0) 
      {
       xBuffer_Bid[SIZE-1] = NormalizeDouble(MarketInfo(_Symbol, MODE_BID ), Digits);                     // заполнение массива Bid  
       if (ArraySize(xBuffer_Bid) < 2147483647) 
          {  
           Alert (" Текущее значение xBuffer_Bid [SIZE-1] = ", DoubleToStr(xBuffer_Bid[SIZE-1],Digits) );        
           if (SIZE>1)  Alert (" Предыдущее значение xBuffer_Bid [SIZE-2] = ", DoubleToStr(xBuffer_Bid[SIZE-2],Digits) );    
           if (SIZE>2)  Alert (" Предпредыдущее значение xBuffer_Bid [SIZE-3] = ", DoubleToStr(xBuffer_Bid[SIZE-3],Digits) );                
          } 
     
      } 
   Alert (" Текущее значение SIZE = ", DoubleToStr(SIZE,2) );  
   if ( SIZE >= Ma_period)
      if (ArraySize(xBuffer_Bid) < 2147483647) 
           { 
            double macurrent0=iMAOnArray(xBuffer_Bid,0,Ma_period,0,MODE_EMA,SIZE-1);
            double macurrent1=iMAOnArray(xBuffer_Bid,0,Ma_period,0,MODE_EMA,SIZE-2);
            double macurrent2=iMAOnArray(xBuffer_Bid,0,Ma_period,0,MODE_EMA,SIZE-3);
          
                 
           
            Alert(" macurrent0 = ",      DoubleToStr(macurrent0,Digits));
            Alert(" macurrent1 = ",      DoubleToStr(macurrent1,Digits));
            Alert(" macurrent2 = ",      DoubleToStr(macurrent2,Digits));
            
           }           
  
  
    SIZE ++;                                                               // счётчик индекса массивов для их заполнения необходимо его увеличение