[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 448

 
sss2019:


Here's the code

As a result, the alert outputs these messages:

You can see that the variable has a value, but you can't assign a variable value to an array, I can't figure out what the problem is


Don't you have to set the size of the array?
 
Maybe I explained something wrong, you only need to mark the first candle on m1 m5 m15 m30 h1 h4, which starts at 16:00 Moscow time, and the indicator marks (for example on m15 four candles).
 
Yulia:
Maybe I explained something wrong, you only need to mark the first candle on m1 m5 m15 m30 h1 h4, which starts at 16:00 Moscow time, and the indicator marks (well for example on m15 four candles).

To help and to do are slightly different things. Don't you agree?
 
Vinin:

Don't you have to set the size of the array?


Yes, I really forgot, I'm getting bogged down. Now the array is full, but the lines are still not displayed. Arrays are linked to buffers

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue

void init()
        {
        SetIndexBuffer(0, HighMass);
        SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1);
        SetIndexBuffer(1, LowMass);
        SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1);
        }
 
sss2019:


Yes indeed, I forgot, I'm exhausted already. Now the array is full, but the lines still don't show up. Arrays are linked to buffers


You should have given me the whole code. You don't want to guess what is clear to you.
 
Vinin:

Helping and doing are slightly different things. Don't you agree?

I agree with you completely, I asked for help, I've been poking around for a fortnight and no result, so your option doesn't suit me either, well thanks a lot, I'll figure it out on my own.
 

Good afternoon... Question about the ArrayGetAsSeries function. In order to understand how the ArrayGetAsSeries function works wrote the following script:

//+------------------------------------------------------------------------------------------+
//|                                                                ArrayGetAsSeries_плюс.mq4 |
//+------------------------------------------------------------------------------------------+
//|                         script program start function                                    |
//+------------------------------------------------------------------------------------------+
//------------------------------------ НАЧАЛО START -------------------------------------- 1 -
int start()                                           //функция start
  {                                                   //начало start
   double Timestart=GetTickCount();                   //переменная, с помощью которой вычисляется время (в милисекундах) начала выполнения эксперта 
   double array1[];                                   //объявляем массив-приемник (массив, куда будут скопированы данные)
   int element=ArrayCopy(array1,Open,0,0,WHOLE_ARRAY);//копируем данные по ценам открытия в пользовательский массив (начиная с нулевого бара)
   int size=ArraySize(array1);                        //устанавливаем количество элементов массива array1
   for(int i=0;i<=4;i++)                              //цикл по просмотру скопированных значений (первых пяти)
       {                                              //начало for
        Alert("Значение цены открытия бара № ",i," равно ",array1[i],
              "\nВремя цены открытия бара № ",i,": ",TimeToStr(iTime(NULL,0,i),TIME_DATE|TIME_MINUTES));//cообщение на экран
       }                                                                 //конец for
//----------------------------------------------------------------------------------------- 2 -
   Comment("\nФункция ArrayCopy(array1[],Open,0,0,WHOLE_ARRAY) вернула: ",element,
           "\nФункция ArraySize(array1) вернула: ",size,
           "\nФункция ArrayGetAsSeries(array1) вернула: ",ArrayGetAsSeries(array1),
           "\nСкрипт выполнялся всего ",GetTickCount()-Timestart," миллисекунд, из них: ",MathFloor((GetTickCount()-Timestart)/1000),
           " секунд ",((GetTickCount()-Timestart)/1000-MathFloor((GetTickCount()-Timestart)/1000))*1000," миллисекунд");//печать 
           //сообщения на экран
//----------------------------------------------------------------------------------------- 3 -
   return(0);                                                             //выход из start
  }                                                                       //конец start
//-------------------------------------- КОНЕЦ START -------------------------------------- 4 -

The script copied an array-timeseries of bar open prices into a custom array. Obviously, this custom array is organized as a timeseries array because the array elements are indexed from the last to the first (this is demonstrated in the screenshot where the Alert function has output the open time and price of the fourth bar. This bar is marked with a vertical line on the chart; we can also see the open price of this bar and in the properties window we can see that the bar open time is the same as in theAlert function). But the ArrayGetAsSeries function returns 0 which means: the user array is NOT organized as a timeseries array (left upper corner of screenshot).

Question: why did the ArrayGetAsSeries function return 0, even though the user array is organized as a timeseries array?

P.S. In order not to clutter up the forum, thanks in advance for the answer


 
7777877:
Q: Why did ArrayGetAsSeries function return 0, even though the user array is organized as a timeseries array?
Just because you copied data in some order doesn't mean the array is organized as a timeseries
 
ilunga:
Just because you copied the data in some order doesn't mean that the array is organized as a timeseries

But the point is that the opening price values, which are reproduced in the for loop from an already copied bar, are indexed from the last to the first. But, as far as I understand, this means (i.e. indexing from last to first) that the array is organized as a timeseries?

P.S. Thanks for the answer to my previous question about FileIsEnding and FileIsLineEnding functions

 
7777877:

But the point is that the opening price values, which are reproduced in the for loop from an already copied bar, are indexed from the last to the first. But, as far as I understand, this means (i.e. indexing from last to first) that the array is organised as a timeseries?

P.S. Thanks for the answer to my previous question about functions FileIsEnding and FileIsLineEnding

No, it only means that the data matched a piece of history.

You could have manually typed it in, for example. Or written from a text file. Or received it in the calculation.


After all, even having entered some conditional data "1.25 1.16 1.73 1.35" there we may get to the history for some currency many years ago. But that doesn't mean we've set up an array time series