[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 177

 
badbadboy:

I need it so that the EA can start calculating itself.
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.
 

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?

 
borilunad:
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!
 
belozad:

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

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);       
 

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);
   }

 
belozad:

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.
 
badbadboy:

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?

 
belozad:

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?

 
pasha5282:

The OrderModify() function doesn't allow comments to be changed. Is there any other way to do this?


Only from the terminal.
Reason: