Not more than 3 pairs opened at a time

 
I am very new in MQL4 coding. I downloaded this EA  online. I am trying to modify it such that if I load it on say about 15 different pairs, I do not want trade to open in more than 3 pairs at any particular time even if the conditions for opening trade in the other pairs are met. Thank you all for your anticipated response.
 

Forum on trading, automated trading systems and testing trading strategies

Welcome,

  • Usually people who can't code don't receive free help on this forum, though it could happen if you are lucky, be patient.
  • If you show your attempts and describe well your problem, you will most probably receive an answer from the community.
  • If you don't want to learn to code, nothing bad, you can either look at the Codebase if something free already exists, or in the Market for paid products (sometimes free also).
  • Finally, you also have the option to hire a programmer in the Freelance section.
 
Sergey Golubev:

I have actually added the following  code to the EA as advised but it seems not working as expected:


int SYMBOL_NUMBER_LIMIT = 3;

string COUNTED_SYMBOLS[];

ArrayResize(COUNTED_SYMBOLS, SYMBOL_NUMBER_LIMIT, 0);

for(int s=0; s<SYMBOL_NUMBER_LIMIT; s++) COUNTED_SYMBOLS[s]="";

int SYMBOLS_IN_TRADE_SO_FAR = 0;

bool NEW_TRADE_PERMISSION = true;

int ALL_POSITIONS =  OrdersTotal();//PositionsTotal();

if(ALL_POSITIONS > 0)

{

        for(int index=0; index<ALL_POSITIONS; index++)

        {

                string THIS_SYMBOL = OrderSymbol();//PositionGetSymbol(index);

                bool Symbol_already_counted = false;

                for(int i=0; i<SYMBOL_NUMBER_LIMIT; i++)

                {

                        if(COUNTED_SYMBOLS[i]==THIS_SYMBOL)

                        {

                                Symbol_already_counted = true;

                                break;

                        }

                if(Symbol_already_counted) continue;

                else

                {

                        SYMBOLS_IN_TRADE_SO_FAR++;

                        if(SYMBOLS_IN_TRADE_SO_FAR >= SYMBOL_NUMBER_LIMIT)

{

                                NEW_TRADE_PERMISSION = false;

                                break;

                        }

                        for(int j=0; j<SYMBOL_NUMBER_LIMIT; j++)

                        if(COUNTED_SYMBOLS[j]=="")

                        {

                                COUNTED_SYMBOLS[j] = THIS_SYMBOL;

                                break;

                        }

                }

        }

}

 

 }

 
OLUFEMI ODUNUGA:

I have actually added the following  code to the EA as advised but it seems not working as expected:

...

I am not a coder so I can not help sorry.

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button

Thank you.

 

int SYMBOL_NUMBER_LIMIT = 3;

string COUNTED_SYMBOLS[];

ArrayResize(COUNTED_SYMBOLS, SYMBOL_NUMBER_LIMIT, 0);

for(int s=0; s<SYMBOL_NUMBER_LIMIT; s++) COUNTED_SYMBOLS[s]="";

int SYMBOLS_IN_TRADE_SO_FAR = 0;

bool NEW_TRADE_PERMISSION = true;

int ALL_POSITIONS =  OrdersTotal();//PositionsTotal();

if(ALL_POSITIONS > 0)

{

        for(int index=0; index<ALL_POSITIONS; index++)

        {

                string THIS_SYMBOL = OrderSymbol();//PositionGetSymbol(index);

                bool Symbol_already_counted = false;

                for(int i=0; i<SYMBOL_NUMBER_LIMIT; i++)

                {

                        if(COUNTED_SYMBOLS[i]==THIS_SYMBOL)

                        {

                                Symbol_already_counted = true;

                                break;

                        }

                if(Symbol_already_counted) continue;

                else

                {

                        SYMBOLS_IN_TRADE_SO_FAR++;

                        if(SYMBOLS_IN_TRADE_SO_FAR >= SYMBOL_NUMBER_LIMIT)

{

                                NEW_TRADE_PERMISSION = false;

                                break;

                        }

                        for(int j=0; j<SYMBOL_NUMBER_LIMIT; j++)

                        if(COUNTED_SYMBOLS[j]=="")

                        {

                                COUNTED_SYMBOLS[j] = THIS_SYMBOL;

                                break;

                        }

                }

        }

}

 

 }

 
OLUFEMI ODUNUGA:

This is the EA after modification.  It actually compiled and opened 3 pairs. However, once the 3 pairs closed in profit, it does not open another trade again. What I want is for the EA to have not more than 3 pairs opened at any particular time. 

Reason: