set max numer of open orders for Id

 

Hi,

this is my first post...this is a really great community..I'm news in MQL, but not in Forex. So i want ask if someone can tell me How I can tell to my expert, after the "8th" opened orders, don'open more orders, but i don't want that it close all the previuos one, all ordres have to reach stop and take profit, but i want only 8 orders for ID or currency pairs.

Thanks in advance, usually i read all the forum topic before to ask, but i din't find nothing usuful for this.

Bye

Thank

Giuseppe

 
pengiu wrote >>

Hi,

this is my first post...this is a really great community..I'm news in MQL, but not in Forex. So i want ask if someone can tell me How I can tell to my expert, after the "8th" opened orders, don'open more orders, but i don't want that it close all the previuos one, all ordres have to reach stop and take profit, but i want only 8 orders for ID or currency pairs.

Thanks in advance, usually i read all the forum topic before to ask, but i din't find nothing usuful for this.

Bye

Thank

Giuseppe

you need to loop over your open orders and count them ...

if 8 or more open, dont open a new one ...

int hasbuy=0;

int hassell=0;

for(int i=OrdersTotal()-1; i>=0; i--)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol()&&OrderMagicNumber() == MagicN)
{
if (OrderType()==OP_BUY)
{
hasbuy++;
}
if (OrderType()==OP_SELL)
{
hassell++;

}

}

}

 

thanks so much.

bye