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

 

Hi,

Thanks for this great article...

In the function ReplacedDelayedOrders is the code line:   for(int b=0;i<history_orders;b++)

I think this will cause an endless loop, or am I wrong?

I think the code line must be:   for(int b=0;b<history_orders;b++)

 

Bye, T.

 

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
 

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

 

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...
 

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!

 

In the CTableOrders class, I think you should use order_info.OrderType() instead of order_info.Type()

Reason: