The task is to count losing buy/sell orders individually. Code:
int w = OrdersHistoryTotal()-1; if (OrderSelect(w, SELECT_BY_POS, MODE_HISTORY)) { if (OrderProfit() < 0) { if (OrderType()==OP_BUY) i = i + 1; if (OrderType()==OP_SELL) y = y + 1; Print("i, y", i, " ", y); Print("OrderProfit()", OrderProfit()); } }
The code itself is a snippet from an EA. The Expert Advisor is running and consistently generating losses. There are a lot of losing orders (I print them elsewhere), all of which are logged. But in this code fragment, the Expert Advisor does not enter the
The task is to count losing buy/sell orders individually. Code:
int w = OrdersHistoryTotal()-1; if (OrderSelect(w, SELECT_BY_POS, MODE_HISTORY)) { if (OrderProfit() < 0) { if (OrderType()==OP_BUY) i = i + 1; if (OrderType()==OP_SELL) y = y + 1; Print("i, y", i, " ", y); Print("OrderProfit()", OrderProfit()); } }
The code itself is a snippet from an EA. The EA is running and consistently generating losses. There are a bunch of losing orders (I print them elsewhere) all of which are logged. But in this code fragment, the Expert Advisor does not enter the
if (OrderProfit() < 0)
What am I doing wrong?
Try
int w = OrdersHistoryTotal();
int BUY=0;
int SELL=0;
for (i=0; i<w; i++)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
{
if (OrderProfit() < 0)
{
if (OrderType()==OP_BUY) BUY++;
if (OrderType()==OP_SELL) SELL++;
}
}
}
Print(" BUY = ",BUY);
Print(" SELL = ",SELL);
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.
I need it so that the EA can start calculating itself.
Help to understand:
The task is to count losing buy/sell orders individually. Code:
int w = OrdersHistoryTotal()-1;
if (OrderSelect(w, SELECT_BY_POS, MODE_HISTORY))
{
if (OrderProfit() < 0)
{
if (OrderType()==OP_BUY) i = i + 1;
if (OrderType()==OP_SELL) y = y + 1;
Print("i, y", i, " ", y);
Print("OrderProfit()", OrderProfit());
}
}
The code itself is a snippet from an EA. The Expert Advisor is running and consistently generating losses. There are a lot of losing orders (I print them elsewhere), all of which are logged. But in this code fragment, the Expert Advisor does not enter the
if (OrderProfit() < 0)
What am I doing wrong?
Do you have an EA that only opens positions? Each copy (version) should have its own magician and each will only monitor its own positions.
Got it. Thank you very much!
Help to understand:
The task is to count losing buy/sell orders individually. Code:
int w = OrdersHistoryTotal()-1;
if (OrderSelect(w, SELECT_BY_POS, MODE_HISTORY))
{
if (OrderProfit() < 0)
{
if (OrderType()==OP_BUY) i = i + 1;
if (OrderType()==OP_SELL) y = y + 1;
Print("i, y", i, " ", y);
Print("OrderProfit()", OrderProfit());
}
}
The code itself is a snippet from an EA. The EA is running and consistently generating losses. There are a bunch of losing orders (I print them elsewhere) all of which are logged. But in this code fragment, the Expert Advisor does not enter the
if (OrderProfit() < 0)
What am I doing wrong?
Try
I'm losing my mind, what's wrong with my mql4?
Why does the software perform the following condition on each cycle? It is written that the "i" should only be printed when a new order is closed!
w = OrdersHistoryTotal();
if (i!=w)
{
i = w;
Print ("i :", i);
}
I'm going crazy, what's wrong with my mql4?
Why does the program execute the following condition on each cycle? It is written to print "i" only when a new order is closed!
w = OrdersHistoryTotal();
if (i!=w)
{
i = w;
Print ("i :", i);
}
If i is not a static variable, it will be printed at every tick.
If i is not a static variable it will still print on every tick.
Ooh, I was wondering why I have several pieces in my program working through the ass! =)
So all working variables whose values I use in different ticks must be declared static?
Ooh, I was wondering why I've got a few pieces of software working through my butt! =)
So all the working variables whose values I use in different instants have to be declared static?
It's hard to say. Look at the properties of the variables, and then think about what to declare and how to do it.
The OrderModify() function doesn't allow comments to be changed. Is there any other way to do this?
The OrderModify() function doesn't allow comments to be changed. Is there any other way to do this?
Only from the terminal.