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

 
Alexandr Nikolaev:
So it turns out that OrderSelect by ticket from closed and deleted orders searches only among the history loaded into the terminal? There is no information about this in the handbook.

yes

In fact, the EA only has access to the data you can find in the terminal

This also applies to chart history, if you limit it, the EA will also not be able to access chart bars you cannot see in the terminal


Aleksey Mavrin:

In the description of OrdersHistoryTotal it says

When selecting an order by ticket:

The pool parameter is ignored

https://docs.mql4.com/ru/trading/orderselect
 
Can anyone tell me how to get the handle of the latest file in the folder without knowing its name. That is, when running the script you need to refer to the most recently created file, which I can't figure out what to put in the loop. MQL4
 
hoka777:
Can someone tell me how I can get the handle of the latest file in the folder without knowing its name. That is, when running the script I need to refer to the most recently created file, I can't figure out what to put in the loop. MQL4

FileFindFirst, FileFindNext, FileGetInteger

 

what does this entry mean?

int tf=0x0001|0x0002|0x0004|0x0008|0x0010|0x0020|0x0040;
 
Seric29:

what does this entry mean?

Equal to this:

int tf=1|2|4|8|16|32|64;

Someone is using flags somewhere for something. This entry says that there are 7 flags stored in the tf variable, and they are all raised.

 

Order tracking.

Hello all, Gentlemen of the forum.

Faced with the need to track orders for the copier and was surprised by the complexity of the issue.

Task.

To track opening, closing and modification of market and pending orders with the least possible delay and load on the system.

Possible solutions.

1. Monitoring the entire order list every tick is not very attractive yet.

2. MQL5 has good OnTrade() and OnTradeTransaction() functions, but I haven't found analogues in MQL4.

3. The Last order lines and their TP andSL manipulations on the chart seem to be quite attractive, using OnChartEvent, but these objects are not visible and are not handled by the function. Maybe there is a way to detect them?

4. Now I'm thinking about the possibility of getting information from the general log. You will have to monitor there too, but less.

I haven't found a satisfactory solution yet, maybe someone has already done some digging?

 
Artyom Trishkin:

Equal to this:

Someone somewhere is using flags for something. This entry says that there are 7 flags stored in the variable tf, and they are all raised.

int tf=1|2|4|8|16|32|64;

And why are they written through a vertical stick how to use this? Can each part of this flag be accessed? Here's a code like this.

    if(_Period==1440){diff=86399; tf=0x0001|0x0002|0x0004|0x0008|0x0010|0x0020|0x0040;}// выбор старшего ТФ, с него скрипт рисует на младших ТФ
    if(_Period==240) {diff=14340; tf=0x0001|0x0002|0x0004|0x0008|0x0010|0x0020;}
    if(_Period==60)  {diff=3540;  tf=0x0001|0x0002|0x0004|0x0008|0x0010;}
    if(_Period==30)  {diff=1740;  tf=0x0001|0x0002|0x0004|0x0008;}
    if(_Period==15)  {diff=840;   tf=0x0001|0x0002|0x0004;}
    if(_Period==5)   {diff=240;   tf=0x0001|0x0002;}  

    cl_timeM1=op_timeM1 + diff ;                    // координата даты и времени бара М1 по цене CLOSE старшего ТФ
    cl_NumBarM1=iBarShift(NULL,PERIOD_M1,cl_timeM1);// индекс бара М1
    cl_priceM1=iClose(NULL,PERIOD_M1,cl_NumBarM1);  // координата цены CLOSE бара М1
      
//--- трендовые линии -----------------------------------------------+ 
   for(i=0;i<1000000;i++){name1="Point_"+i; if(ObjectFind(name1)<0) break;}     // позволяет рисовать множество объектов с одинаковым именем, добавляя к имени порядковый номер
  
   ObjectCreate(0,name1,OBJ_TREND,0,op_timeM1,op_priceM1,cl_timeM1,cl_priceM1); // создать объект трендовая линия с координатами цены и времени  
   ObjectSet(name1,OBJPROP_COLOR,clrWhite);                                     // задать цвет объекта
   ObjectSet(name1,OBJPROP_STYLE,STYLE_DASH);                                   // задать стиль объекта (пунктир, линия...)
   ObjectSet(name1,OBJPROP_RAY,false);
   Строчка ниже будет отрисовываться нужное количество раз или что?
   ObjectSet(name1,OBJPROP_TIMEFRAMES,tf);    
 
Seric29:

And why are they written through a vertical stick how to use it?

as long as you call it a "vertical stick", you cannot read this code

read the helphttps://www.mql5.com/ru/docs/basis/operations/bit

 
Igor Makanu:

as long as you call it a "vertical stick" you will not be able to read this code

read the helphttps://www.mql5.com/ru/docs/basis/operations/bit

I read it (I don't know for how many times now) and understand it poorly because there are no examples of its use and it's not clear what it's for. There is an example

int a=305;
int b=a;      
int shift=37; 
shift++; 
a=a>>shift;   // 38 в двоичном представлении будет выглядеть как '100110', младшие 5 бит '00110' представляют число 6 
b=b>>6;

Is there any way to make this line

if(_Period==1440){diff=86399; tf=0x0001|0x0002|0x0004|0x0008|0x0010|0x0020|0x0040;}

can it be written shorter through the counter?

 
Seric29:

I've read it (I don't know how many times) and understand it poorly because there are no examples of how to use it and it's not clear what it's for. There is an example.

You have read the wrong example

Bitwise OR operation

Bitwise OR of binary representations of x and y. The value of the expression contains 1 in all places where x or y does not contain 0, and 0 in all other places.

b = x | y;

Example:

 char a='a',b='b';
//--- операция ИЛИ
   char c=a|b;
   Print("a = ",a,"  b = ",b);
   Print("a | b = ",c);
// Результат будет такой:
// a = 97   b = 98
// a | b = 99