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

 
makssub #:

Write an example, because I'm already a bit confused. If it's not too much trouble. Thanks

In the loop to search for orders:

if (OrderOpenPrice()<previous_value)
   {
   previous_value=OrderOpenPrice();
   nearest_order=OrderTicket();
   }

Before the loop, initialize previous_value=DBL_MAX a nearest_order=0

 
Taras Slobodyanik #:

in the order loop:

initialise previous_value=DBL_MAX a nearest_order=0 before the loop

Exactly. Thank you. Works

 
Taras Slobodyanik #:

in the order loop:

initialise previous_value=DBL_MAX a nearest_order=0 before the loop

DBL_MAX is categorical).
 
Valeriy Yastremskiy #:
DBL_MAX is categorical).

The main thing works)

How to find OP_BUY with maximum OrderOpenPrice and determine its OrderProfit.
I can't put them together, everything works through the ass... If you can give me an example right away) Thank you)

 
makssub #:

The main thing works)

How to find OP_BUY with maximum OrderOpenPrice and determine its OrderProfit.
I can't put them together, everything works through the ass... If you can give me an example right away) Thank you)

previous_value=0;

if (OrderOpenPrice()>previous_value)
   {
   previous_value=OrderOpenPrice();
   profit_order=OrderProfit();
   }
 
MakarFX #:

I just wanted to say that I'm all done.

But you have made it more compact. I'll take your suggestion.)

Thanks

 
How to work with a file in mql5 program without writing the file to disk, but to work only in RAM, to speed up. I want to transfer data from an mql5 program to a program on my computer. Is it possible to do it without network functions? It doesn't have to be a file, an array or a variable; it's even better. I only know two ways, python integration module and web socket, is there any other way?
 

I delete all objects in OnDeInit() by loop (arrows indicating signal bars and one button):

const int obj_total=ObjectsTotal();

Print("ObjectsTotal ",obj_total);

for(int i=0 ; i < obj_total ; i++){
 Print("ObjectName ",ObjectName(i),", i = ",i);
 ObjectDelete(ObjectName(i));
}

I am aware that there is ObjectsDeleteAll(), but still if I do it through a loop, only half of the objects are deleted in one. Actually here is the work of the loop and I don't understand why it happens so:

2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName , i = 20
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName , i = 19
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName , i = 18
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName , i = 17
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName , i = 16
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName , i = 15
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName , i = 14
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName , i = 13
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName , i = 12
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName , i = 11
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName button1, i = 10
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName ArrowUp0008, i = 9
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName ArrowUp0006, i = 8
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName ArrowUp0004, i = 7
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName ArrowUp0002, i = 6
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName ArrowUp0000, i = 5
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName ArrowDown0008, i = 4
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName ArrowDown0006, i = 3
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName ArrowDown0004, i = 2
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName ArrowDown0002, i = 1
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectName ArrowDown0000, i = 0
2021.09.30 04:47:30.462    2021.01.04 03:56:45  test EURUSD,M1: ObjectsTotal 21
 
Nerd Trader #:

I delete all objects in OnDeInit() by loop (arrows indicating signal bars and one button):

I am aware that there is ObjectsDeleteAll(), but still if I do it through a loop, only half of the objects are deleted in one. Actually here is how the loop works and I don't understand why it happens this way:

The loop when deleting should be reversed:

for(int i=obj_total-1; i>=0; i--)

and this applies not only to deleting graphical objects, but in general to deleting any objects in the lists of the terminal.

 
Nerd Trader #:

I delete all objects in OnDeInit() by loop (arrows indicating signal bars and one button):

I am aware that there is ObjectsDeleteAll(), but still if I do it through a loop, only half of the objects are deleted in one. Actually here is how the loop works and I don't understand why it happens:

but if you try it this way - only you need to put all the names

string   m_name[]= {"button1","ArrowUp0008","ArrowDown0008","ArrowUp0006","ArrowDown0006"};
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   for(int i=0; i<ArraySize(m_name); i++)
     {
      ObjectDelete(0,m_name[i]);
     }
//---
  }
//+------------------------------------------------------------------+
Reason: