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

 
mila.com:
Hello, can you help me please?
I want to build 5 lines down from the close of the first bar in 50 pips increments. I have no idea how to do it with a cycle.
//+------------------------------------------------------------------+
double price_close=iClose(Symbol(),PERIOD_CURRENT,1);
for(int i=1; i<=5; i++){                        // цикл по количеству линий
   int shift=i*50;                              // смещение очередной линии относительно цены Close
   double price_line=price_close-shift*Point(); // Значение цены очередной линии
   }
//+------------------------------------------------------------------+
 
Artyom Trishkin:
Thank you Artem, could you tell me how to get the opening price for 2016 or the current year or for example 2012?
 
Artyom Trishkin:

I told you already - attach the code using the SRC button. I'm sorry, are you completely unlearned?

Tell me, who would want to look at this piece of junk?

Artyom, in my opinion such posts should simply be deleted without explanation.

 
Alexey Viktorov:

Artem, in my opinion such posts should simply be deleted without explanation.

Well, you can see that Vitya (Vinin) took a look, corrected and posted the corrected version without any extra words or show-offs.

But if I had deleted it, so what? The person would be left without help.

 
mila.com:
Thanks, Artyom, could you tell me how to get the opening price for 2016 or the current year or, for example, 2012?
int  CopyOpen(
   string           symbol_name,     // имя символа
   ENUM_TIMEFRAMES  timeframe,       // период
   datetime         start_time,      // с какой даты
   int              count,           // сколько копируем
   double           open_array[]     // массив для копирования цен открытия
   );

You need to put the date of the desired year here.

CopyOpen - Доступ к таймсериям и индикаторам - Справочник MQL4
CopyOpen - Доступ к таймсериям и индикаторам - Справочник MQL4
  • docs.mql4.com
CopyOpen - Доступ к таймсериям и индикаторам - Справочник MQL4
 
Artyom Trishkin:

Well, you see that Vitya (Vinin) took a look, corrected and posted the corrected version without any extra words or show-offs.

But if I had deleted it, so what? The man would have been left without help.

Then he wouldn't have had to repeat it a third time. And Victor could have done the same thing a little later. But that's just my opinion, a reaction to public contempt. That's how I view the posting of such scrips.
 
Alexey Viktorov:

This is where you should put the date of the desired year.

It needs to get the start date of the year. And you suggest to insert already found date to CopyOpen()

 
mila.com:
Thank you, Artyom, tell me how to get the opening price of 2016 or the current year or, for example, 2012.

Well, there is a function that converts any date you pass to it to the opening date of the date you passed to the function:

//+------------------------------------------------------------------+
//| Возвращает время начала года                                     |
//+------------------------------------------------------------------+
datetime CRates::YearStartTime(const datetime time) {
   MqlDateTime stm;
   ::TimeToStruct(time,stm);
   stm.day=1;
   stm.mon=1;
   stm.hour=0;
   stm.min=0;
   stm.sec=0;
   return(::StructToTime(stm));
}
//+------------------------------------------------------------------+
And what date and how you will pass there ...
 
Artyom Trishkin:

She needs to get the start date of the year. And you suggest to paste already found date into CopyOpen()

It's strange... Yesterday I could read and today I can't...

Forum on trading, automated trading systems & strategy testing

Any questions for newbies on MQL4, help and discussion on algorithms and codes

mila.com, 2017.09.06 08:39

Thanks, Artyom, advise how to get the opening price of 2016 or current year or for example 2012

 
Alexey Viktorov:

It's strange... Yesterday I could read and today I can't...


Well then - I can't read - something of my own making up ;)