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

 
dzhini:
Can you tell me how to determine the price coordinate of a graphical object of type OBJ_LABEL?

Use ObjectGet with parameters OBJPROP_XDISTANCE, OBJPROP_YDISTANCE
 

1 question.If there is a number 10 in brackets for the name of an array, it means that there are 11 elements in that array

Question 2. I should make sure that there are no zeros after the array's end_set, but all the prices from the Allow_set to the end_set should be there . Am I doing the ArrayResize correctly?

//global
price[10];
int i =-1;
//-------------------
int start()
{
if(!TF_F_NewBar())return(0);
if(Allow_setting == true)
{
i++;
ArrayResize(price, i);//I take it that the price[10] array will remain price[0] (is this allowed ?),
//i.e. one place in the array where zero is written
. So with every step (bar) we will

//increase size of the array
price[i] = Close[1] ; // I write Close[1] instead of zero into this one place array. If this is allowed,
// then you can specify the minimum array price[0]
;
}
if(end_set== true)
{
Array data processing ;

i = -1; //after processing, return to original position
}
}

Apologies for putting the code in the wrong way as it should be.

 
gince:

1 question.If there is a number 10 in brackets for the name of an array, it means that there are 11 elements in that array


Such array contains 10 cells with indexes from 0 to 9. It means the first element will be in the cell 1 with index 0, that's why the for statement starts with 0.

Question 2. I should make sure that there are no zeros after the array's end_set, but all the prices from the Allow_set to the end_set should be there . Am I doing the ArrayResize correctly?

Do you want to get 10 close prices of the last 10 bars into the array?

Sorry, I didn't put the code in the right way.

You can always tweak what you have written, just click on "Edit".


 
paladin80:

Do you want to array the last 10 prices close to the last 10 bars?

You can always tweak what you have written, just click on "Edit".


No, not 10, but Allow_select to end_set. It can be either 40 or 65. You have to make sure that there are no zeros in the array after the end_set.
 
gince:
No, not 10, but Allow_select before end_select. This can be either 40 or 65. It should not have zeros after the end_set in the array


That's fine, just set the array as dynamic at the beginning:

double цена[];

...

int init ()

{

…

ArrayResize (цена,0);

…

}

int start ()

{

…

}

 
gince:
No, not 10, but Allow_select before end_select. This can be either 40 or 65. It should not have zeros after the end_set in the array

double цена[]; // динамический массив
int    начало=2; // 0 (ноль) это текущий, ещё не закрытый бар
int    конец=45;
int    количество;
//---
int init()
  {
   количество=конец-начало; // =43
   ArrayResize(цена, количество); // устанавливается размер массива - 43 ячейки
   return(0);
  }

//---
int start()
  {
    if(!TF_F_NewBar()) return(0);    
    if(Разрешить_набор == true)
    {
      for (int i=0; i<=количество-1; i++) // заполнить 43 ячейки с индексом от 0 до 42.
                                          // в ячейке 0 будет цена close для бара 2 и т.д.
      цена[i]=Close[i+начало];   
    }
   return(0);
  }
//---
 
paladin80:

I don't know how many elements an array should have. It could be 40 or 65. In a word, we need a dynamic array

double цена[]; // динамический массив

int i = -1;
//---
int init()
  {
   ArrayResize(цена, 0); // устанавливается размер массива минимальным - 1 ячейка
   return(0);
  }

//---
int start()
  {
    if(!TF_F_NewBar()) return(0);    
    if(Разрешить_набор == true)                // это сигнал по индюку
    {
      //Пришел новый бар и резрешение есть 
      i++.                                     //увеличиваем индех            
      ArrayResize(цена, i)
      цена[i]=Close[i];   
   }
   if(конец_набора== true)   // это сигнал по индюку
   {
      //----
      //работа с массивом
      //----
      Pазрешить_набор == false; 
      i= -1;
//А тут
надо что нибуть делать с бывшим массивом (уменшить, очистить или еще что то)      
   }
   return(0);
 }
//---
 
gince:

I don't know how many elements an array should have. It could be 40 or 65. In a word, we need a dynamic array

Let me ask you from the other side. Why do you need to fill the array with close prices? double close[] itself is already an array of close prices.
 
paladin80:
I'll ask you from the other side. Why do you need to fill an array with close prices? double close[] itself is already an array of close prices.
I don't care whether it's close or open. The most important thing is that they are from now to now. Then I filter them. Filtering should be done in this period from now to now. When I have filtered an array, I redo another one with different data. And I draw using the last array. So, this array you asked about is just an intermediate one.
 
Right now, for each bar, it puts one cloze in the array. And if I don't do that, then I'll have to calculate from which bar to collect data, cycle, filter. And this leaves only the latter.
Reason: