Not logged in
Viewing 2 posts - 1 through 2 (of 2 total)

Forums>EA Wizard>General Discussion>Total number of open trades

  • #250769|
    Customer
    74 Posts

    Hi,

    Is it possible to have a rule that checks the total number of open trades in the account (not just the EA)? For example, IF number of open trades in the account < 3, then execute action.

    #250775
    tomas262
    Administrator
    1116 Posts

    Hello,

    EA Wizard does not include such function but it can be easily added as the following custom function (include at the end into /code/CustomFunctions.mq4)

    int getOpenOrdersCount() {

    int open_orders = 0;

    for( int j = 0; j < Total; j ++){
    OrderSelect(j, SELECT_BY_POS, MODE_TRADES);
    if(OrdersTotal()==0) break;
    if(OrderType()==OP_BUY) open_orders++; continue;
    if(OrderType()==OP_SELL) open_orders++; continue;
    }

    return(open_orders);

    }

    and refer in EA Wizard as shown in the screenshot attached

    Attachments:
    You must be logged in to view attached files.
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.