Need help, my PositionClose didn't work

zemoda  

Hello,

I don't know why my PositionClose doesn't work :

void crossClose(string symbolName, ENUM_TIMEFRAMES timeframe){

   CTrade trade;
   ulong ticket = getLastTicket(symbolName);
   int signal = getCrossSignal(symbolName, timeframe);
   
   if(PositionSelectByTicket(ticket)){
      
      if(signal == 1 && PositionGetInteger(POSITION_TYPE) == 0) trade.PositionClose(ticket); 
      if(signal == 3 && PositionGetInteger(POSITION_TYPE) == 1) trade.PositionClose(ticket);
   
   }
}

I know my signal 1 and 3 works... If i want make a trade on it that works.

Any idea ?

I tryed 

void crossClose(string symbolName, ENUM_TIMEFRAMES timeframe){

   CTrade trade;
   ulong ticket = getLastTicket(symbolName);
   int signal = getCrossSignal(symbolName, timeframe);
   
   if(PositionSelectByTicket(ticket)){
      
      if(signal == 1 trade.PositionClose(ticket); 
      if(signal == 3 trade.PositionClose(ticket);
   
   }
}

but it's the same :(