[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 616

 

Good afternoon!

I am writing 4 variables ("tick_up", "tick_dn", "pip_up", "pip_dn") calculated in the indicator to a text file. Since they are calculated tickwise

I cannot see the possibility to create a script and I use the indicator and run it on the history.

Here is the code of recording.

.............
     
 handle = FileOpen("TickHistory.txt", FILE_CSV|FILE_WRITE, '\t');
   FileWrite(handle, "tick_up", "tick_dn", "pip_up", "pip_dn");
   FileWrite(handle, MA1[i],MA2[i],ExtBuffer1[i], ExtBuffer0[i]);  //---Также пробовал организовать вывод НЕ через массив, а через переменную типа double. 
            
   }      
      FileClose(handle);       
return(0);
}

The file TickHistory.txt is created and only 2 lines are written into it

tick_up  tick_dn  pip_up    pip_dn   //--- Имя переменных
 0.35     0.65     0.28      0.71   //--- Рассчитываемые данные

Why is ONLY ONE line of data written to the file?

 
DOCTORS:


I apologize for my lack of correctness to my requests ... The essence is that the calculation on the highs of different timeframes is different, it is understandable, therefore I did the following (it is necessary for the strategy of trading on different timeframes):



Show the picture

The indicator needs to be reworked, there seems to be a lot of unnecessary calculations

 
Fox_RM:

Good afternoon!

I am writing 4 variables ("tick_up", "tick_dn", "pip_up", "pip_dn") calculated in the indicator to a text file. Since they are calculated tickwise

I cannot see the possibility to create a script and I use the indicator and run it on the history.

Here is the code of recording.

The file TickHistory.txt is created and only 2 lines are written into it

Why is ONLY ONE line of data written to the file?


This is how you write down two lines

 
Fox_RM:

Good afternoon!

I am writing 4 variables ("tick_up", "tick_dn", "pip_up", "pip_dn") calculated in the indicator to a text file. Since they are calculated tickwise

I cannot see the possibility to create a script and I use the indicator and run it on the history.

Here is the code of recording.

The file TickHistory.txt is created and only 2 lines are written into it

Why is ONLY ONE line of data written to the file?

Because every time you open a file in FILE_WRITE mode without FILE_READ it is completely overwritten. https://docs.mql4.com/ru/files/FileOpen
 
alsu:
Because every time you open a file in FILE_WRITE mode without FILE_READ it is completely overwritten. https://docs.mql4.com/ru/files/FileOpen
I.e. the correct way: open once before the loop and write the header, write data many times in the loop, close it after the loop.
 

And one more question about working with iMAonArray and similar functions.

I'm calculating a slip from Volume:

//----Объявление массивов
double ExtBuffer0[],ExtBuffer1[],MA1[],MA2[],ExtVol[]; //--- Связанные через SetIndexBuffer массивы
double Mass1[], Mass2[], Mass3[];               //--- Массивы просто объявленные на глобальном уровне

   SetIndexBuffer(0,MA1);
   SetIndexBuffer(1,MA2);
   SetIndexBuffer(2,ExtBuffer0);
   SetIndexBuffer(3,ExtBuffer1);
   SetIndexBuffer(3,ExtVol);
  
IndicatorBuffers(5);


//----Вычисление среднего Вариант №1 (через связанные массивы) 
ExtVol[i]=Volume[i]; 
MA1[i]=iMAOnArray(ExtVol[i],0,8,0,0,0); //--- Или MA1[i]=iMAOnArray(Volume[i],0,8,0,0,0);

//----Вычисление среднего Вариант №2
Mass1[i]=Volume[i]; 
Mass2[i]=iMAOnArray(Mass1[i],0,8,0,0,0); //--- Или Mass1[i]=iMAOnArray(Volume[i],0,8,0,0,0);

Why do I get sliding calculation only through arraylinked through SetIndexBuffer ?

If I do it with a regular array, nothing comes out.

 
alsu:
I.e. this is correct: open once before the loop and write the header, write the data many times in the loop, close it after the loop.
Got it!) Question cleared!) Thank you!
 

Gentlemen! How to describe the bar cycle more intelligently?



Gentlemen! Please advise me, if it's not too difficult.

If I want to compare the indicators on three or four consecutive bars, how should I write the code correctly?

I am looking at different variants and get confused.

I'm sorry, if I made someone nervous...

 

Dear Connoisseurs! Question about modification and trellings.



I beg your pardon!

Please, be kind, who understands. How to properly describe the modification of orders,

as well as trailing stops and profits on the five digits?

Tried the standard options, but they somehow work unstable.

Maybe someone will throw a link?

I thank you in advance.

 
Can you please tell me how to declare an indicator superimposed on another indicator (e.g. MA on RSI) in an EA?
Reason: