Помогите найти ошибку

 

Всем привет!

Не понимаю где ошибка" 'for' - expressions are not allowed on a global scope и  'int' - semicolon expected Poprigunchik.mq4"

#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

extern int TakeP = 150; //Тейк Профит
extern int StopL = 300; //Стоп Лосс
extern int Slip  = 50;  //Проскальзывание
extern double Lot= 0.01;//Лот
extern int Magik = 227; //Идентификатор
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   int open = MessageBox("Запустить робота?","Внимание!",MB_YESNO|MB_ICONQUESTION);
     if(open==7)
     return(INIT_FAILED);
     
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
//  if(OrderCount() == 0)
//   {
   double bar = (iOpen(_Symbol,PERIOD_M15,1)-iClose(_Symbol,PERIOD_M15,1))/Point;
   
    if(OrderCount() == 0)
   {  
      if(bar > 150 && bar < 250)
        {
         if(OrderSend(_Symbol,OP_BUY,Lot,Ask,Slip,NormalizeDouble(Ask+StopL*Point,Digits),NormalizeDouble(Bid-TakeP*Point,Digits),"",Magik,0,Green)>-1)
         Print ("Открыта позиция Buy!");
        }
// Продажа        
      if(bar > -150 && bar < -250)
        {
         if(OrderSend(_Symbol,OP_SELL,Lot,Bid,Slip,NormalizeDouble(Bid-StopL*Point,Digits),NormalizeDouble(Ask+TakeP*Point,Digits),"",Magik,0,Green)>-1)
         Print ("Открыта позиция Sell!");
        }
   }
 
}    
//+------------------------------------------------------------------+
// Счетчик позиций 
//+------------------------------------------------------------------+
int OrderCount()
    int Count = 0;
    
    for(int i=OrderSelect(); i >= 0; i--)
      {
       if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         {
         if(OrderSymbol()== Symbol() && OrderMagicNumber()== Magik)
            {
             Count++;
            }
         }
      }


Файлы:
 
Cav1ty IM:

Всем привет!

Не понимаю где ошибка" 'for' - expressions are not allowed on a global scope и  'int' - semicolon expected Poprigunchik.mq4"

Нет фигурных скобок у тела функции OrderCount().

 
Спасибо!