Please, I need help. I Got 3 errors in my codes, but I can't fix them

 
//+------------------------------------------------------------------+
//|                                                      MACD EA.mq5 |
//|                                  Copyright 2022, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//---Declaration of EA Properties
input double               StopLoss      =50;       // Stop Loss in Pips
input double               TakeProfit    =50;       // Take Profit in Pips
input int                  EA_MagicNumber=123406;   // Magic Number
input double               Volume        =0.1;      // Lot Size
input int                  Slippage      =10;
//---Declaration of EA INPUT VARIABLES


// RSI input variables
input int RSI_Period = 14;
input ENUM_APPLIED_PRICE AppliedPrice = PRICE_CLOSE;

// MACD input variables
input int                  FastEMA       =9;
input int                  SlowEMA       =26;
input int                  MacdSMA       =9;
input ENUM_APPLIED_PRICE   AppliedPriceA  =PRICE_CLOSE;

// STOCH input variables
input int KPeriod = 5;
input int SlowingPeriod = 3;
input int Dperiod = 3;
input ENUM_MA_METHOD MA_Method = MODE_SMA;
input ENUM_STO_PRICE PriceField = STO_LOWHIGH;




//---Declaration of other global variables

// RSI global variable

int RSIHandle;
double RSI_Signal[];

// MACD global variable
int MacdHandle;

double MainLine[];
double SignalLine[];

// STOCH global variable
int StocHandle;
double StocMain[];
double StocSignal[];
   
   
double STP;
double TKP;
datetime m_prev_bars               =0;        // "0" -> D'1970.01.01 00:00';
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---Getting the Indicator handle

// RSI handle
  RSIHandle = iRSI(_Symbol,PERIOD_CURRENT,RSI_Period,AppliedPrice);
//--- checking if valid handle is obtained
   if(RSIHandle<0)
     {
      Alert("Error obtaining indicator handle. Error: ",GetLastError());
      return(INIT_FAILED);
     }
     
// MACD handle
   MacdHandle=iMACD(Symbol(),PERIOD_CURRENT,FastEMA,SlowEMA,MacdSMA,AppliedPriceA);
//--- checking if valid handle is obtained
   if(MacdHandle<0)
     {
      Alert("Error obtaining indicator handle. Error: ",GetLastError());
      return(INIT_FAILED);
     }

// STOCH handle
   StocHandle=iStochastic(Symbol(),PERIOD_CURRENT,KPeriod,Dperiod,SlowingPeriod,MA_Method,PriceField);
//--- checking if valid handle is obtained
   if(StocHandle<0)
     {
      Alert("Error obtaining indicator handle. Error: ",GetLastError());
      return(INIT_FAILED);
     }



     
//--- standardizing the currency digits
   STP=StopLoss*Point();
   TKP=TakeProfit*Point();
   if(Digits() == 5 || Digits() == 3)
     {
      STP=STP*10.0;
      TKP=TKP*10.0;
     }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- releasing indicator handle
   IndicatorRelease(RSIHandle);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- we work only at the time of the birth of new bar
   datetime time_0=iTime(Symbol(),Period(),0);
   if(time_0==m_prev_bars)
      return;
   m_prev_bars=time_0;
//--- checking if we have open trades
   if(PositionsTotal()>0)
      return;
//---
// defining MQL structures to be used for trading
   MqlTick latest_price;            //To be used to get the latest price information
   MqlTradeRequest mrequest;        //To be used in send trade requeste
   MqlTradeResult mresult;          //To be used in accessing trade results
   ZeroMemory(mrequest);
//---
   //double MainLine[];
   //double SignalLine[];
//--- setting our arrays to the as series flag

// RSI arrays series
   ArraySetAsSeries(RSI_Signal,true);
   
// MACD arrays series
   ArraySetAsSeries(MainLine,true);
   ArraySetAsSeries(SignalLine,true);
   
// STOCH arrays series
   ArraySetAsSeries(StocMain,true);
   ArraySetAsSeries(StocSignal,true);

//--- checking if we have the latest price quote
   if(!SymbolInfoTick(Symbol(),latest_price))
     {
      Alert("Error getting latest price quote. Error: ",GetLastError());
      m_prev_bars=0;
      return;
     }
     
//--- copy and check indicator values
   if((CopyBuffer(RSIHandle,0,0,3,RSI_Signal)!=3) || (CopyBuffer(MacdHandle,0,0,3,MainLine)!=3) || (CopyBuffer(MacdHandle,1,0,3,SignalLine)!=3) || (CopyBuffer(StocHandle,0,0,3,StocMain)!=3)  (CopyBuffer(StocHandle,1,0,3,StocSignal)!=3))
     {
      Alert("Error copying the indicator buffers. Error: ",GetLastError());
      m_prev_bars=0;
      return;
     }
//--- buy position condition
   if((RSI_Signal[0]<30) && (MainLine[1]>SignalLine[1]) && (MainLine[0]<SignalLine [0]) && (StocMain[1]>StocSignal[1]) && (StocMain[0]<StocSignal [0]))
      mrequest.action=TRADE_ACTION_DEAL;
      mrequest.price=NormalizeDouble(latest_price.ask,Digits());
      mrequest.sl=NormalizeDouble(latest_price.ask - STP,Digits());
      mrequest.tp=NormalizeDouble(latest_price.ask + TKP,Digits());
      mrequest.symbol=Symbol();
      mrequest.volume=Volume;
      mrequest.magic=EA_MagicNumber;
      mrequest.type=ORDER_TYPE_BUY;
      mrequest.type_filling=ORDER_FILLING_FOK;
      mrequest.deviation=Slippage;
      bool result=OrderSend(mrequest,mresult);
      //---Getting the trade results
      if(mresult.retcode == 10009 || mresult.retcode == 10008)
        {
         Alert("A buy order has been successfully placed with ticket# :",mresult.order,"!!");
        }
      else
        {
         Alert("A buy order could not be placed - Error: ",GetLastError());
        }
     }
//--- sell position condition
   if((RSI_Signal[0]>70) && (MainLine[1]<SignalLine[1]) && (MainLine[0]>SignalLine [0]) && (StocMain[1]<StocSignal[1]) && (StocMain[0]>StocSignal [0]))
     {
      mrequest.action=TRADE_ACTION_DEAL;
      mrequest.price=NormalizeDouble(latest_price.bid,Digits());
      mrequest.sl=NormalizeDouble(latest_price.bid + STP,Digits());
      mrequest.tp=NormalizeDouble(latest_price.bid - TKP,Digits());
      mrequest.symbol=Symbol();
      mrequest.volume=Volume;
      mrequest.magic=EA_MagicNumber;
      mrequest.type=ORDER_TYPE_SELL;
      mrequest.type_filling=ORDER_FILLING_FOK;
      mrequest.deviation=Slippage;
      bool result=OrderSend(mrequest,mresult);
      //---Getting the trade results
      if(mresult.retcode == 10009 || mresult.retcode == 10008)
        {
         Alert("A sell order has been successfully placed with ticket# :",mresult.order,"!!");
        }
      else
        {
         Alert("A sell order could not be placed - Error: ",GetLastError());
        }
     }
  }
//+------------------------------------------------------------------+
 
Chinwendu Evans:

how do you expect help if you don't say what the errors are...

 
Oh! Sorry about that. Attached is a screenshot of the error messages I got

Files:
 
  1. Don't post pictures of code or error message; just post the error message.
  2. Not allowed on global scope means you have too many closing brackets above that line.
  3.    if((RSI_Signal[0]<30) && (MainLine[1]>SignalLine[1]) && (MainLine[0]<SignalLine [0]) && (StocMain[1]>StocSignal[1]) && (StocMain[0]<StocSignal [0]))
          mrequest.action=TRADE_ACTION_DEAL;
          mrequest.price=NormalizeDouble(latest_price.ask,Digits());
    The if statement only applies to the action.
 
Chinwendu Evans:

1. Line 188 - You have an extra bracket on line 188 which prematurely ends the OnTick() function and excludes subsequent lines [as mentioned by William above]

2. Line 160 - you are missing a logic operator for the last term - it should be  (CopyBuffer(StocHandle,0,0,3,StocMain)!=3) || (CopyBuffer(StocHandle,1,0,3,StocSignal)!=3)) 

3. Line 202 - You have a warning "declaration of 'result' hides local variable" - you could remove the bool re-declaration and use the existing variable


If you have not done so already, switch on and learn how to use bracket matching as that is usually the most tricky error to resolve - the others are straightforward once the brackets are corrected

 
 
R4tna C #:

1. Line 188 - You have an extra bracket on line 188 which prematurely ends the OnTick() function and excludes subsequent lines [as mentioned by William above]

2. Line 160 - you are missing a logic operator for the last term - it should be  (CopyBuffer(StocHandle,0,0,3,StocMain)!=3) || (CopyBuffer(StocHandle,1,0,3,StocSignal)!=3)) 

3. Line 202 - You have a warning "declaration of 'result' hides local variable" - you could remove the bool re-declaration and use the existing variable


If you have not done so already, switch on and learn how to use bracket matching as that is usually the most tricky error to resolve - the others are straightforward once the brackets are corrected

 
Thanks you very much. This was helpful. I have fixed the error. I really appreciate. 
 
William Roeder #:
  1. Don't post pictures of code or error message; just post the error message.
  2. Not allowed on global scope means you have too many closing brackets above that line.
  3. The if statement only applies to the action.
Thanks for your reply. You have exposed me to something new. Thank you