Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 90
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
Thank you, for some reason it doesn't work that way with the lot.
double r=-1;
if (sy=="0") sy=Symbol();
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==sy || sy=="") {
if (OrderType()>1 && OrderType()<6) {
if (op<0 || OrderType()==op) {
if (mn<0 || OrderMagicNumber()==mn) {
if (r>OrderLots() || r==-1) {
r=OrderLots();
}}}}}}}
return(r);
}
How do I return the lot of the fourteenth sell stop on the snapshot lot= 0.03?
Thank you, for some reason it doesn't work that way with the lot.
if (sy=="0") sy=Symbol();
double r=MarketInfo(sy, MODE_MINLOT);
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==sy || sy=="") {
if (OrderType()>1 && OrderType()<6) {
if (op<0 || OrderType()==op) {
if (mn<0 || OrderMagicNumber()==mn) {
if (r>OrderLots()) {
r=OrderLots();
}}}}}}}
return(r);
}
Here's looking for the lot furthest away from the price
datetime t=0;
double r=-1,l=0;
if (sy=="0") sy=Symbol();
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==sy || sy=="") {
if (OrderType()>1 && OrderType()<6) {
if (op<0 || OrderType()==op) {
if (mn<0 || OrderMagicNumber()==mn) {
if (r>OrderOpenPrice() || r==-1) {
r=OrderOpenPrice();
l=OrderLots();
}}}}}}}
return(l);
}
Thank you, for some reason it doesn't work that way with the lot.
double r=-1;
if (sy=="0") sy=Symbol();
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==sy || sy=="") {
if (OrderType()>1 && OrderType()<6) {
if (op<0 || OrderType()==op) {
if (mn<0 || OrderMagicNumber()==mn) {
if (r>OrderLots() || r==-1) {
r=OrderLots();
}}}}}}}
return(r);
}
How do I return the lot of the fourteenth sell stop in the snapshot lot= 0.03?
No the function works correctly, why is the return value not 1 and14 orders but 2?
is it a tester?
It works correctly for me.
Here's looking for the lot furthest away from the price
Thank you, that makes sense. Found it, now you can find out all you need to know about it )
No the function works correctly, why is the return value not 1 and14 orders but 2?
is it a tester?
It works correctly for me.
Thank you, that makes sense. Found it, now you can find out everything you need to know about it )
To find out all the information about an order or a position, it's better to do it by ticket
// всё что угодно
}
...why is the return value not 1 and14 orders but 2?
Because I call it like this
To find out the full details of an order or position, it is better to do so from the ticket
// всё что угодно
}
But to do this, we first need to know the ticket of the last order 14
So the order still has to be searched first, like in the first function?
Or just replace SELECT_BY_POS with SELECT_BY_TICKET
But in order to do this, you must first find out the ticket of the last order 14
So the order still needs to be searched first as in the first function?
Or just replace SELECT_BY_POS with SELECT_BY_TICKET
It depends on what you need to check. In fact, we may find out everything here, select the order by price and then write the required parameters for it and return everything.
Using loops one more time is not a good idea, so, it's better to realize everything in one loop; it is not noticeable in the real trading, but tests in the tester will run for a long time. However, it all depends on the task, someone writes programs for the tester, and someone for trading, so you can use more than one cycle.
P.S. If the Expert Advisor is a pipsqueak, of course, it is better not to use a single cycle)