Discussion of article "Creating Multi-Expert Advisors on the basis of Trading Models" - page 6

 

Thank you, this is a great article and a good framework. Exactly what I was looking for.

I plan to use it with real money, is it the latest version?

 

Thanks 

 
't' - conversion exists, but is inaccessible    Model.mqh    280    27
 

Good afternoon!

I've tried to correct several errors, but one more keeps popping up... if the aim was to make life easier for beginners, it's getting difficult like this and I'm losing my mind here...

Help Please!

Error

 

Great article!
I had to change two things to get it working.

On the file "TableOrders.mqh" on this function bool CTableOrders::Add(ulong Ticket,double stop_loss,double take_profit) line 89, the variable m_type should be replaced by:

From:
m_type=order_info.Type();

To:

m_type=order_info.OrderType();

The second one also on the "TableOrders.mqh":

From:

class CTableOrders : CObject  

To:

class CTableOrders : public CObject 

Regards,
A. HUPP

 
Airton Raposo:

Good afternoon!

I've tried to correct several errors, but one more keeps popping up... if the aim was to make life easier for beginners, it's getting difficult like this and I'm losing my mind here...

Help Please!

Airton this article is very advanced for beginners, you must first understand the concept of Object Oriented application development, hierarchies, polymorphism, inheritance, virtual methods, that is, you need to know advanced programming, the errors found in these examples however are related to class declarations, which in some of them are missing the public keyword that you must insert by hand, perhaps the previous version of MQL did not need these keywords to compile, but this version requires this correction.

 

in order to compile the file simple_model.mq5 i had to add "public":

class CModel: public CObject  at line 12

while compiling MACD_MA_model.mq5 i keep getting this error:

'MODE_OPEN' - enumerator identifier already defined    stdlib.mqh    13    4

i cannot get around this error which refers to underlying library.

Thank you for your article and the effort to build a general framework for testing.

 
z3r00tt0:

in order to compile the file simple_model.mq5 i had to add "public":

class CModel: public CObject  at line 12

while compiling MACD_MA_model.mq5 i keep getting this error:

'MODE_OPEN' - enumerator identifier already defined    stdlib.mqh    13    4

i cannot get around this error which refers to underlying library.

Thank you for your article and the effort to build a general framework for testing.

https://www.mql5.com/en/forum/244512

Enumerator compile error
Enumerator compile error
  • 2018.05.14
  • www.mql5.com
Hi, I'm new in mql programming and trying to develop my first EA based on what I found in mql articles...
 

Tried to uncompile, got errors

'MACD_MA model.mq5'     MACD_MA model.mq5       1       1
'Trade.mqh'     Trade.mqh       1       1
'Object.mqh'    Object.mqh      1       1
'StdLibErr.mqh' StdLibErr.mqh   1       1
'SymbolInfo.mqh'        SymbolInfo.mqh  1       1
'OrderInfo.mqh' OrderInfo.mqh   1       1
'HistoryOrderInfo.mqh'  HistoryOrderInfo.mqh    1       1
'PositionInfo.mqh'      PositionInfo.mqh        1       1
'DealInfo.mqh'  DealInfo.mqh    1       1
'AccountInfo.mqh'       AccountInfo.mqh 1       1
'model_macd.mqh'        model_macd.mqh  1       1
'Model.mqh'     Model.mqh       1       1
'List.mqh'      List.mqh        1       1
'TableOrders.mqh'       TableOrders.mqh 1       1
'Time.mqh'      Time.mqh        1       1
'mm.mqh'        mm.mqh  1       1
'stdlib.mqh'    stdlib.mqh      1       1
'model_ma.mqh'  model_ma.mqh    1       1
'model_bollinger.mqh'   model_bollinger.mqh     1       1
return value of 'OrderSelect' should be checked TableOrders.mqh 120     4
implicit enum conversion        TableOrders.mqh 50      44
'new_message' - conversion is not accessible because of inheritance access      Time.mqh        185     21
possible use of uninitialized variable 'lot_limit'      mm.mqh  129     10
't' - conversion is not accessible because of inheritance access        Model.mqh       252     27
declaration of 'trade' hides global variable    Model.mqh       282     16
   see previous declaration of 'trade'  MACD_MA model.mq5       18      8
declaration of 'i' hides local variable Model.mqh       310     15
   see previous declaration of 'i'      Model.mqh       307     12
possible loss of data due to type conversion    Model.mqh       428     47
possible loss of data due to type conversion    model_macd.mqh  86      11
possible loss of data due to type conversion    model_macd.mqh  90      14
possible loss of data due to type conversion    model_macd.mqh  91      14
possible loss of data due to type conversion    model_macd.mqh  92      16
expression not boolean  model_macd.mqh  228     11
expression not boolean  model_macd.mqh  254     11
possible loss of data due to type conversion    model_ma.mqh    85      11
possible loss of data due to type conversion    model_ma.mqh    89      8
possible loss of data due to type conversion    model_ma.mqh    90      19
expression not boolean  model_ma.mqh    219     11
expression not boolean  model_ma.mqh    242     11
declaration of 'k_ATR' hides global variable    model_bollinger.mqh     97      110
   see previous declaration of 'k_ATR'  MACD_MA model.mq5       25      16
possible loss of data due to type conversion    model_bollinger.mqh     99      22
possible loss of data due to type conversion    model_bollinger.mqh     104     22
possible loss of data due to type conversion    model_bollinger.mqh     107     22
variable 'rezult' not used      model_bollinger.mqh     170     9
variable 'rezult' not used      model_bollinger.mqh     195     9
expression not boolean  model_bollinger.mqh     238     11
expression not boolean  model_bollinger.mqh     263     11
2 errors, 25 warnings           3       26

Any plans to fix the code?

 

min_risk = point * tick_value * symbol_info_.LotsStep();

you should use tick count instead of point count.

tick_count = MathAbs(open_price - stop_loss) / symbol_info_.TickSize();

because in some symbols, tick size != point


for example: 

Futures\Agricultural Commodities\#Coffee_H21:

Digits: 2 Point: 0.01 TickValue: 18.75 TickValueProfit: 18.75 TickValueLoss: 18.75 TickSize: 0.05 ContractSize: 375.0 LotsMin: 0.01 LotsMax: 50.0 LotsStep: 0.01 LotsLimit: 0.0
 

You shouldn't delete node when iterating the list.

for example:

class Test : public CObject {
  public:
    int i_;
    Test(int i) {
        i_ = i;
    };
    int get_i() {
        return i_;
    };
};


    CList *list = new CList();
    for (int i = 0; i < 10; i++) {
        Test *t = new Test(i);
        list.Add(t);
    }

    for (int i = 0; i < list.Total(); i++) {
        Test *t = list.GetNodeAtIndex(i);
        if (i == 5) {
            list.DeleteCurrent();
        }
        if (CheckPointer(t) == POINTER_INVALID) {
            continue;
        }
        Print(t.get_i());
    }

After deleting node at index 5, you iterate index 6, but the next element is still index 5.

It's a better idea using GetFirstNode / GetNextNode

    for (Test *t = list.GetFirstNode(); t != NULL;) {
        t_current = t;
        if (t.get_i() == 5) {
            list.DeleteCurrent();
            t = list.GetCurrentNode();
            if (t == t_current) {break;}
            continue;
        }
        Print(t.get_i());
        t = list.GetNextNode();
    }

Thanks for your contribution!