Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1216

 
Valeriy Yastremskiy:

Flags either control the number of order types or if there is a ticket control the closing time of the market order, if not equal to zero then the order has closed and the order opening flag is false.

And programmatically how ?
 
AIGUL SALMANOVA:
How is this done programmatically ???
 if(OrderSelect(Ticket, SELECT_BY_TICKET)==true)
        {
         if(OrderCloseTime()==0)              // Если наш рыночный ордер не закрыт
           {
            if(flagAlert == true)
               Alert("Наш рыночный ордер жив, Модифицируем его если нужно ", Text,Ticket,". Ждём ответ..");

            ModifyTral(); // Модифицируем если нужно
           }
         if(OrderCloseTime()!=0)              // Если наш рыночный ордер закрылся
           {
            OpnOr=false;                     // Флаг открытия рыночного ордера после его закрытия делаем ЛОЖЬ
            Ticket=0;                          // Тикет ордера рыночного, он может быть только один
           
            Alert("Наш рыночный ордер закрылся. Работа Советника продолжается ","Прибыль/убыток = ",OrderProfit(),
                  " Своп = ", OrderSwap(), " Комиссия = ", OrderCommission());
            return;
           }
        }
      else
        { Alert("OrderSelect() нашего рыночного ордера вернул ошибку - ",GetLastError()); return;}
     }

To account for a ticket.

When opening an order, the ticket must be memorised.

 Alert("Попытка открыть Buy Ожидание ответа..","SL = ",SL,"TP = ",TP,"Lts = ",Lts);
            Ticket=OrderSend(Symb,OP_BUY,Lts,Ask,slippage,SL,TP,"QstrBuy",Magic,0,Blue);//Открытие Buy
            if(Ticket>0) // Получилось :)
              {
               Alert(Symbol(),"Открыт ордер Buy по цене ",Ask,"Ticket = ",Ticket);}
 
Valeriy Yastremskiy:

To be honest, it's not clear what you're looking for. Write in formulas how you understand what is output and what you need.

You need the time in milliseconds between the last 4 ticks. Update values when new tick appears.

The indicator writes the time of the last tick(GetTickCount()) in the buffer.

The Expert Advisor takes values from the indicator and calculates the time difference.

double buf1=iCustom(Symbol(),0,"time",0,1);
double buf2=iCustom(Symbol(),0,"time",0,2);
double buf3=iCustom(Symbol(),0,"time",0,3);
double buf4=iCustom(Symbol(),0,"time",0,4);
double delta1=buf1-buf2;
double delta2=buf2-buf3;
double delta3=buf3-buf4;
Alert(delta1,"   ",delta2,"   ",delta3);

It seems to count, but Alert shows values as in the image.

I don't understand why.


 
prom18:

Need the time in milliseconds between the last 4 ticks. Updates the values when a new tick occurs.

The indicator writes the time of the last tick (GetTickCount()) into the buffer.

The Expert Advisor takes values from the indicator and calculates the time difference.

It seems to count, but Alert shows values as in the image.

I do not understand why.


Because you haven't read the documentation

Help for GetTickCount says it's an integer counter overflow

 
Maxim Kuznetsov:

because you don't read the documentation.

The GetTickCount reference says it's an integer overflow.

You mean uint? Why is it popping up in the alert? I didn't put it there.

 
prom18:

You mean uint? Why is it popping up in the alert? I didn't write it there.

In the first Alerte you output incorrectly (without taking into account overflows) calculated difference,

the second Alert, where a large integer value is looked for in the code, it is not present in this fragment :-)

 

That's the thing, it's not in the code.

All the indicator code.

#property  indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Aqua
double x[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(1);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,x);
   SetIndexDrawBegin(0,0);
   SetIndexLabel(0,"x");
   SetIndexShift(0,0);
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   uint b=GetTickCount();
   x[0]=b;
   Alert(b);
   for(int j=ArraySize(x)-1;j>=1;j--){x[j]=x[j-1];}
   return(0);
  }
//+------------------------------------------------------------------+

All of the EA code.

#property copyright ""
#property link      ""
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- 
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- 
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   uint buf1=iCustom(Symbol(),0,"time",0,1);
   uint buf2=iCustom(Symbol(),0,"time",0,2);
   uint buf3=iCustom(Symbol(),0,"time",0,3);
   uint buf4=iCustom(Symbol(),0,"time",0,4);
   uint delta1=buf1-buf2;
   uint delta2=buf2-buf3;
   uint delta3=buf3-buf4;
   Alert(delta1,"   ",delta2,"   ",delta3);  
  }
//+------------------------------------------------------------------+
Документация по MQL5: Константы, перечисления и структуры / Именованные константы / Предопределенные макроподстановки
Документация по MQL5: Константы, перечисления и структуры / Именованные константы / Предопределенные макроподстановки
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...
 
prom18:

That's the thing, it's not in the code.

All of the indicator code.

All of it.

Look what else is in it.

time.mq4 - maybe it sends alerts

 
prom18:

That's the thing, it's not in the code.

All the indicator code.

All of the EA code.

In the indicator, in the Alert structure. The 5th line from the bottomAlert(b);

uint b=GetTickCount();
   x[0]=b;
   Alert(b);

Apparently this is the number of milliseconds since the start of the system)

 

How do I track the status of the quick trade buttons?

That is, are they present on the chart or not.

Can you suggest a function or another method?