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

 
Alexey Viktorov:
Artyom Trishkin:
Thank you, please forgive me, I have not formulated my thought correctly.
I want to getthe opening price of the year, not by specifying a particular date, but by passing an index, as if there is a bar of 1 year in the terminal. Last month has index 1, also make last year index 1.Help to implement this?
 
mila.com:
Thank you, please forgive me, I have formulated the thought incorrectly.
I want to getthe opening price of the year, not by specifying a specific date, but by passing an index, as if there is a 1 year bar in the terminal. Last month has index 1, same way to make last year index 1.Help to implement this?

Very simple.

double f(int numYear)
 {
   MqlDateTime newYear = {0}; // Обнулить обязательно.
   newYear.year = numYear;
   double priceOpenYear[1];
   CopyOpen(_Symbol, PERIOD_MN1, StructToTime(newYear), 1, priceOpenYear);
   return(priceOpenYear[0]);
}

And it doesn't depend on working/non-working day in any way. PERIOD_MN1 is always the first day of the month, also PERIOD_W1 is always Sunday.

 

Guys!

One of the clients is complaining that EAs are dropping when the price moves sharply. This has happened with different brokerage companies.

There is nothing in their code that can cause deletion. I have never faced this problem myself.

What may be the problem?

 
Vladimir Tkach:

Guys!

One of the clients is complaining that EAs are dropping when the price moves sharply. This has happened with different brokerage companies.

There is nothing in their code that can cause deletion. I have never faced this problem myself.

What may be the problem?


You do not see anything in the logs? Not even about unloading?

 
Aleksey Vyazmikin:

Is there nothing straightforward in the logs? Not even about the unloading?


2017.08.08 23:31:29.035 Expert DEBUT 3.0 GBPUSD,M1: removed

 
Vladimir Tkach:

2017.08.08 23:31:29.035 Expert DEBUT 3.0 GBPUSD,M1: removed


If expert doesn't use patterns - reopens itself on its chart, then I have no hypotheses...

 
Aleksey Vyazmikin:

If the expert doesn't use patterns - reopens on its chart itself, then I have no hypotheses...

Vladimir Tkach:

2017.08.08 23:31:29.035 Expert DEBUT 3.0 GBPUSD,M1: removed

Is there enough free memory? Expert does not clog the RAM with anything?

 

Good evening.

Please tell me whyOrderSelect(Ticket,SELECT_BY_TICKET,MODE_TRADES) function doesn't work.

It returns an error: expression could not be evaluated. Ticket - value is filled.

I cannot understand anything ((((

Thank you.

 
rabanik:

Good evening.

Please tell me why OrderSelect(Ticket,SELECT_BY_TICKET,MODE_TRADES) function doesn't work.

It returns an error: expression could not be evaluated. Ticket - value is filled.

I cannot understand anything ((((

Thank you.

When selecting an order by ticket, we don't need to specify pool - MODE_TRADES is redundant here - this parameter is ignored when selecting by ticket and the order is selected from one of the two lists - from the list of closed or from the list of market positions - depending on whether the position is closed or not yet.

After the successful selection of an order based on the ticket, in order to understand which of the two lists the order is selected from, it is necessary to check the position closing time - if it is higher than zero, then the order has already been closed and was selected from the list of historical orders, otherwise - the order is still in the market.

But in order to understand what your error is, you need to attach the code - give more information, because in this line, in principle, there is no error (except that you do not check the return result of the function, you use a modifier which is ignored in this case and there is no ";" after the closing bracket).

 
Alexey Viktorov: Very simple.

Thank you, but it returns zero for me. What could be the reason?

Comment("OpenYear : ",DoubleToString(f(1))); 
Reason: