Trading multiple pairs using symbol function (MT3).

 
Hello,

I have pasted below a simple code for trading multiple pairs using symbol function . And something is wrong there when opening trade.
I had some examples of experts advisors with symbol function, but due to lost some of files and data, i don't have it anymore. Maybe someone just could paste a templet of their own.
About two weeks i was trying , and still no good results. I would extremely be thankful for any help.
Thank You.
//shift
/*[[
	Name := nb
	Author := 
	Link := 
	Notes := 
	Lots := 1
	Stop Loss := 100
	Take Profit := 100
	Trailing Stop := 0
]]*/
Defines:risk(5),ff(2), cl(3),vl(6),cnt(0);
var: histo2(0),lotsi(0),slippage(0),i(0),H2(0),;

lotsi=Ceil((Balance*risk*PriceAsk)/100000);

histo2=iMAEx(cl,MODE_EMA,0,PRICE_OPEN,0)-iMAEx(vl,MODE_EMA,0,PRICE_OPEN,0);

H2=histo2/point;

for cnt=1 to TotalTrades
{
If Symbol = OrderValue(cnt,VAL_SYMBOL) then {
if  H2<-ff  then {
for i=1 to TotalTrades {
	if ord(i,VAL_TYPE)=OP_SELL then
		CloseOrder(ord(i,VAL_TICKET),ord(i,VAL_LOTS),ask,slippage,FireBrick)
	else if ord(i,VAL_TYPE)=OP_SELLSTOP then
		DeleteOrder(ord(i,VAL_TICKET),red);
};
if TotalTrades<1  then {
    SetOrder(OP_BUY,lotsi,ask,Slippage,ask-StopLoss*point,ask+TakeProfit*Point,SkyBlue);
    };
};
 
if  H2>ff  then {
for i=1 to TotalTrades {
	if ord(i,VAL_TYPE)=OP_BUY then
		CloseOrder(ord(i,VAL_TICKET),ord(i,VAL_LOTS),bid,slippage,Gray)
	else if ord(i,VAL_TYPE)=OP_BUYSTOP then
		DeleteOrder(ord(i,VAL_TICKET),red);
};
if TotalTrades<1   then {
    SetOrder(OP_SELL,lotsi,bid,Slippage,bid+StopLoss*point,bid-TakeProfit*Point,white);
    };
};
};};

Reason: