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

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I have an idea to write a function that will take and shift an array. The question is how to make this function so that it itself determines what type of array is one-dimensional or 2-dimensional, so that I don't have to specify in the arguments every time that the array is 2-dimensional or regular. At the same time, I want to apply a template, so that I don't have to specify the type of the array.
How can I make it so that I don't have to specify what type of array?
Do overloading:
Overloading to do:
Can the second dimension be dynamic?
It's not dynamic, it's just written as a received argument, just put square brackets.
How can I implement in a loop (or some other way) the enumeration of possible condition variants?
For example, there are 2 indicators MA and MACD, i.e. they represent 3 possible condition variants:
1 option - if(iMA ...) {...};
2nd scenario - if(iMACD ...) {...};
variant 3 - if(iMA ... iMACD ...) {...};
It's easy to combine input parameters, but how do I combine conditions? This is especially useful if there are more than 2 indicators or formulas
Give links to examples if available
How to implement in a loop (or some other way) the enumeration of possible variants of conditions?
If I understand correctly, the answer can be found in the topic.
Hello again, again I don't understand something obvious.
So how to pass an array to a function after all?
Errors:
']' - expression expected
'b' - parameter conversion not allowed
Suppose I know how to eliminate the first error:
Func(b[3]);
But in this case what, only the third element will be passed? It makes no sense.
How can I pass the array as a whole?
Thank you.
Hello again, again I don't understand something obvious.
So how to pass an array to a function after all?
Errors:
']' - expression expected
'b' - parameter conversion not allowed
Suppose I know how to eliminate the first error:
But in this case what, only the third element will be passed? It makes no sense.
How can I pass the array as a whole?
Thank you.
Please explain the mechanics of variable begin
This link seems to have informationhttps://www.mql5.com/ru/docs/basis/function/events, but I either don't understand it or haven't found it. I can't understand what is the default value at the beginning and how it changes as the cycles in the indicators go through
For example I know that return() inside the function OnCalculate() assigns the return value to the variable prev_calculated and it will be used in calculations at next call of OnCalculate(), i.e. at next tick
Please describe in the same simple words the mechanics of the variable begin inside the function OnCalculate()
Good afternoon.
Can you please tell me why the OnTick function doesn't write data to the file using this code:
//=== write data to file ===
h1=FileOpen("test_bar.csv",FILE_CSV|FILE_WRITE|FILE_READ,",");
FileSeek(h1, 0, SEEK_END);
FileWrite(h1, TimeToStr(Time[1],TIME_DATE|TIME_MINUTES),i,Open[1],High[1],Low[1],Close[1], Parabola57Up, ");
FileClose(h1);
And that is during history testing. When the Expert Advisor is working online, it keeps recording.
Thank you
How can I implement in a loop (or some other way) the enumeration of possible condition variants?
For example, there are 2 indicators MA and MACD, i.e. they represent 3 possible condition variants:
1 option - if(iMA ...) {...};
2nd scenario - if(iMACD ...) {...};
variant 3 - if(iMA ... iMACD ...) {...};
It's easy to combine input parameters, but how do I combine conditions? This is especially useful if there are more than 2 indicators or formulas
Give me some links to examples if you have them.
I want to make a self-optimization, but not only by input parameters of indicators. I understand it
But how to makeloopingof conditions? For example, there are 3 indicators (we don't consider the selection of input parameters in the loop for simplicity) and they are 7 possible combinations of conditions/combinations
For example, the first three conditions have one indicator
1) if(indicator #1 ...) {...};
2) if(indicator #2 ...) {...};
3) if(indicator #3....) {...};
The second three conditions on two indicators are
4) if(#1 ... && #2 ...) {...};
5) if(#1 ... && #3 ...) {...};
6) if(#2 ... && #3 ...) {...};
And in the last seventh condition all three available indicators
7) if(#1 ... && #2 ... && #3 ...) { ...};
And if it is also possible, it would be good to loop the enumeration of logical conditions. For example, don't write && || > < == and so on, but loop
. It would be nice if we could write every possible variant manually and the EA would combine and check all possible variants of the input parameters, combined or individual indicators and logical conditions.