Help to correct errors when compiling

 
int OnInit()
  {
   double LotSize(string symbol,datetime tbar)
     {
      double size;
      string BQ,currency=AccountCurrency();
      switch(MarketInfo(symbol,MODE_PROFITCALCMODE))
        {
         case 0:
           {
            int sbar=iBarShift(symbol,0,tbar);
            size=MarketInfo(symbol,MODE_LOTSIZE);
            if(StringSubstr(symbol,3,3)=="USD") break;
            if(StringSubstr(symbol,0,3)=="USD") size=size/iClose(symbol,0,sbar);
            else
              {
               BQ=StringSubstr(symbol,0,3)+"USD";
               if(iClose(BQ,0,0)==0) BQ="USD"+StringSubstr(symbol,0,3);
               if(iClose(BQ,0,0)==0) break;
               int BQbar=iBarShift(BQ,0,tbar);
               if(StringSubstr(BQ,0,3)=="USD") size=size/iClose(BQ,0,BQbar)/iClose(symbol,0,sbar);
               else size=size*iClose(BQ,0,BQbar)/iClose(symbol,0,sbar);
              }
           }
         break;
         case 1: size=MarketInfo(symbol,MODE_LOTSIZE); break;
         case 2: size=MarketInfo(symbol,MODE_TICKVALUE)/MarketInfo(symbol,MODE_TICKSIZE);
        }
      if(currency!="USD")
        {
         BQ=currency+"USD";
         if(iClose(BQ,0,0)==0)
           {
            BQ="USD"+currency;
            size*=iClose(BQ,0,iBarShift(BQ,0,tbar));
           }
         else size/=iClose(BQ,0,iBarShift(BQ,0,tbar));
        }
      return(size);
     }

 

 When compiling two errors:  I do not think what is wrong and how to fix it. Tell me please.

 
your code is broken press Ctrl + , and follow the brackets.
 
Marco vd Heijden:
your code is broken press Ctrl + , and follow the brackets.

Where code is broken? I'm asking you to help fix bugs.

//+------------------------------------------------------------------+
//|                                                   Break Even.mq4 |
//|                                                 Copyright 2016,  |
//|                                         /ru |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, "
#property link      "/ru"
#property version   "1.00"
#property strict
#property indicator_chart_window   
#property indicator_buffers 1
#property indicator_plots   1
//--- plot BreakEven
#property indicator_label1  "BreakEven"    
#property indicator_type1   DRAW_LINE     
#property indicator_color1  clrGold       
#property indicator_style1  STYLE_SOLID  
#property indicator_width1  1
//--- indicator buffers
double         BreakEvenBuffer[];
//+------------------------------------------------------------------+
//| We expect to break even                                          |
//+------------------------------------------------------------------+
int OnInit()
  {
   double LotSize(string symbol,datetime tbar)
     {
      double size;
      string BQ,currency=AccountCurrency();
      switch(MarketInfo(symbol,MODE_PROFITCALCMODE))
        {
         case 0:
           {
            int sbar=iBarShift(symbol,0,tbar);
            size=MarketInfo(symbol,MODE_LOTSIZE);
            if(StringSubstr(symbol,3,3)=="USD") break;
            if(StringSubstr(symbol,0,3)=="USD") size=size/iClose(symbol,0,sbar);
            else
              {
               BQ=StringSubstr(symbol,0,3)+"USD";
               if(iClose(BQ,0,0)==0) BQ="USD"+StringSubstr(symbol,0,3);
               if(iClose(BQ,0,0)==0) break;
               int BQbar=iBarShift(BQ,0,tbar);
               if(StringSubstr(BQ,0,3)=="USD") size=size/iClose(BQ,0,BQbar)/iClose(symbol,0,sbar);
               else size=size*iClose(BQ,0,BQbar)/iClose(symbol,0,sbar);
              }
           }
         break;
         case 1: size=MarketInfo(symbol,MODE_LOTSIZE); break;
         case 2: size=MarketInfo(symbol,MODE_TICKVALUE)/MarketInfo(symbol,MODE_TICKSIZE);
        }
      if(currency!="USD")
        {
         BQ=currency+"USD";
         if(iClose(BQ,0,0)==0)
           {
            BQ="USD"+currency;
            size*=iClose(BQ,0,iBarShift(BQ,0,tbar));
           }
         else size/=iClose(BQ,0,iBarShift(BQ,0,tbar));
        }
      return(size);
     }
//--- indicator buffers mapping
   SetIndexBuffer(0,BreakEvenBuffer);

//---
   return(INIT_SUCCEEDED);
  }
 

it tells you where to look


 
Marco vd Heijden:

it tells you where to look


I know where to look. I do not understand how to correct the mistake, so asked for help.
 

you can't write a function in a function.

LotSize() is in OnInit() 


rest of code looks very strange but i'm not sure if it is wrong...for example after case 0: i think there can not be a "{"

or for example if ended with ";" and then else (not sure if it is wrong but i don't know it this way)

 

There is error, that you define function LotSize not in global scope.

Put it outside of OnInit()

Then modify OnInit

int OnInit()
  {
    ??= LotSize(symbol,tbar);
     
//--- indicator buffers mapping
   SetIndexBuffer(0,BreakEvenBuffer);

//---
   return(INIT_SUCCEEDED);
  }
Reason: