Hello! My goal is to transfer the indicator by creating a function into the EA.
The first step, which is the creation of the function, is done. But the next one - testing - does not work.
The indicator draws channels. It has 4 buffers and a lot of variables. I have placed it all in the function.
But when I create a test EA to make sure that it works accurately by comparing the indicator and my function, I cannot get it to compile.
Constant errors of external variables, which were not there when I created the function, have popped up in the EA.
Please give me some advice or a link to an example. I used GODZILLA's articles, but his examples are different from mine.
The scheme is roughly as follows:
transfer everything that was in indicator init() to a separate function, for example, fInit_Indicator() and write it in init() of the EA, while remembering to remove everything that concerns initialization of indicator buffers from the code.
copy all global indicator variables and place them in global variables of the EA. Do not forget to define the size of indicator buffers when they are declared in the EA. Something like gd_Buf1[100], gd_Buf2[100] etc. I think that 100 values will be enough for you.
rename indicator's start() function, for example, fMyIndicator() and place it in the EA's start() function before the code of order opening (for making a decision).
Also, do not forget that the indicator buffer is different from the "non-indicator" buffer. There are several solutions for this:
when a new bar arrives, all data in the "non-indicator" array is shifted, releasing the 0-index, where the new calculated value is placed.
Again, when a new bar arrives, recalculate the entire "nonindicator array".
I need to load values of the number of points into the array on each new tick.
The size of the array will be different each time. What should I do in this case, use ArreyResize on each iteration of the loop?
1-Item: your philosophy of changing the array size is defective from the very beginning, in 99 out of 100 cases you can use only 10 cells for handling indicator readings;
2-nd: to recalculate these readings at each tick is a whim of ill-informed brain.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hello! My goal is to transfer the indicator by creating a function into the EA.
The first step, which is the creation of the function, is done. But the next one - testing - does not work.
The indicator draws channels. It has 4 buffers and a lot of variables. I have placed it all in the function.
But when I create a test EA to make sure that it works accurately by comparing the indicator and my function, I cannot get it to compile.
Constant errors of external variables, which were not there when I created the function, have popped up in the EA.
Please give me some advice or a link to an example. I used GODZILLA's articles, but his examples are different from mine.
The scheme is roughly as follows:
Try it out - it's not difficult.
Help me write a condition that will cause the EA to multiply the lot by two times after opening n orders
Good afternoon!
I'm still figuring things out with arrays.
I need to load values of the number of points into the array on each new tick.
Thesize of the array will be different each time. What should I do in this case, use ArreyResize on each iteration of the loop?
Good afternoon, on the subject of arrays.
there is a cell of this type
12345,p,fgh,2011-01-01,55,66
how can i get 55 from it?
Thanks.
If the array is heterogeneous, you should probably convert all elements to string type and then search for the required one using
StringFinde(https://www.mql5.com/ru/forum/138609/page22#613148). Correct me if I'm wrong.
else gd_200 = AccountBalance() * RiskPercent / 100.0 / 10000.0;
Replace it with an Expert Advisor that calculates not the balance but the number of open orders.
The answer would be very much appreciated.
else gd_200 = AccountBalance() * RiskPercent / 100.0 / 10000.0;
Replace it with an Expert Advisor that calculates not the balance but the number of open orders.
The answer would be very much appreciated.
Good afternoon, on the subject of arrays.
there is a cell of this type
12345,p,fgh,2011-01-01,55,66
how can i get 55 from it?
Thanks.
https://book.mql4.com/ru/variables/arrays
Help me write a condition that will cause the EA to multiply the lot by two times after n orders are opened
Good afternoon!
I'm still figuring things out with arrays.
I need to load values of the number of points into the array on each new tick.
The size of the array will be different each time. What should I do in this case, use ArreyResize on each iteration of the loop?
1-Item: your philosophy of changing the array size is defective from the very beginning, in 99 out of 100 cases you can use only 10 cells for handling indicator readings;
2-nd: to recalculate these readings at each tick is a whim of ill-informed brain.