Problem with EA when compiling

 

This is my first EA, but after a long time spent searching for an error I could't find anything. If you can help me find it i'll be forever grateful.

The compiler gives me errors like:

'=' - Illegal Assignment Used 

'0' - Unexpected Token

'&&' - Assignment expected 

Please help

Thank You 


//EXTERN VARIABLES

extern double FLotSZ = 0.01;
extern bool DeboLotSZ = true;
extern double PatPct = 2.5;
extern int Slippage = 2;
extern int StopLoss = 50;
extern int TakeProfit = 100;
extern bool DeboTP = false;
extern bool DeboSL = true;
extern int barsSL = 4;
extern int N_Period = 8;
extern int MagicNumber = 123;

//GLOBAL VARIABLES


int BuyTicket;
int SellTicket;
int UseSlippage;
double UsePoint;


//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+

int init()
  {
   UsePoint = PipPoint(Symbol());
   UseSlippage = GetSlippage(Symbol(), Slippage);
  }


//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+

int deinit()
  {
 
//----
   
//----

   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   //Calculando Lot Size
   double LotSZ = VLotSZ(DeboLotSZ, PatPct, StopLoss, FLotSZ);
   LotSZ = VerifyLotSZ(LotSZ);
   
   //Custom Indicator Function
   double TendUp = iCustom(NULL,0,"SuperTrend-signals",N_Period,false,8,8,8,8,8,8,8,8,8,0,0);    
   double TendDown = iCustom(NULL,0,"SuperTrend-signals",N_Period,false,8,8,8,8,8,8,8,8,8,1,0); 

   int Tendencia = Trend(TendUp,TendDown);
   
   //Buy Order
   if(Tendencia = 0 && BuyTicket == 0)
    {
     BuyTicket = OpenBuyOrder(Symbol(),LotSZ,UseSlippage,MagicNumber);
     
     if(BuyTicket>0 && (StopLoss > 0 || TakeProfit >0))
      {
       OrderSelect(BuyTicket,SELECT_BY_TICKET);
       double OpenPrice = OrderOpenPrice();
       
       double BuySL = CalcBuySL(Symbol(), StopLoss, OpenPrice);
       if(BuySL>0)
        {
         BuySL = AdjustBelowStopLevel(Symbol(),BuySL,5);
        }
          
       double BuyTP = CalcBuyTP(Symbol(), TakeProfit, OpenPrice);
       if(BuyTP>0)
        {
         BuyTP = AdjustAboveStopLevel(Symbol(), BuyTP, 5);
        }
         
      }  
    }
     
    //Sell Order
    if(Tendencia=1 && SellTicket == 0)
    {
     SellTicket = OpenSellOrder(Symbol(),LotSZ,UseSlippage,MagicNumber);
     
     if(SellTicket>0 && (StopLoss > 0 || TakeProfit >0))
      {
       OrderSelect(SellTicket,SELECT_BY_TICKET);
       OpenPrice = OrderOpenPrice();
       
       double SellSL = CalcSellSL(Symbol(), StopLoss, OpenPrice);
       if(SellSL>0)
        {
         SellSL = AdjustBelowStopLevel(Symbol(),SellSL,5);
        }
          
       double SellTP = CalcSellTP(Symbol(), TakeProfit, OpenPrice);
       if(SellTP>0)
        {
         SellTP = AdjustAboveStopLevel(Symbol(), SellTP, 5);
        }
         
      }  
    }
     
    //Close Buy
    if(BuyTicket>0 && Tendencia=1) int Closed = CloseBuyOrder(Symbol(),BuyTicket, Slippage);
    BuyTicket = 0;
    
    //Close Sell
    if(SellTicket>0 && Tendencia=0) Closed = CloseSellOrder(Symbol(),SellTicket, Slippage);
    SellTicket = 0;
    
          
   return(0);
  }
//+------------------------------------------------------------------+
//| Functions
//+------------------------------------------------------------------+

//PipPoint Function

double PipPoint(string Currency)
  {
   int CalcDigits = MarketInfo(Currency,MODE_DIGITS);
   if(CalcDigits == 2 || CalcDigits == 3) double CalcPoint = 0.01;
   else if(CalcDigits == 4 || CalcDigits == 5) CalcPoint = 0.0001;
   return(CalcPoint);
  }
  
//GetSlippage Function

int GetSlippage(string Currency, int SlippagePips)
  {
   int CalcDigits = MarketInfo(Currency,MODE_DIGITS);
   if(CalcDigits == 2 || CalcDigits == 3)double CalcSlippage = SlippagePips;
   else if(CalcDigits == 4 || CalcDigits == 5)CalcSlippage = SlippagePips * 10;
   return (CalcSlippage);
  }
  
//Lot Size Function

double VLotSZ(bool argDeboLotSZ, double argPatPct, double argStopLoss, double argFLotSZ)
  {
   if(DeboLotSZ == true)
    {
     double Risktotal = AccountEquity() * (PatPct/100);
     double Tickvalue = MarketInfo(Symbol(),MODE_TICKVALUE);
     if(Point == 0.001 || Point == 0.00001) Tickvalue *= 10;
     double NLotSZ = (Risktotal/StopLoss)/Tickvalue;
    }
   else NLotSZ = FLotSZ;
   return (NLotSZ);
  }
  
//Verify Lot Size Function

double VerifyLotSZ(double argLotSZ)
  {
   if(argLotSZ < MarketInfo(Symbol(),MODE_MINLOT))
    {
     argLotSZ = MarketInfo(Symbol(), MODE_MINLOT);
    }
   else if(argLotSZ > MarketInfo(Symbol(), MODE_MAXLOT))
         {
          argLotSZ = MarketInfo(Symbol(), MODE_MAXLOT);  
         } 
        if(MarketInfo(Symbol(), MODE_LOTSTEP)==0.1)
         {      
          argLotSZ = NormalizeDouble(argLotSZ,1);
         } 
        else argLotSZ = NormalizeDouble(argLotSZ,2);
  
   return(argLotSZ);
  }  
      
//Buy Order

int OpenBuyOrder(string argSymbol, double argLotSZ, double argSlippage, double argMagicNumber, string argComment = "Buy Order")
  {
   while(IsTradeContextBusy()) Sleep(10);
   
   //Colocar Buy Order
   
   int Ticket = OrderSend(argSymbol, OP_BUY, argLotSZ, MarketInfo(argSymbol, MODE_ASK), argSlippage, 0, 0, argComment, argMagicNumber, 0, GreenYellow);
   
   //Error Buy 
   
   if(Ticket == -1)
    {
     int ErrorCode = GetLastError();
          
     string ErrAlert = StringConcatenate("Open Buy Order - Error ", ErrorCode);
     Alert(ErrAlert);
     
     string ErrLog = StringConcatenate("Bid: ",MarketInfo(argSymbol,MODE_BID),"Ask: ",MarketInfo(argSymbol,MODE_ASK)," Lots: ",argLotSZ);
     Print(ErrLog);
    }
    
    return(Ticket);
  }
   
//Sell Order

int OpenSellOrder(string argSymbol, double argLotSZ, double argSlippage, double argMagicNumber, string argComment = "Sell Order")
  {
   while(IsTradeContextBusy()) Sleep(10);
   
   //Colocar Sell Order
   
   int Ticket = OrderSend(argSymbol, OP_SELL, argLotSZ, MarketInfo(argSymbol, MODE_BID), argSlippage, 0, 0, argComment, argMagicNumber, 0, DeepPink);
   
   //Error Sell
   
   if(Ticket == -1)
    {
     int ErrorCode = GetLastError();
         
     string ErrAlert = StringConcatenate("Open Sell Order - Error ", ErrorCode);
     Alert(ErrAlert);
     
     string ErrLog = StringConcatenate("Bid: ",MarketInfo(argSymbol,MODE_BID),"Ask: ",MarketInfo(argSymbol,MODE_ASK)," Lots: ",argLotSZ);
     Print(ErrLog);
    }
    
    return(Ticket);
  }
   
//Cerrar Buy Order

bool CloseBuyOrder(string argSymbol, int argCloseTicket, double argSlippage)
  {
   OrderSelect(argCloseTicket,SELECT_BY_TICKET);
   
   if(OrderCloseTime() == 0)
    {
     double CloseLots = OrderLots();
     
     while(IsTradeContextBusy()) Sleep(10);
     
     double ClosePrice = MarketInfo(argSymbol,MODE_ASK);
     
     bool Closed = OrderClose(argCloseTicket,CloseLots,ClosePrice,argSlippage,Blue);
     
     if(Closed == false)
      {
       int ErrorCode = GetLastError();
              
       string ErrAlert = StringConcatenate("Close Buy Order - Error: ",ErrorCode);
       Alert(ErrAlert);
       
       string ErrLog = StringConcatenate("Ticket: ",argCloseTicket,"Ask: ",MarketInfo(argSymbol,MODE_ASK));
       Print(ErrLog);
      }
    }
    return(Closed);
  }   
 
//Cerrar Sell Order

bool CloseSellOrder(string argSymbol, int argCloseTicket, double argSlippage)
  {
   OrderSelect(argCloseTicket,SELECT_BY_TICKET);
   
   if(OrderCloseTime() == 0)
    {
     double CloseLots = OrderLots();
     
     while(IsTradeContextBusy()) Sleep(10);
     
     double ClosePrice = MarketInfo(argSymbol,MODE_BID);
     
     bool Closed = OrderClose(argCloseTicket,CloseLots,ClosePrice,argSlippage,Red);
     
     if(Closed == false)
      {
       int ErrorCode = GetLastError();
            
       string ErrAlert = StringConcatenate("Close Sell Order - Error: ",ErrorCode);
       Alert(ErrAlert);
       
       string ErrLog = StringConcatenate("Ticket: ",argCloseTicket,"Bid: ",MarketInfo(argSymbol,MODE_BID));
       Print(ErrLog);
      }
    }
    return(Closed);
  }  
      
//Buy Stop Loss en Pips

double CalcBuySL(string argSymbol, int argStopLoss, double argOpenPrice)
  {
   if(argStopLoss == 0) return(0);
   double BuyStopLoss = argOpenPrice - (argStopLoss * PipPoint(argSymbol));
   return(BuyStopLoss);
  }
  
//Sell Stop Loss en Pips

double CalcSellSL(string argSymbol, int argStopLoss, double argOpenPrice)
  {
   if(argStopLoss == 0) return(0);
   double SellStopLoss = argOpenPrice + (argStopLoss * PipPoint(argSymbol));
   return(SellStopLoss);
  } 
  
//Buy Take Profit en Pips

double CalcBuyTP(string argSymbol, int argTakeProfit, double argOpenPrice)
  {
   if(argTakeProfit == 0) return(0);
   double BuyTakeProfit = argOpenPrice + (argTakeProfit * PipPoint(argSymbol));
   return(BuyTakeProfit);
  }      
  
//Sell Take Profit en Pips

double CalcSellTP(string argSymbol, int argTakeProfit, double argOpenPrice)
  {
   if(argTakeProfit == 0) return(0);
   double SellTakeProfit = argOpenPrice - (argTakeProfit * PipPoint(argSymbol));
   return(SellTakeProfit);
  }           
 
//VerificaciÛn Stop Level Above

double AdjustAboveStopLevel(string argSymbol, double argAdjustPrice, int argAddPips = 0, double argOpenPrice = 0)
  {
   double StopLevel = MarketInfo(argSymbol,MODE_STOPLEVEL)*Point;
   
   if(argOpenPrice == 0) double OpenPrice = MarketInfo(argSymbol,MODE_ASK);
   else OpenPrice = argOpenPrice;
   
   double UpperStopLevel = OpenPrice + StopLevel;
   if(argAdjustPrice<=UpperStopLevel)
    {
     double AdjustedPrice = UpperStopLevel + (argAddPips * PipPoint(argSymbol));
    }
   else AdjustedPrice = argAdjustPrice;
   
   return(AdjustedPrice);
  }   
     
 
//VerificaciÛn Stop Level Below

double AdjustBelowStopLevel(string argSymbol, double argAdjustPrice, int argAddPips = 0, double argOpenPrice = 0)
  {
   double StopLevel = MarketInfo(argSymbol,MODE_STOPLEVEL)*Point;
   
   if(argOpenPrice == 0) double OpenPrice = MarketInfo(argSymbol,MODE_BID);
   else OpenPrice = argOpenPrice;
   
   double LowerStopLevel = OpenPrice - StopLevel;
   if(argAdjustPrice<=LowerStopLevel)
    {
     double AdjustedPrice = LowerStopLevel - (argAddPips * PipPoint(argSymbol));
    }
   else AdjustedPrice = argAdjustPrice;
   
   return(AdjustedPrice);
  }   
 
  
//Custom Indicator

double Trend(double argTendUp, double argTendDown)
  {
   if(argTendUp != EMPTY_VALUE && argTendDown == EMPTY_VALUE)return(0);
   return(1);  
  }   
 
 
if(Tendencia == 0
 
Thank you very much, Now it works just fine!!