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

 
MikeM:
It is possible to remember the previous value of sig1and only open an order when the current value is permissive and the previous value was prohibitive.
I don't get it.
 
Top2n:
I don't get it.

Get to know the flags.
 
which countries) Please write down what the flags are. What are the keys to enter in the search engine and find out.
 
If you mean false true, I don't see how you can open just one order at a time.
 
Can you tell me how an EA opens a grid of orders? I have written a function which detects the order with the highest price and the lowest one. But I also need information about the second order with the lowest price or the highest.
 
Top2n:
If you mean false true, then I do not understand how it is possible to open exactly one order.
Why not check "is there already an open position of the type that should be opened by the signal?
If it already exists, then don't open it.

If there is no position of this type in the market, then open it.

Well, along with this check, some other conditions can be checked. For example: if there is already such a position, but a given amount of time has passed after it was opened, another position can be opened... etc. etc. ...

 
DimaMA:
Can you tell me how an EA opens a grid of orders? I have written a function which determines the order with the highest price and the lowest one. But I need more information about the second order with the lowest price or the highest. Here in general the 2nd and not the last. tell me the function.

Cycle through all the orders and store them in a two-dimensional array. In the first dimension of the array, record the time the order was placed, and in the second dimension, record its ticket. Sort the array by the order placing date (by the first dimension) in descending order. The second element of the array in the first dimension will contain the date of installation of the penultimate order (the second from the end), and the second dimension will contain the ticket of the necessary order. You select the order by this ticket and... You may do whatever you want with it.


Once I wrote a function for calculating Breakeven for the N-th amount of last positions for a custom EA. The calculation should be done for the last several positions, starting from the penultimate one. You may look how it is implemented and get something out of it:

//+----------------------------------------------------------------------------+
// Уровень безубытка по символу для N последних позиций, начиная с предпоследней
double LevelPreWLforNpos(int op, int mn1, int mn2, int num) { 
   double lots=0;
   double sum=0;
   int n=0;
   int mass[1][2];
   ArrayInitialize(mass,0);
   for (int i=0; i<OrdersTotal(); i++) {
      if (OrderSelect(i,SELECT_BY_POS)) {
         if (OrderSymbol()!=sy)  continue;
         if (OrderType()!=op)    continue;
         if (OrderMagicNumber()==mn1 || (OrderMagicNumber()==mn2 || OrderMagicNumber()<0)) {
            n++;
            if (n>ArrayRange(mass,0)) ArrayResize(mass, n);
            mass[n-1][0]=OrderOpenTime();
            mass[n-1][1]=OrderTicket();
            }
         }
      }
   ArraySort(mass,WHOLE_ARRAY,0,MODE_DESCEND);
   if (ArrayRange(mass,0)>num+1)  ArrayResize(mass,num+1);
   for (i=1; i<ArrayRange(mass,0); i++) {
      if (OrderSelect(mass[i][1],SELECT_BY_TICKET)) {
         if (OrderCloseTime()==0) {
            if (OrderType()==OP_BUY) {
               lots+=OrderLots();
               sum+=OrderLots()*OrderOpenPrice();
               }
            if (OrderType()==OP_SELL) {
               lots-=OrderLots();
               sum-=OrderLots()*OrderOpenPrice();
               }
            }
         }
      }   
   double price=0;
   if (lots!=0) price=sum/lots;  
   return(NormalizeDouble(price,dg));
}
//+----------------------------------------------------------------------------+
 
Top2n:
If you mean false true, I don't see how you can open just one order at a time.


Yeah. That's what I mean. See the tutorial here. You will have some more conditions, as you write: "Attention question!) And how to make it open once for (sig1) it may be so sig1-open BAY, the next command, sig0-admit inclusion. trall (not important), the next command again, sig1-open second BAY." - is it not a lot of times? It seems that you do not need it ... In general, play with flags.

 
Roman.:


Yes. I mean them. See the tutorial here. You will have some more conditions, as you write: "Attention question!) And how to make it open once for (sig1) while it may be so sig1-open BAY, the next command, sig0-admit on. trawl (it does not matter), the next command again, sig1-open second BAY" - is not it many times? It seems that you do not need it ... In general, play with flags.

Has Kimi got a suitable function, by any chance? So as not to clutter up the program. It is necessary that he opened the order and calm down, but "one thousand" in one second.
 
Top2n:
Does Kim I.V. happen to have a suitable function? So as not to clutter up the program. I want him to open an order and relax, because he "opens a thousand" in one second.
Take your pick.
Reason: