Hello all! Could you please tell me how to select the last closed order in mql4 history? I am using OrderSelect(0,SELECT_BY_POS,MODE_HISTORY), which selects the first closed order.
Sergei Maksimenko: Hello all! Could you please tell me how to select the last closed order in mql4 history? I am using OrderSelect(0,SELECT_BY_POS,MODE_HISTORY); it selects the first closed order, but how can I select the last one?
Instead of 0, you should use OrdersHistoryTotal()-1.
It is easier to track bar changes by bar time changes rather than by bar prices. At the end of the algorithm, we will remember the current bar time, and at the beginning we will compare it with the current time.
For example, for the M5 bar, the current time will be changed only at the beginning of the bar and every 5 minutes....
Testing of such programs is performed "by opening prices", which greatly speeds up the process of code debugging and optimization.
Thus, I will have to find out what TF it is now and do rounding if a bar doesn't appear in exactly 5 minutes... In my case, the code is very easy and not burdensome. Of course, the open price may not change, but you can check by the sum of two previous bars. In general, if you hadn't written about advantages of your solution, I would have understood it better if I had attached the code - I am not a programmer...
-Aleks-: So I have to find out what TF it is now, do the rounding if the bar doesn't appear in exactly 5 minutes... In my case the code is very easy and not cumbersome. Of course the opening price may not change, but you can check by the sum of the past two bars. In general, if you hadn't written about advantages of your solution, I would have understood it better if I had attached the code - I am not a programmer...
-Aleks-: So I have to find out what TF it is now, do the rounding if the bar doesn't appear in exactly 5 minutes... In my case the code is very easy and not cumbersome. Of course the opening price may not change, but you can check by the sum of the past two bars. In general, if you hadn't written about advantages of your solution, I would have understood it better if I had attached the code - I am not a programmer...
//код в фигурных скобках выполнится только один раз, на открытии каждого нового бара М5
datetime prevTime;
if(prevTime!=iTime(Symbol(),PERIOD_M5,0))
{
...
}
prevTime=iTime(Symbol(),PERIOD_M5,0);
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hello all! Could you please tell me how to select the last closed order in mql4 history? I am using OrderSelect(0,SELECT_BY_POS,MODE_HISTORY); it selects the first closed order, but how can I select the last one?
It is easier to track bar changes by bar time changes rather than by bar prices. At the end of the algorithm, we will remember the current bar time, and at the beginning we will compare it with the current time.
For example, for the M5 bar, the current time will be changed only at the beginning of the bar and every 5 minutes....
Testing of such programs is performed "by opening prices", which greatly speeds up the process of code debugging and optimization.
So I have to find out what TF it is now, do the rounding if the bar doesn't appear in exactly 5 minutes... In my case the code is very easy and not cumbersome. Of course the opening price may not change, but you can check by the sum of the past two bars. In general, if you hadn't written about advantages of your solution, I would have understood it better if I had attached the code - I am not a programmer...
Thank you - easier than I pictured in my mind after reading the comment.
Good afternoon!
Who can tell me how to make a drop-down menu in expert settings?
Like the one in the picture. Thanks.
Good afternoon!
Who can tell me how to make a drop-down menu in expert settings?
Like the one in the picture. Thanks.
So I have to find out what TF it is now, do the rounding if the bar doesn't appear in exactly 5 minutes... In my case the code is very easy and not cumbersome. Of course the opening price may not change, but you can check by the sum of the past two bars. In general, if you hadn't written about advantages of your solution, I would have understood it better if I had attached the code - I am not a programmer...
Where is the mistake?
Where is the mistake?