Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 770

 
Igor Zakharov:

Use the ATR indicator

Thanks, but I still don't understand how it can be used in my case.

Someone threw a link to CopyRates (Thank you, unfortunately the comment has been deleted), so I'm trying to understand iVolume() is the difference between High and Low price or something else ?

I.e. in my case (as I understand it) I can create an array of monthly and weekly data and then average the values, etc.

 
Alexander Layzerevich:

trying to understand iVolume() is it the difference between High and Low price or something else ?

these are tick volumes, right click on the chart in MT and select show volumes - histograms will appear at the bottom of the chart - this is it

https://docs.mql4.com/ru/series/ivolume

iVolume - Доступ к таймсериям и индикаторам - Справочник MQL4
iVolume - Доступ к таймсериям и индикаторам - Справочник MQL4
  • docs.mql4.com
Значение тикового объема бара (указанного параметром shift) соответствующего графика или 0 в случае ошибки. Для получения дополнительной информации об ошибке необходимо вызвать функцию GetLastError().
 
Igor Makanu:

these are tick volumes, right click on the chart in MT and select show volumes - histograms will appear at the bottom of the chart - these are them

https://docs.mql4.com/ru/series/ivolume

Thank you very much for the clarification.

So that leaves the following: Create 2 arraysHigh and Low to calculate data for the month and 2 arraysHigh and Low to calculate for the week.

Then everything is averaged, etc.

I'll try to implement it all in the code...

I have another question: what is better to calculate the last month and last week?

Judging by the example :

Reference by initial position and number of required elements

intCopyHigh(
stringsymbol_name,// symbol name
ENUM_TIMEFRAMEStimeframe,// period
intstart_pos,//where to start
intcount,// how many we copy
doublehigh_array[]// array for copying of maximum prices
);

timeframe = PERIOD_D1;

start_pos = 1; // previous bar

count = 30; // 30 days (month)

 
Alexander Layzerevich:

Another question: What is the best way to count the last month and the last week?

It's better to date it, as there are skips of bars and weekends when there are no bars, so this will help:

Обращение по начальной и конечной датам требуемого интервала времени

int  CopyHigh(
   string           symbol_name,      // имя символа
   ENUM_TIMEFRAMES  timeframe,        // период
   datetime         start_time,       // с какой даты
   datetime         stop_time,        // по какую дату
   double           high_array[]      // массив для копирования максимальных цен
   );

https://docs.mql4.com/ru/series/copyhigh

CopyHigh - Доступ к таймсериям и индикаторам - Справочник MQL4
CopyHigh - Доступ к таймсериям и индикаторам - Справочник MQL4
  • docs.mql4.com
Функция получает в массив high_array исторические данные максимальных цен баров для указанной пары символ-период в указанном количестве. Необходимо отметить, что отсчет элементов от стартовой позиции ведется от настоящего к прошлому, то есть стартовая позиция, равная 0, означает текущий бар. При копировании заранее неизвестного количества...
 
Igor Makanu:

It would be better to date, as there are skips (quotes) of bars and weekends when there are no bars, that would help:

https://docs.mql4.com/ru/series/copyhigh

Thanks, just how to let the EA (Robot) know what date to start with and where to stop.

I find it easier to count 30 candles (30 days) from 1. Or 7 candlesticks (days).

I got this code:

//************************************************************************************************/
double iPointOrderStep()
{
double Awerage30 = 0, SummAwerage30 = 0;
double Awerage7 = 0, SummAwerage7 = 0;

double High30[], Low30[], High7[], Low7[];
//----------------Для месяца---------------------------
int iHigh30 = CopyHigh(Symbol(),PERIOD_D1,1,30,High30);
int iLow30 = CopyLow(Symbol(),PERIOD_D1,1,30,Low30);
//----------------Для недели---------------------------
int iHigh7 = CopyHigh(Symbol(),PERIOD_D1,1,7,High7);
int iLow7 = CopyLow(Symbol(),PERIOD_D1,1,7,Low7);

for(int i=0;i<30;i++) 
   {
      SummAwerage30 += (High30[i]-Low30[i]);
   }
for(int i=0;i<7;i++) 
   {
      SummAwerage7 += (High7[i]-Low7[i]);
   }

   Awerage30 = SummAwerage30/30;
   Awerage7 = SummAwerage7/7;
   
   double iPointOrderStep = NormalizeDouble(((Awerage30+Awerage7)/2),0);
   return (iPointOrderStep/6);
}
//************************************************************************************************/

But unfortunately it gives out a value = 0.

Can you tell me where the error is...

And also...

How to make calculation once a week at the beginning of session or when terminal was restarted ?

 
Alexander Layzerevich:

Thanks, but I haven't yet understood how it can be used in my case.

The essence of ATR is the average height of bars over a period. Might as well use MA(high)-MA(low). It's easier than unfolding the overshoot

 
Igor Zakharov:

The essence of ATR is the average height of bars over a period. You might as well use MA(high)-MA(low). It's easier than reversing the overshoot

i.e. according to the Example

intiATR(
stringsymbol,// symbol name
ENUM_TIMEFRAMESperiod,// period
intma_period// averaging period
);

double Awerage30= iATR(Symbol(),PERIOD_D1, 30); this will be the average numeric value for 30 days ?

 
Alexander Layzerevich:

i.e. according to the Example

intiATR(
stringsymbol,// symbol name
ENUM_TIMEFRAMESperiod,// period
intma_period// averaging period
);

double Awerage30= iATR(Symbol(),PERIOD_D1, 30); it will be the average value for 30 days ?

Not calendar days. 30 days backwards (Sundays, Saturdays)

Judging by the function without parameter shift you are doing in 5, and you asked a question in 4 :)

 
Igor Zakharov:

Just not the calendar ones. 30 day bars backwards (Sundays, Saturdays)

Judging by the function without the shift parameter you are doing in 5 and you asked the question in 4 :)

This branch is for both terminals. Especially with the same functions.

 
Artyom Trishkin:
This branch is on both terminals. Especially with the same functions.

Should the title be corrected then?

Reason: