Does the count of orders in this function start from 0 or 1? That is, if there is one order, does OrdersTotal() equal 0 or 1?
TheOrdersTotal() shows the quantity, i.e., if there is one order, thenthe OrdersTotal() will equal 1, but in the list of orders, the report starts with 0
0 - first order
1 - second order
2 - third
and so on.
So, if we start the search from the end of the list, we have tosubtract one from the total number ofOrdersTotal().
OrdersTotal() shows the quantity, i.e. if there is one order, thenOrdersTotal() will be one, but in the list of orders the report starts from zero
0 - first order
1 - second order
2 - third
and so on.
So, if we start the search from the end of the list, we have tosubtract one from the total number ofOrdersTotal().
But if we don't subtract one from the first expression, it won't be an error, because if we have one order, two iterations will happen. Unless we don't need to make two iterations when we can do everything we need in one, so -1, right?
wishmast: But if the first expression does not subtract one, it will not be an error, if we have one order, two iterations will happen. Unless there is no need to do two iterations when everything we need can be done in one, so -1, right?
trader781: Since we have a stack of orders, why can't we just pull out the one we need? (The right ones) and do with them what we want? For example order (i-4)
Because it will only work in the MT4 tester. Or when trading on only one symbol and only one this EA.
If you think about it, the EA is the same for every pair, only the account balance is common (the switch will be the last)
the filter goes to all orders which satisfy the condition market-open by the EA-if the simulation matches
what is wrong?
Well, it has already been explained to you above what is wrong. We can count orders as ours only and take array indexes by total amount - we will get an array with empty cells. And what is this for? And if the array was not empty, the "unnecessary" fields will contain unnecessary rubbish that will lead to errors, and we are talking about money.
Vitalie Postolache: Well it has already been explained to you above what is wrong. Orders count only their own, and take the array indexes for the total number - you get an array with empty cells. And what is this for? And if the array was not empty, the "unnecessary" fields will contain unnecessary trash that will lead to errors, and we are talking about money.
OK, that's how it works.
struct myorder { int Ticket; double orderopenprice; int ordertype; double profit; double stoploss; double lot; };
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.
Please tell me why the OrdersTotal() function will write -1 when searching for orders.
Example: for (i=OrdersTotal()-1 ;i>=0; i--)
why not just OrdersTotal()?
Does the count of orders in this function start from 0 or 1? That is, if there is one order, is OrdersTotal() equal to 0 or 1?
Please tell me why the OrdersTotal() function will write -1 when searching for orders.
Example: for (i=OrdersTotal()-1 ;i>=0; i--)
why not just OrdersTotal()?
Does the count of orders in this function start from 0 or 1? That is, if there is one order, does OrdersTotal() equal 0 or 1?
TheOrdersTotal() shows the quantity, i.e., if there is one order, thenthe OrdersTotal() will equal 1, but in the list of orders, the report starts with 0
0 - first order
1 - second order
2 - third
and so on.
So, if we start the search from the end of the list, we have tosubtract one from the total number ofOrdersTotal().
OrdersTotal() shows the quantity, i.e. if there is one order, thenOrdersTotal() will be one, but in the list of orders the report starts from zero
0 - first order
1 - second order
2 - third
and so on.
So, if we start the search from the end of the list, we have tosubtract one from the total number ofOrdersTotal().
But if the first expression does not subtract one, it will not be an error, if we have one order, two iterations will happen. Unless there is no need to do two iterations when everything we need can be done in one, so -1, right?
Yes correct
Not quite right.
You can use prefix decrement.
Since we have a stack of orders, why can't we just pull out the one we need? (The right ones) and do with them what we want? For example order (i-4)
Because this will only work in the MT4 tester. Or when trading on only one symbol and only one this EA.
If you think about it, the EA is the same for every pair, only the account balance is common (the switch will be the last)
the filter goes to all orders satisfying the condition market-open by the Expert Advisor-if the symbol coincides
what is wrong?
If you think about it, the EA is the same for every pair, only the account balance is common (the switch will be the last)
the filter goes to all orders which satisfy the condition market-open by the EA-if the simulation matches
what is wrong?
Well it has already been explained to you above what is wrong. Orders count only their own, and take the array indexes for the total number - you get an array with empty cells. And what is this for? And if the array was not empty, the "unnecessary" fields will contain unnecessary trash that will lead to errors, and we are talking about money.
OK, that's how it works.
{
int Ticket;
double orderopenprice;
int ordertype;
double profit;
double stoploss;
double lot;
};
myorder orders[];
int i;
int count1=0;
void CalcOrders()
{
for(i=OrdersTotal()-1; i>=0; i--)
{
if((OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) && (OrderSymbol()==Symbol())
&& (OrderMagicNumber()==Magic) && (OrderType()<2))
orders[count1].Ticket=OrderTicket();
orders[count1].lot=OrderLots();
orders[count1].orderopenprice=OrderOpenPrice();
orders[count1].ordertype=OrderType();
orders[count1].profit=OrderProfit();
orders[count1].stoploss=OrderStopLoss();
count1++;
}
}
right?