![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello Andrey!
Hello Andrey!
The GetOpenPriceByLot() function.
This function returns the opening price of a position or order by lot size. The selection of positions to be taken into account is specified by external parameters:
The GetTicketByLot() function.
This function returns the ticket of a position or order by lot size. The selection of the positions to be taken into account is specified by external parameters:
ZS. Attached is a script to test GetTicketByLot() function.
Hello Igor!
Thank you very much for the new features and for being so quick. Everything is very good. The function returns, for example, a ticket order by conditions, which can be set by external variables or you can not use them. I'm a little unclear about this line here:
if ((op<0 || OrderType()==op) && (OrderType()>1 && OrderType()<6))
Here we check for the if statement condition, i.e., if the external variable <0, any order type is available OR if we write, for example, OP_BUY in the function call, the selection will be made from among OP_BUY orders. This condition is clear, but further we have an equivalent condition written through&& which states thatOrderType() must be within the range of pending orders, i.e. from 1 to 5. Our OP_BUY type is not included into this range and therefore the operator's condition must be false and control must pass to the operator following the if-else operator, i.e. it is difficult for me to say where, somewhere behind the curly body arrow. It seems to me that we should specify here the condition for market orders and a separate function of pending orders of the same kind. That is, if I want to make a selection from market orders and do not know its exact type, I take the external variable <0 but address the function where conditions from 0 to 1 are written. The same is true for pending orders. So, I have come to the conclusion that we should use a different function for each category of order types when using this useful condition.
Also, I have a problem with library connection. I've searched and read, but the connection gives an error when compiling the EA I'm writing. I don't have time to deal with it yet, I want to write profitable Expert Advisor faster, so I have copied all three needed libraries and attached them after special function start(), and placed their global variables in global variables of EA and commented out references to them. It is not very convenient, but it works.I'm a little unclear about this line here:
if ((op<0 || OrderType()==op) && (OrderType()>1 && OrderType()<6))
Thank you! Corrected... This is a consequence of copying, i.e. using a preform of another function intended to work only with limit and stop orders.
I also have a problem with connecting libraries. I have searched and read, but the connection gives me an error when compiling the Expert Advisor I am writing. I don't have time to figure it out, and I want to write a profitable Expert Advisor faster, so I have copied all three needed libraries and attached them after special function start(), and placed their global variables in global EA variables and commented out references to them. It is not very convenient, but it works.
By the way, I don't use my own libraries in the form of MQH files. I usually copy the functions I need in my EA, i.e. my standard ready-made EA is a single MQ4 file. Everything I need is inside this file. Yes, there is some repetitiveness in the code. But there are no problems with versions of functions.
By the way, I also noticed that you have testing scripts for each function and they have all the additional functions you need, which you can simply add to your EA along with the function and it will be all in one file with nothing extra. Functions are simple and useful, but with your permission I will make four of them for myself: two for positions and two for stops. They will be more universal for delicate requirements of my EA. But now I see how easy it is to do. Thank you very much Igor.
Regards Andrei.
The TimeOpenFirstPos() function.
This function returns the time of the first open position. Selection of positions to be taken into account is specified by external parameters:
Hello
How to add a foeba to your SetRegression()(https://www.mql5.com/ru/forum/107476/page35 ) channel.
Hello
How to add a foeba to your SetRegression()(https://www.mql5.com/ru/forum/107476/page35 ) channel.
Duck, it's easy: