Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1497

 
I wonder if a graphical text object could be placed, for example, on the sidebar of a subwindow with a WPR graph?
 
maxvoronin74 #:
I wonder if a graphical text object can be placed, for example, on the side scale of a subwindow with a WPR graph?

No, it will not work on the scale. You can place it in the indicator window very close to the scale, but not on the scale itself.

 
Aleksandr Slavskii #:

No, you can't do it on the scale. It is possible in the indicator window very close to the scale, but not on the scale itself.

Got it, thanks.
 

I've tried several times to figure out how debugging works, but after several failed attempts I gave up on the idea. Trying to figure it out again, so will need some help. For example, in the attached picture below I have created a simple code to view Expressions and Values while debugging, but I can't see them, but the documentation shows Expressions and Values. What is the problem?


Отладка кода - Разработка программ - Справка по MetaEditor
  • www.metatrader5.com
В MetaEditor встроен отладчик — инструмент, который позволяет проверить работу программы по шагам (по отдельным функциям). Вы расставляете в коде...
 

Nauris Zukas #:

... but I can't see them...

In order to see something, you need to add something to the observation using the Shift+F9 keyboard shortcut. Steps to view each line of code are made by pressing the F11 key.

Regards, Vladimir.

 
Nauris Zukas #:

I've tried several times to figure out how debugging works, but after several failed attempts I gave up on the idea. Trying to figure it out again, so will need some help. For example, in the attached picture below I have created a simple code to view Expressions and Values while debugging, but I can't see them, but the documentation shows Expressions and Values. What is the problem?


Be sure to figure it out, very useful stuff!
 
Look it up on YouTube.
I think it's Alexei Volchansky.
 

Thanks!!! I spent half a day working with the debugger and realised why I don't use it every day - it takes too much time, I find it easier to just put Print in a function to get information quickly.

But I started this because I wanted to understand why all array elements are assigned 0 at once. It's already a number in nature and that can lead to a wrong result later on. How would you proceed? Is ArrayInitialise(arr1,EMPTY_VALUE) the best solution or something else?


 
Nauris Zukas #:

But I started this because I wanted to understand why all array elements are assigned 0 at once. This is already a number in nature and that can lead to incorrect results later on. How would you proceed? Is ArrayInitialise(arr1,EMPTY_VALUE) the best solution or something else?

Arrays are not assigned values of zeros. You just got lucky, let's say randomly.

If you don't initialise an array, it often contains rubbish.

In your screen where you indicate that there is an incorrect value instead of zero it could be any number.

 
Hello, please advise.

Saving data to a file.
void OrderExport(MqlTradeRequest &request)
  {
   static long trans = 0;
   static long keepTrans = 0;
   string file = "OrderExchange" + (request.magic > 0 ? IntegerToString(request.magic) : "") + ".csv";
   int handle = FileOpen(file, FILE_CSV | FILE_READ | FILE_SHARE_READ | FILE_WRITE | FILE_SHARE_WRITE | (Common ? FILE_COMMON : 0), ';');
   if(handle != INVALID_HANDLE)
     {
      FileSeek(handle, 0, SEEK_END);
      long tr = TimeGMT();
      trans = (tr > trans) ? tr : (trans + 1);
      FileWrite(handle,
                trans,
                request.action,
                request.magic,

Getting data from the file

void OrderImport(MqlTradeRequest &aReq[], int magic, string symbol)
  {
   ArrayFree(aReq);
   long tr;
   static long trans = 0;
   if(trans == 0)
      trans = TimeGMT() - 3;
   string file = "OrderExchange" + (magic > 0 ? IntegerToString(magic) : "") + ".csv";
   int handle = FileOpen(file, FILE_TXT | FILE_READ | FILE_SHARE_READ | FILE_ANSI | (Common ? FILE_COMMON : 0));
   if(handle != INVALID_HANDLE)
     {
      FileSeek(handle, 0, SEEK_SET);
      while(!FileIsEnding(handle))
        {
         string s = FileReadString(handle);
         string aS[];
         int cnt = StringSplit(s, ';', aS);
         if(cnt <= 0)
            continue;
         //---   ПРОБЛЕМНОЕ МЕСТО ОТ
          tr = StringToInteger(aS[0]);
         //---    ПРОБЛЕМНОЕ МЕСТО ДО
         if(tr <= trans)
            continue;

GetLastError() Error is given that -Spoiltstring type parameter

If you output the aS[0] array via Print(), the font is different from the rest.


If you just print the parameter tr , then = 0

Reason: