- Creating a ready-made Expert Advisor - MQL4/MQL5 Wizard
- Managing Pending Orders - Trade - MetaTrader 5 for iPhone
- Live Update - For Advanced Users - Getting Started
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.
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;
}
}
}
}
}
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)!
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;
}
}
}
}
}
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.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use