Beta version of the online book on MQL4 programming - by Sergey Kovalev (SK.) - page 9

 
Climber:
Found this great article on complex order bookkeeping by SK 'Order Bookings in a Large Program'.
Honestly, I'm wondering if this whole thing is a scam.
It is not a gimmick but you have to keep an open mind. Read Korey's posts starting on this page for more clarity. And have a look at my first "grail".
 
I've read about the grail before :)
But unlike the character described in the article about the grail, I don't think like him: "Just me!". I think there's something wrong here, or it's just luck right now. Although, looking at the championship results, you can see a much better result in three months, which basically means nothing is impossible. And yet, one can't help but wonder who will give such a "rapid" development in the real world?
 
Climber:
And yet one wonders who will allow such "rapid" development in the real world?

It is a simple question. And the answer is obvious: he who works honestly (brokers are not discussed here).

The more difficult question is whether the Expert Advisor is producing stable, high results? Or is it just a fitting story or a fluke?

 
SK. писал (а):
The more difficult question is whether the advisor actually gives consistent,
high results? Or is it just a fit with the story or a fluke?
Well, I don't have one yet, but if I had one, I think it would help me understand a lot. I am also inclined to chance. That's me manually on the demo for now.

I've just had much more modest results before. And in general, while studying your book (for almost a month) and the whole language in general, I`ve learned a lot about trading that I didn`t know and didn`t suspect during 2 years of studying Forex. I am even now thinking how I could earn something without knowing that much)) I think even now I could have made so much without knowing anything. It's just that when I first tried to trade on the demo, I got the feeling that I could earn not more than $300 per month. Which is not bad either, especially taking into account my allergy to bosses of all kinds:) I used to write my first Expert Advisor in my blog, and I've never heard of it.

I wrote my first advisor within a week of first reading the book. But I didn't write it, I copied it, replacing only the block with trade criteria, and the rest was taken from the example of EA using MA. But when I wrote it, I only wanted to know what if I did it this way. I mean to simply use the capabilities of the tester without having to check it manually for a long time. I didn't have any ideas like in the article about the grail. I'm more down-to-earth in this respect:) I am satisfied with the result, as I have completely lost my deposit (one less variant). The idea was simple as hell, so it was a sin not to check it. But the last strategy is more difficult (for me) in terms of description using MQL4 tools, therefore I have to work with my own hands. But its results in manual mode require further development of the Expert Advisor. So I am trying, slowly but slowly, to write it.
 
Climber:
I just had much more modest results before. And in general, while studying your book (almost a month) and the whole language in general, I learned a lot about trading that I didn't know and didn't suspect during my 2 years of acquaintance with forex. I am even now thinking how I could earn something, without knowing much...).
But the last strategy is more complicated (for me) in terms of description by means of MQL4, so I have to work manually. But its results in manual mode just need further development of the Expert Advisor. So I am trying, slowly, but writing.
In my opinion, the labor input for the creation of a robust profitable strategy is about two orders (100 times) higher than the labor input for learning the language. In essence, programming is only a technical tool, largely predictable, and therefore subject to the will of the strategy creator. But to be fair, it must also be said that delving into the details of programming, a trader begins to look at the whole phenomenon of market-trading-strategy with a clearer view. In this sense, it is difficult to overestimate the programming practice. Therefore, the developers who decided to rely on auto-trading were right a hundred times over.
 

to SK

Variables, .

You have the following written:

" All arrays are static inherently, i.e. have a static form, even if this is not explicitly stated during initialisation "

However

Suppose an indicator, the calling subroutine has an array:

1)

double summ[]; //the standard function .................................... .......... is called

i=ArrayMinimum(summ,iter,0); // Error on the second call: <incorrred start position 0 for ArrayMinimum function>

2) variant of the error

static double summ[];

//..............................................

i=ArrayMinimum(summ,iter,0); // Same error on the second call: <incorrred start position 0 for ArrayMinimum function>

3) error free variant

double summ[1000];

..............................................

i=ArrayMinimum(summ,iter,0); // Normal execution

4) error free variant

static double summ[1000];

..............................................

i=ArrayMinimum(summ,iter,0); // Normal execution



It follows from examples 1 and 2 that arrays are allocated dynamically.

Example 2 suggests that an array without a dimension is not initialized as a static array (which is obvious), but this does not show up in compiler errors ((

Example 3 4 implies that only predefined arrays have static allocation .

Interestingly the executing system catches the Error and determines from Example 1 and 2, which suggests a well thought out real time terminal system . I.e. the array behaves like an object. Kudos to the developers.

However, not everything is going so well with simple variables

double instik(int &t) // this function changes the variable in the calling program

{

t++;

}

This call counts on every tick if

//...........................................

static int tik;


instik(tik);

Print (" tick=",tik);

//...............................

And this doesn't count because memory allocation is dynamic, and the linked address on the second call doesn't match.

................

int tik;


instik(tik);

Print (" tick=",tik);

// instik subroutine gives increment to unknown byte, but terminal doesn't crash!!!! Again, kudos to the developers.

 
SK. писал (а):

But to be fair
it should also be said that by getting into the details of programming
a trader begins to look at the whole market-trading-strategy phenomenon
with a clearer view. And as they gain experience, they sift out
And as experience is accumulated, wrong lines of thought are eliminated and promising lines of thought are identified.
I agree 100%. I was even surprised at first, I think I am trying to learn programming and I have learned more about trading than I knew before. So I am going to gain experience for now:)
 
Korey:

to SK

Variables, static variables.

...


I think you are overlooking the fact that special functions are re-run on every tick. Static variables retain their values and are not initialized, while non-static variables are initialized according to the code. In your code, the integer variable tik is initialized to zero by default.

//----------------------------------------------------------------------------------
int start()
   {
   int tik;                // Инициализация нолём на каждом тике
   instik(tik);            // Вызов функции, передача параметра по ссылке
   Alert (" tick=",tik);   // Всё время выводит 1, как и ожидается
   return;
   }
//----------------------------------------------------------------------------------
double instik(int &t)      // Функция изменяет переменную в вызывающей программе
   {                       // При каждом обращении заходит 0
   t++;                    // Увеличение значения на 1, как и заказано, т.е.
   }                       // ..при каждом исполнении уходит 1
//----------------------------------------------------------------------------------

In instik() everything happens as intended. In start(), by the moment of Alert(), the value of the tik variable is 1, which is what Alert() outputs.

But this is not the whole truth. Since the tik variable is not declared as static, its value is not saved. That is, at the next call for execution of the special function start() the tik variable will be initialized with zero again. And everything begins all over again. Therefore, Alert safely outputs one after another.

 
Congratulations to Sergey Kovalev!

The release of the MQL4 language tutorial is scheduled for February 1 and it is already integrated into the MQL4.community website. The translation into English is well under way.
 
Sergei!
How to implement in the Expert Advisor the possibility to close an order - by counter-order? I didn't find it in the tutorial...
Reason: