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

 
MakarFX:

Question 1: I do not understand the question(

The programme to get the beginning of the selected period or the period itself

 
Andrey Sokolov:

to get the start of the selected period or the period itself

No, "OrdersHistoryTotal Returns the number of closed and deleted orders in the current account history loaded in the client terminal."
 
Andrey Sokolov:

to get the start of the selected period or the period itself

Once upon a time, not only did the period depend on the settings in the "History" tab, but also the sorting order. Sorting seems to have been made immutable, but the period seems to have remained dependent. I.e., if we show the history from 01.12.2020 - 04.12.2020, then OrdersHistoryTotal() will only return the amount of orders for this period. And if my brain hasn't completely dried out, it counts by closing time. It doesn't consider the open time. Suppose, for example, an order was opened on 02.12.2020 and closed (not very good dates yet, but still) on 05.12.2020, it won't get into the period from 01.12.2020 to 04.12.2020.
 
Alexey Viktorov:
And if my brains aren't completely dry, it counts by closing time.

Yes, only close or delete

 
Alexey Viktorov. MakarFX thank you for clarifying what date is counted. But the question wasn't exactly about that. Let's say the "last month" period is selected, how can we get the start date of this (selected) period, even if there were no trades on that day?
 
Andrey Sokolov:
Alexey Viktorov. MakarFX thank you for clarifying what date is counted. But the question wasn't exactly about that. Suppose I chose the period "last month", how can I get the start date of this (selected) period, even if I haven't traded on that day?
There is no way.
 
Andrey Sokolov:
Alexey Viktorov. MakarFX, thank you for clarifying what date is taken into account. But my question was not exactly about this. Let's assume that we have selected "last month" period, how can we get the start date of this (selected) period programmatically, even if we haven't traded on that day?

There is no period start date, there is a warrant with the earliest date. Sad, to be honest, because if there are no orders in the history, there are no period dates. In fact, that's it.

 
Valeriy Yastremskiy:

There is no period start date, there is a warrant with the earliest date. Sad, to be honest, because if there are no orders in the history, there are no period dates. In fact, that's it.

this setting is not intended for "everyday tweaking" - configure the terminal once and do not touch it

in 99.9% of the trading systems the period of 3 months history will work perfectly, probably with the exception of TS, in which tens of thousands of orders per month - the period of 1 month should be set up here

SZZ: I did not notice any performance loss during a long period of history (it is clear that everything can be broken)) ) - but in the case of a 1 month period, there may be some surprises


So, if the MetaTrader developers allowed us to "rotate" the order history - bad!

)))

 
Igor Makanu:

this setting is not intended for "daily tweaking" - configure the terminal once and do not touch it

in 99.9% of the trading systems the period of 3 months history will work perfectly, well, probably with the exception of TS, in which several tens of thousands of orders per month - here, most likely a period of 1 month should be set up

SZZ: I did not notice any performance loss during a long period of history (it is clear that everything can be broken)) ) - but in the case of a 1 month period, there may be some surprises


So, if the MetaTrader developers allowed us to "rotate" the order history - bad!

)))

My approach is more pessimistic. We cannot do analysis on default data like history because it has to exist and we have to find it, and the efficient analysis requires its own data collection )))). History is for operational management only.

 

You can try pulling the date from the form using WinAPI. And order a new period too.

For four, I don't know how it is with five.


I found this, I did it a few years ago, like this:

#import "user32.dll"
   int GetForegroundWindow();
   int PostMessageA(int hWnd, int msg, int wParam, int lParam);
#import

//загружает всю историю закрытых ордеров
bool DownloadOrderHistory()
   {
   int eHandle=GetForegroundWindow();
   if(eHandle<=0) return(false);
   return(PostMessageA(eHandle,0x0111,0x8122,0)==1);
   }
GetForegroundWindow better replace....