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

 
Igor Zakharov:

This is not a replacement - MB does not work in indicators as it stops the flow until the button is pressed!

I inadvertently advised this, but that's not what the note says at all:

Note

This function is not recommended to use in custom indicators, as the call of MessageBox() stops the execution of indicator thread for the entire time of waiting for user's answer. And since all of the indicators for each symbol are executed in a single thread, all of the charts for all timeframes for this symbol will be stopped.

When working in the strategy tester, the MessageBox() function is not executed.

 
MakarFX:

I am not a programmer, I edit the indicator for my own convenience. I didn't check it in the tester, but in real time.

By the way, there are no telepaths.

If you know which of the indicators available here use this function, please tell me, maybe then I will figure it out myself.

Thanks

We have everything.

Клуб Телепатов
Клуб Телепатов
  • 2011.05.08
  • www.mql5.com
Клуб телепатов Вас послали сюда? Тогда давайте знакомиться! Как же такое могло случиться со мной...
 
Artyom Trishkin:

You declare a variable with the structure type in the local scope, and it is what you send to the function. In the same local scope.

The point is that when you create a variable for a structure in the field its scope is on the whole fonction and not on a local area. Here is an example.

int OnInit()
  {
{int In=8;
 MyPoint qr;}
qr - видна здесь
In - здесь не видна
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason){}

struct MyPoint
{
    int x[5];
    int y;
};

It turns out that it is no longer possible to work locally.

 

Trying to read data from a csv file in a script. No luck and I don't understand why at all.

I use a simple procedure to read it:

bool GetBiFromFile(string InFNam,int& alBars,double& xClose[],datetime& xTime[])
{  int  InHndl,nBars;
   bool fset;
   double aval;
   
   InHndl = FileOpen(InFNam+".csv",FILE_READ|FILE_CSV,",");
   if (InHndl==INVALID_HANDLE) {
       Print("File "+InFNam+" does not open. Error: ", GetLastError()); 
       return(false); 
   } else {
      fset = FileSeek(InHndl,0,SEEK_SET);
      ArrayResize(xClose,alBars);      
      ArrayInitialize(xClose,0.0);  
      ArrayResize(xTime,alBars);       
      ArrayInitialize(xTime,0);  
      nBars = 0;
      while (!FileIsEnding(InHndl)) {
         nBars++;
         xTime[nBars-1]  = FileReadDatetime(InHndl);;
         xClose[nBars-1] = FileReadDouble(InHndl);
         aval = FileReadDouble(InHndl);
         if (nBars>=alBars) break;
      }
   }
   Print("nBars = ",nBars,"   allBars = ",alBars);
   Print("Start: ",xClose[0],"   " + TimeToString(xTime[0],TIME_DATE|TIME_SECONDS));
   Print("End: ",xClose[nBars-1],"   " + TimeToString(xTime[nBars-1],TIME_DATE|TIME_SECONDS));
   return(true);
}

The file with the data has the following form:

2012.01.02 02:00:02,1.293240,1.293410

2012.01.02 02:00:52,1.293330,1.293500

2012.01.02 02:00:55,1.293810,1.293980

....

And the result of the Print() statements from the procedure is

nBars = 1000 alBars = 1000

Start: 0.0 2020.01.29 01:00:00

End: 0.0 2020.01.29 01:00:00

That is, all the lines are processed in the read loop, but nothing is read. And no error message.

Can someone explain this to me ?


 
Yurixx:

Can someone explain this to me ?

Binary functions read a text file.

 
Alexey Viktorov:

We have everything.

You're mean!

 
MakarFX:

You're mean!

I'm pretending.

If you want to understand programming, start trying to figure it out. If you just need to do it, go to the thread where they offer to write it for free, post your indicator there and describe your request.


ps: I checked everything. Alert() for some reason even if placed before PlaySound() does not play the selected sound. Maybe my memory is bad, but not the point.

You can mute Alert() by double-tapping it to get a red cross


and in that case it won't matter what Alert() or PlaySound() is written in front of it

 
Alexey Viktorov:

I'm pretending.


and in this case it makes no difference whether it says Alert() or PlaySound() in front

In this case, the alert window does not open.(

 
fxsaber:

You read a text file with binary functions.

It does say aboutFileReadDouble() function that it reads from a binary file.

But it says aboutFileReadDatetime(): "Reads from CSV file a string of one of formats: "YYYY.MM.DD HH:MI:SS", "YYYY.MM.DD" or "HH:MI:SS" - and converts it to datetime value".

Also, the same picture was when I usedFileReadString() and then converted the strings to the correcttype myself.

How do you think I should do it ?


 
Yurixx:

How do you think it should be done ?

void OnStart()
{
  datetime time;
  
  double PriceBid;
  double PriceAsk;
  
  string Str = "2012.01.02 02:00:02,1.293240,1.293410";
  string StrArray[];
  
  if (StringSplit(Str, ',', StrArray) > 2)
  {
    time = (datetime)StrArray[0];
    
    PriceBid = (double)StrArray[1];
    PriceAsk = (double)StrArray[2];
  }
}
Reason: