to continue...
I thought of converting the lines of this example:
if(m_method_fast!=MODE_SMA && m_method_fast!=MODE_EMA && m_method_fast!=MODE_SMMA && m_method_fast!=MODE_LWMA)
if(m_method_slow!=MODE_SMA && m_method_slow!=MODE_EMA && m_method_slow!=MODE_SMMA && m_method_slow!=MODE_LWMA)
Into the algorithm:
1) two arrays:
the first contains m_method_fast and m_method_slow
the second contains ENUM_MA_METHOD enumeration values.
2) In a loop, taking the value of the first array, check if it is found in the second one.
Can you tell me how to implement this?
I understand that it is necessary to connect CArray . But what type?
Who can, please, write a part of the code, because elementary basic things, and with syntax I can not catch yet.
Thank you!

- www.mql5.com
to continue...
I thought of converting the lines of this example:
if(m_method_fast!=MODE_SMA && m_method_fast!=MODE_EMA && m_method_fast!=MODE_SMMA && m_method_fast!=MODE_LWMA)
if(m_method_slow!=MODE_SMA && m_method_slow!=MODE_EMA && m_method_slow!=MODE_SMMA && m_method_slow!=MODE_LWMA)
Into the algorithm:
1) two arrays:
the first contains m_method_fast and m_method_slow
the second contains ENUM_MA_METHOD enumeration values.
2) In a loop, taking the value of the first array, check if it is found in the second one.
Can you tell me how to implement this?
I understand that it is necessary to connect CArray . But what type?
Who can, please, write a part of the code, because elementary basic things, and with syntax I can not catch yet.
Thanks!
Like this:
func(int& array1[],int& array2[]) { int total1=ArraySize(array1); int total2=ArraySize(array2); //--- for(int i=0;i<total1;i++) { for(int j=0;j<total2;j++) { if(array1[i]==array2[j]) { // found it } } } }
Yes, I've already got to this point in C++ for Beginners :-)
Except that there is no such data type ENUM_MA_METHOD there
How can I find out what type of data this enumeration consists of? Is it possible to loop through the ENUM_MA_METHOD enumeration itself?
I see two ways now:
//first way to describe both arrays ENUM_MA_METHOD l_array_enum_ma_method[3]; l_array_enum_ma_method[0]=MODE_SMA; l_array_enum_ma_method[1]=MODE_EMA; l_array_enum_ma_method[2]=MODE_SMMA; l_array_enum_ma_method[3]=MODE_LWMA; print("array size %d", ArraySize(l_array_enum_ma_method)); print("ENUM_MA_METHOD size %d", ArraySize(ENUM_MA_METHOD)); ENUM_MA_METHOD l_array_select_method[1]; l_array_select_method[0]=m_MethodFast; l_array_select_method[1]=m_MethodSlow; //further according to the scheme //second way, connect the library //#include <Arrays\ArrayInt.mqh> CArrayInt *l_array_enum_ma_method=new CArrayInt; l_array_enum_ma_method[0]=MODE_SMA; l_array_enum_ma_method[1]=MODE_EMA; l_array_enum_ma_method[2]=MODE_SMMA; l_array_enum_ma_method[3]=MODE_LWMA; l_array_enum_ma_method.Sort(); //--- search element if(l_array_enum_ma_method.Search(m_MethodFast)!=-1) printf("Element found"); else printf("Element not found"); //--- delete array delete l_array_enum_ma_method;
in the second way you need to connect a library of a specific type, and what type is ENUM_MA_METHOD?
hmm... strange, I clicked reply and it turned out to be a new post....
Yes, I've already got to this point in C++ for Beginners :-)
Except that there is no such data type ENUM_MA_METHOD there
How can I find out what type of data this enumeration consists of? Is it possible to loop through the ENUM_MA_METHOD enumeration itself?
I see two ways now:
in the second way you need to connect a library of a specific type, and what type is ENUM_MA_METHOD?
hmm... strange, I clicked reply and it turned out to be a new post....
First way:
ENUM_MA_METHOD l_array_enum_ma_method[]={MODE_SMA,MODE_EMA,MODE_SMMA,MODE_LWMA}; //--- further down the line
Second way:
#include <Arrays\ArrayInt.mqh> CArrayInt l_array_enum_ma_method; //--- l_array_enum_ma_method.Add(MODE_SMA); l_array_enum_ma_method.Add(MODE_EMA); l_array_enum_ma_method.Add(MODE_SMMA); l_array_enum_ma_method.Add(MODE_LWMA); //--- further down the line
I can't figure out why so many steps are required?
oops... thanks a lot, that's what I'm trying to do... off.
In the first case, I've already seen this way of recording, but I haven't realised what I need yet,
and in the second case - I was confused by ArrayInt. I thought that since Int, it means that only number value is stored, but ,
it seems that the compiler converts MODE_SMA into a number, and when getting the value back, it will be necessary to perform an implicit conversion (using parentheses) to the type(ENUM_MA_METHOD), i.e. something similar to the following.
ENUM_POSITION_TYPE type=(ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);
P.S. In the third section 3. Methods for setting parameters, we should erase prematurely declared lines, I think
:
CiCustom m_fast_ma; // indicator as an object CiCustom m_slow_ma; // indicator as an object
P.S. In the third section 3. Methods for setting parameters, I think we should erase prematurely declared lines:
I was getting excited, but I can't get around this (comm - I read about memory address transfer, but it didn't work that way either):
The compiler returns the error 'm_MethodFast' - constant expression required, ' m_MethodSlow' - constant expression required
Of course, these are questions for a dummies. maybe I should ask such questions in another thread, so as not to clog up the article?
//first way to describe both arrays //int *Finger_m_MethodFast; //int *Finger_m_MethodSlow; //Finger_m_MethodFast=&m_MethodFast; //Finger_m_MethodFast=&m_MethodSlow; // int l_array1_select_method[]={Finger_m_MethodFast,Finger_m_MethodFast}; ENUM_MA_METHOD l_array1_select_method[]={m_MethodFast,m_MethodSlow}; ENUM_MA_METHOD l_array2_enum_ma_method[]={MODE_SMA,MODE_EMA,MODE_SMMA,MODE_LWMA}; int total_array1=ArraySize(l_array1_select_method); int total_array2=ArraySize(l_array2_enum_ma_method); bool NoErrorsFlag=false; for(int i_array1=0;i_array1<total_array1;i_array1++) { for(int i_array2=0;i_array2<total_array2;i_array2++) { if(l_array1_select_method[i_array1]=l_array2_enum_ma_method[i_array2]) { NoErrorsFlag=true; } } if(!NoErrorsFlag) { PrintFormat("Invalid smoothing type %s moving average!",EnumToString(l_array1_select_method[i_array1])); } } if(!NoErrorsFlag) { return(false); }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
New article Create Your Own Trading Robot in 6 Steps! is published:
If you don't know how trade classes are constructed, and are scared of the words "Object Oriented Programming", then this article is for you. In fact, you do not need to know the details to write your own module of trading signals. Just follow some simple rules. All the rest will be done by the MQL5 Wizard, and you will get a ready-to-use trading robot!
Author: MetaQuotes