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

 
hoz:

I have something on a simple point, a headache. There is a function to search for orders.

t - counter of all orders.

p - counter of pending orders.

I call it from the start:

In fact, when we open it, even when there are no orders, we see this (even when there are no orders, it prints as if there are...):

How is this possible?


There you go...
if (OrderType() > 1)
      {
          p++;
      }
      t++;
Что у нас тут? Если тип ордера больше OP_SELL, то увеличиваем p

Did you ever think that the type of order could also be more than five? Specifically six. This is a non-trading change in the deposit.

 
artmedia70:
There you go...

Did you ever think that the type of order could also be more than five? Specifically six. This is a non-trading change in the deposit.



No. That's the first I've heard of it. Where does it say that?
 
FAQ:
deposit = type 6

Hmm. Order type = deposit!? What is that?
 
artmedia70:
There you go...

Did you ever think that the type of order could also be more than five? Specifically six. This is a non-trading change in the deposit.



And why 6, because the size or number of orders can be set independently in the Expert Advisor.
 
hoz:

Hmm. Order type = deposit!? What is this?

all withdrawals and deposits go under this number
 
Profitov:

And why 6, because the size or number of orders can be written into the EA.

What are we talking about? We are not talking about the number of orders, but about the type of order. So: an order of type 6 is a non-trading modification of the deposit.
 
hoz:

No. That's the first I've heard of it. Where does it say that?

This is undocumented data.
 
FAQ:

All withdrawals and deposits go under that number.


Hmm. And how can this number affect the collection of order statistics?

artmedia70:

This is undocumented data.

That's great! The most interesting thing is that someone knows about it, oddly enough. How could anyone have guessed that?

artmedia70:

What are we talking about? It's not about the number of orders, it's about the type of order. So: an order of type 6 is a non-trading change of deposit.

If an owl is tested in the demo, how can this order be accounted for? I.e. the balance, which is initially given on the demo - it will be that... the sought-after ONE? And in the real - this is what we have withdrawn and deposited, right?

 
Sepulca:

This should work, I haven't tested it myself, as the terminal is busy optimizing another EA so far

Hello!

I have tried to paste your code into the template from the tutorial. I have to open only one position but the template has only one position.

The ticket variable has another name, as the template already has one and made it static, so the criterion for withdrawal would receive data from it, if the position remains on the next day.

Everything is good, but a looping problem has appeared. For example, in the Strategy Tester, the Expert Advisor exits a position at Take Profit or close sell and the criterion of entering is still active, so it turns out that the Expert Advisor constantly opens and closes a position.

This problem was solved by adding a static datetime variable t earlier but now

 if(Maximum>0 && Flag) {
   signal = Maximum - Bid;    
   if (signal > 0.005 ) { // к примеру если ниже максимума на 12 пунктов, в этом случае откроем SELL 
      Opn_S = true;
      tickett= Opn_S; 
      t=Time[0];  
      if(tickett>=0) Flag=false;// Ордер открылся, сегодня больше не открываем.       
   }  
}
 
if(tickett>=0) 
    {
double stop = iHigh(Symbol(),Period(),0) - iHigh(Symbol(),Period(),1);
if (stop > 0.0012)
     {
       if (Time[0]>t)
            {
             Cls_S=true;   
             tickett=-1;          
            }
      }
     }

sell stops working.

It works but it loops:

#define magic 123456789
StartHour=14;
StartMinute=1;// Время 08:01
StopHour=16;
StopMinute=30; // Время 23:58
StartTime=StartHour*60+StartMinute;
StopTime=StopHour*60+StopMinute;
static int tickett=-1;
static double Maximum=-1;
static datetime t;
if(StopTime<=StartTime) {Print("ERROR: Неправильные времена"); return(0);}
 CurrentMinutesFromDayStart=Hour()*60+Minute();// Текущее время в минутах от начала дня
 datetime td=iTime(Symbol(),PERIOD_D1,0);// Время открытия дневного бара в секундах от 01.01.1970
 if(CurrentMinutesFromDayStart<StartTime) {Maximum=-1;Flag=true;}// Если StartTime еще не настало, то после StopTime нужно пересчитать Maximum и можно открывать ордер
if(CurrentMinutesFromDayStart>StopTime && Maximum<0) {// если максимум ещё не посчитан
  datetime ts=td+StartTime*60;// начало временного диапазона в секундах от 01.01.1970
  start= iBarShift(Symbol(),PERIOD_M1,ts,false);// смещение бара, которому принадлежит ts
  ts=td+StopTime*60;// конец временного диапазона в секундах от 01.01.1970
  count= iBarShift(Symbol(),PERIOD_M1,ts,false);// смещение бара, которому принадлежит ts
  count=start-count;// Сколко баров длится временной интервал
  Maximum=iHigh(Symbol(),PERIOD_M1,iHighest(Symbol(),PERIOD_M1,MODE_HIGH,count,start));//Находим максимум на заданном временном интервале
 }
 if(Maximum>0 && Flag) {
   signal = Maximum - Bid;    
   if (signal > 0.005 ) { // к примеру если ниже максимума на 12 пунктов, в этом случае откроем SELL 
      Opn_S = true;
      tickett= Opn_S;   
      if(tickett>=0) Flag=false;// Ордер открылся, сегодня больше не открываем.       
   }  
}
 
if(tickett>=0) 
    {
double stop = iHigh(Symbol(),Period(),0) - iHigh(Symbol(),Period(),1);
if (stop > 0.0012)
            {
             Cls_S=true;   
             tickett=-1;          
            }
      }

What may be the problem? I tried everything I could think of, but I am not so good at mql .

I am attaching the Expert Advisor, it is not possible to place all the text.

Files:
svhrvrsa.mq4  14 kb
 
hoz:


Hmm. And how this number may influence the collection of order statistics?


That's great! The most interesting thing is that someone knows about it, oddly enough. How could anyone have guessed that?


If an owl is tested in the demo, how can this order be accounted for? I.e. the balance, which is initially given on the demo - it will be that... the sought-after ONE? And what we have in the real market is what we have withdrawn and deposited, right?

Perhaps, it is possible to prescribe somehow the withdrawal of part of the deposit, when one closes with a good profit, or the filling when one has hit the loss. I must look it up, maybe there is such a thing, eh?

Reason: