Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 68

 
ALWAYS RECALCULATE ALL OBJECTS.
 

OK.


Rustam, Artyom - Thank you very much!

 

Can you help?:)EA needs to finish, I myself sitting examining, and do not get to finish, in fact, maybe a very good EA will turn out, about a year more than a little, the strategy goes without failure, but lately less signals went, if before 22 trades a month of them 2 loss-making, 2-3 lossless, now about 16-18 deals of them 2-3 loss-making, and 2 lossless, in fact, the adviser is almost working, but nirvozhno entered two induks in collaboration, this AC and JSC well strategy, I think they know:) I have a stupid AC1>AC2 AO1>AO2 prescribed in my EA, which is fundamentally stupid:)

Who can help write in person please

 
Hello! Please advise how to write a correct condition like:if(Among all open orders there is no order with a magician==magic)Thank you in advance...already my brain is just boiling...
 
niktron:
Hello! Please advise how to write a correct condition like:if(Among all open orders there is no order with a magician==magic)Thank you in advance...already my brain is just boiling...

int ExampleMagic = 65536;
if (!PrsntMgc(ExampleMagic)) {
   // Your code here ...
}

bool PrsntMgc(int MgcNum) {
   for (int i = OrdersTotal()-1; i >= 0; i--) {
      OrderSelect(i, SELECT_BY_POS);     
      if(OrderMagicNumber() == MgcNum) 
         return true;
   }
   return false;
}
 
Chiripaha:

2. I need to. I need to view 2 types of objects: horizontal lines and trend lines. The other objects are not relevant in this enumeration.

If I understand correctly, are the opinions divided? or does the answer about "firsts" not contradict the previous statement?

No, they are not. I glanced at your code and answered "without looking". Your line:

for(int i=ObjectsTotal(OBJ_HLINE)-1; i>=0; i--) 

- assigns to the loop index i a value equal to the total number of horizontal lines. If you have 3 of them, the loop will be from 2 to 0. And it is unclear what is in your loop, but there will be only three iterations from 2 to 0.

 
niktron:
Hello, Could you please tell me how to write a correct condition like:if(Among all open orders there is no order with magic==magic)Thanks in advance...already my brain is just boiling...

Right:

//+----------------------------------------------------------------------------+
int Magic=12345679;
//+----------------------------------------------------------------------------+
int start() {
   if (!ExistOrdersByTypeWithMagic(Symbol(), OP_BUY, Magic)) {
      Print("Нет открытых позиций Buy с магиком "+Magic);
      }
   else Print("Позиция Buy с магиком "+Magic+" существует однако...");
   if (!ExistOrdersByTypeWithMagic(Symbol(), OP_SELLLIMIT, Magic)) {
      Print("Нет установленных ордеров SellLimit с магиком "+Magic);
      }
   else Print("Висит где-то лимитничек Sell с магиком "+Magic);
   
   // e.t.c.
   
   return(0);
}
//+----------------------------------------------------------------------------+
bool ExistOrdersByTypeWithMagic(string sy, int op, int mn) {
   int i, k=OrdersTotal()-1;
   for (i=k; i>=0; i--) {
      if (OrderSelect(i, SELECT_BY_POS)) {
         if (OrderSymbol()!=sy)  continue;
         if (OrderType()!=op)    continue;
         if (OrderMagicNumber()==mn) return(true);
         }
      }
   return(false);
}
//+----------------------------------------------------------------------------+

The ExistOrdersByTypeWithMagic() function searches for a given type of order/position by a given symbol with Magic and returns true if there is one and false if there is none

 
r772ra:

Here

Thanks again!
 
What is the maximum number of elements in an array?
 
MauzerVII:
Can you tell me what is the maximum number of elements in an array?
Determined by the free memory available to the process.
Reason: