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

 
Oleg:

Colleagues, please advise why the sound stops playing when the desired volume of the candle.

The sound file is in the SOUNDS folder, when I set the alert the file is playing normally, but there is no sound in the indicator.

Or, do you need a special folder with sounds for indicators?


/---- The main loop of indicator calculation

for(bar=limit; bar>=0 && !IsStopped(); bar--)
{
Range=(high[bar]-low[bar])/_Point;
IndBuffer[bar]=Range;

if(Range<5)
{
if (prev_calculated > 0 && Flag==0)
{
Flag=1;
}
}
if(Range>=Threshold){
clr=0;
if (prev_calculated > 0 && Flag==1 )
{
Flag=0;

PlaySound("zummer");


}
}

for(bar=limit; bar>=0 && !IsStopped(); bar--)
{
  Range=(high[bar]-low[bar])/_Point;
  IndBuffer[bar]=Range;

  if(Range<5)
  {
    if (prev_calculated > 0 && Flag==0)
    {
      Flag=1;
    }
  }

  if(Range>=Threshold) {
    clr=0;
    if (prev_calculated > 0 && Flag==1 )
    {
      Flag=0;
      ResetLastError();
      PlaySound("zummer");
      Print(__FUNCTION__, " Error #", GetLastError());
    }
  }
}



And post here what error it gives out.

 
Иван:
Hello. Question: How does the tester calculate the results for closed positions in MT4 when working with crosses (pairs without $) in the tester, if the account where the testing is done is a dollar account? For the recalculation of position totals in dollars, does the tester take the exchange rate of the base currency of the cross to the dollar at the current moment or at the moment of the tested interval? I strongly suspect that it is at the current time. If so, is it not possible to make it count at the time of the interval?

Taras Slobodyanik:

Read the MODE_TICKVALUE for each tick itself.

Well, let's say it does count. But how can the tester be "asked" to display in the Results table the value I have calculated, rather than its curved calculation?
 
Mihail Matkovskij:

Look carefully at the examplehttps://www.mql5.com/ru/forum/160683/page1208#comment_17279150 . You don't find anything there...?

This is the function:

You should be a little more careful!

Maybe we didn't understand each other, or maybe I didn't phrase my question accurately, but.... I looked carefully at the list of all functions in the MQL4 Reference and in the MQL5 Reference

I didn't find the function

searshValue(double & array2D[2][], const int _len, const int _index, const double _value)

I didn't find any. I looked at example on your link. I saw the code with unknown function. But I haven't found the answer to my question - what language this function comes from. If it was in MQL4 andMQL5, I think it would be in the list of functions in their directories.

And then I assumed that it was a custom function. But Kovalev's article says that calculations of the custom function are performed outside the lower limits of start()
. And I also read that when writing code in MT one can use functions from other languages, not only MQL4 and MQL5 .

Variables with identifiers CONST are listed as parameters of this function . I've never encountered them inMQL4 and it also confused me.
I know that your programming skills are many orders of magnitude different from mine. I'm just at the beginning of understanding. I am asking you not to judge me strictly and to be lenient to me if I am going to be absurd and ask silly questions. I shall be grateful to you if you could send me some links to information I need, or tell me where to read.

One more thing.... I've created a new EA, copied the first code you sent me, compiled the code without errors. I did not make any changes in it ... I was very surprised that the Print() function was missing in the ledger after running the EA in the tester. While it has been executed many times in our EA.
Thanks again for the informational support and valuable information.

 
ANDREY:

Maybe we didn't understand each other, or maybe I didn't phrase the question accurately, but.... I looked carefully at the list of all functions in the Handbook.. .

Andrey, don't think that I am judging you harshly. If you do not understand where a function comes from, right-click on it and select "Move to Alt+G definition". And don't be embarrassed if you don't know something. It is normal.

How to learn how to program. To do this, you need to answer the question, what is it for? If it's for creating trading robots and technical analysis programs, it's only relevant examples, lessons and articles in MQL. Maybe even books. However, when Igot acquainted with MQL, I've learned it quite well, so I haven't read any books, just read documentation. I advise you to first understand what the program is. To do so, start from studying the MQL event model: https://docs.mql4.com/ru/basis/function/events . This is a basic model. If you have mastered it, you can easily move on. Maybe this will help you: Getting Started with MQL5: Writing a Simple Expert Advisor and Indicator(I used the search engine). More:The basics of the language. Particularly:Function call andPassing parameters(where you have questions). If you have questions during studying (and they will be), you can use Google search or YouTube. Or ask questions here.Ideally, it would be good to learn C++. If you google something about syntax, you can also add "C++".

Функции обработки событий - Функции - Основы языка - Справочник MQL4
Функции обработки событий - Функции - Основы языка - Справочник MQL4
  • docs.mql4.com
В языке MQL4 предусмотрена обработка некоторых предопределенных событий. Функции для обработки этих событий должны быть определены в программе MQL4: имя функции, тип возвращаемого значения, состав параметров (если они есть) и их типы должны строго соответствовать описанию функции-обработчика события. Именно по типу возвращаемого значения и по...
 
Mihail Matkovskij:

Andrei, don't think I'm judging you harshly. If you don't understand where this or that function comes from, right-click on it and select "Go to Alt+G definition". And don't be embarrassed if you don't know something. It is normal.

How to learn how to program. To do this, you need to answer the question, what is it for? If it's for creating trading robots and technical analysis programs, it's only relevant examples, lessons and articles in MQL. Maybe even books. However, when Igot acquainted with MQL, I've learned it quite well, so I haven't read any books, just read documentation. I advise you to first understand what the program is. To do so, start from studying the MQL event model: https://docs.mql4.com/ru/basis/function/events . This is a basic model. If you have mastered it, you can easily move on. Maybe this will help you: Getting Started with MQL5: Writing a Simple Expert Advisor and Indicator(I used the search engine). More:The basics of the language. Particularly:Function call andPassing parameters(where you have questions). If you have questions during studying (and they will be), you can use Google search or YouTube. Or ask questions here.Ideally, it would be good to learn C++. If you google something about syntax, feel free to add 'C++' as well.

Thanks for the advice and hints. It all started for me when I did a free forex course at Teletrade in Moscow some years ago, out of nothing to do and out of a desire to put my spare money somewhere. But after completing the course, I immediately got the idea that trading haphazardly is a guaranteed loss of money... even despite occasional wins. That's why I made a firm decision not to gamble with my own money until I had a system, and before I graduated I didn't even own a PC. I'm not a mathematician. I can't tear myself away from my computer and MT4 since I've bought a computer and got MT4 on course, I can't tear myself away from the computer and MT4 up to this moment. I'm watching myself and can not understand where did this irresistible and irrational craving come from. I don't think it's just the money. I'm fine with money. I don't work and I have all my time on my hands. And I need something to occupy it so it doesn't drag on for too long. I've noticed that when I study Forex and programming time flies quickly and unnoticeably, so, after I graduated from the course it took me a long time to master the computer and simultaneously I was staring at charts on MT and trying to understand how and why price moves in one direction or another. You can say that I was fascinated and enchanted by the chart and it created a strong dominant position in my brain. As I progressed in my understanding of the computer, the Internet and forex, I learned about algorithmic trading and decided to read about it. And it also drew me in to the point where I even learned a little coding from Kovalev's tutorial. The more I understood the book material and tried to apply it while coding the more different thoughts came to me, which I tried to code. But few months ago quite unexpectedly and accidentally I saw one pattern, which appears very clearly on EUR-USD and FUNT-DOLLAR pairs. I managed to code this pattern. And the Expert Advisor with this code in the tester has been drawing a balance graph in the tester since 2008, which is constantly moving up with acceptable drawdowns. This was an additional and powerful impetus for me to become more enthusiastic about studying MQL4 programming. At present I haven't mastered it well enough to start studying MQL5.

Thank you again for the links and your comments.

This is a balance chart

I have some ideas how to make this chart more optimal. But I do not have enough experience to code them all yet.

 
ANDREY:

When you learn MQL4 and move on to MQL5, it will pull you in even more... :)

 
Mihail Matkovskij:

When you learn MQL4 and move on to MQL5, it will pull you in even more... :)

Let's see how quickly it happens...

 
Mihail Matkovskij:

If you don't understand where a function comes from, right-click on it and select "Go to Alt+G definition". And don't be embarrassed if you don't know something. That's fine.

It's a valuable menu item for me. And I was very glad to hear about it and its functionality from you. But for some reason this item doesn't work for me. I've tried different options.

Hovering your cursor over the function (in its place before the parentheses) and right-clicking. The context menu "Goto Alt+G" is active. I click on it but nothing happens. I press Alt+G in English and uppercase, nothing happens.

I think I should be thrown into Help, or rather in the place where the function is described with the right button of the mouse.
I have MT-4 build 1260
I read the MetaEditor's Help, but couldn't find anything about this feature. And this item is very valuable for me. Maybe some settings are missing in MetaEditor?
I'd be grateful if you could share your thoughts on why this item doesn't work for me.

This is the toolbar of my MetaEditor. Many of the buttons are not active. Could it be about one of these buttons?


 
ANDREY:

Thanks for the advice and tips. For me, it all started when I took a free forex course at Teletrade in Moscow a few years ago out of nothing to do and out of a desire to put my spare money somewhere. But after completing the course, I immediately got the idea that trading haphazardly is a guaranteed loss of money... even despite occasional wins. That's why I made a firm decision not to gamble with my own money until I had a system, and before I graduated I didn't even own a PC. I 'm not a mathematician. I can't tear myself away from my computer and MT4 since I've bought a computer and learned to play with it. I'm watching myself and can not understand where did this irresistible and irrational craving come from. I don't think it's just the money. I'm fine with money. I don't work and I have all my time on my hands. And I need something to occupy it so it doesn't drag on for too long. I've noticed that when I study Forex and programming time flies quickly and unnoticeably, so, after I graduated from the course it took me a long time to master the computer and simultaneously I was staring at charts on MT and trying to understand how and why price moves in one direction or another. You can say that I was fascinated and enchanted by the chart and it created a strong dominant position in my brain. As I progressed in my understanding of the computer, the Internet and forex, I learned about algorithmic trading and decided to read about it. And it also drew me in to the point where I even learned to code a little using Kovalev's tutorial. The more I understood the book material and tried to apply it while coding the more different thoughts came to me, which I tried to code. But few months ago quite unexpectedly and accidentally I saw one pattern, which appears very clearly on EUR-USD and FUNT-DOLLAR pairs. I managed to code this pattern. And the Expert Advisor with this code in the tester has been drawing a balance graph in the tester since 2008, which is constantly moving up with acceptable drawdowns. This was an additional and powerful impetus for me to become more enthusiastic about studying MQL4 programming. Since I'm not yet masters it enough to start studying MQL5.

Thanks again for the links and for getting me on the right track.

This is a balance chart

I have some ideas how to make this chart more optimal. But I still lack the experience to thoroughly codify them.

The most important thing for a programmer is to be able to set a task and find ways to solve it. And this defines a mathematical mindset. If you can change your mindset, God willing.

And if you are trying to write in mql4, will always be looking at the documentation for mql5 to find similarities between languages, then consider that having dealt with mql4, you already dealt with mql5. The languages are so similar that it's easier to list the differences than to list the similarities.

Kovalev's textbook was written so long ago that in most cases before you write something, you need to find modern methods, even though the ones used in the examples in the textbook will work for some time.

This article may help a lot, not only to switch to mql5, but also to understand the difference between the mql4 described by Sergei Kovalev and modern mql4
Переход с MQL4 на MQL5
Переход с MQL4 на MQL5
  • www.mql5.com
Данная статья, построенная в форме справочника по функциям MQL4, призвана помочь переходу с MQL4 на MQL5. Для каждой функции языка MQL4 приведено описание и представлен способ ее реализации на MQL5, что позволит вам значительно ускорить перевод своих программ с MQL4 на MQL5. Для удобства функции разбиты на группы, как в документации по MQL4.
 
Alexey Viktorov:

The most important thing for a programmer is to be able to set a problem and find ways of solving it. And that is what defines a mathematical mindset. If you are able to change your mindset, God help you.

And if you are trying to write in mql4, constantly looking through the documentation mql5 to find similarities in the languages, then consider that having dealt with mql4 you already have dealt with mql5. The languages are so similar that it's easier to list the differences than to list the similarities.

Kovalev's textbook was written so long ago that in most cases before you write something you need to find modern methods, even though the ones used in the examples in the textbook will work for some time.

Thanks for the valuable information.

Regarding the mathematical mindset. Since I'm from scratch .... albeit too long .... I am somewhat familiar with Kovalev's textbook, and even learnt to write primitive codes that compile without errors, and even coded something similar to "grail" ..... it means that my mindset is changing in the direction I need it..... , as it seems to me.
Please tell me if it's OK ... Can you run MQL5 functions in MetaEditor 4?

Thank you

Reason: