My code has these two errors, can anyone help?

 

}' - unexpected end of program and '{' - unbalanced parentheses

Auto-translation applied by moderator.

Files:
 
  1. int OnInit()
      {
       Ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
       meutrade.Buy(0.01, _Symbol, Ask, Ask - (200 * _Point), 0);

    Do you really want to open an order every time you change symbol or timeframe, compile, restart the terminal, etc.?

  2. You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.

    1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

    2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close at a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

    3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)

      Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes.
      My GBPJPY shows average spread = 26 points, average maximum spread = 134.
      My EURCHF shows average spread = 18 points, average maximum spread = 106.
      (your broker will be similar).
                Is it reasonable to have such a huge spreads (20 PIP spreads) in EURCHF? - General - MQL5 programming forum (2022)

  3. Don't try to use any price (or indicator) or server related functions in OnInit (or on load or in OnTimer before you've received a tick), as there may be no connection/chart yet:
    1. Terminal starts.
    2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
    3. OnInit is called.
    4. For indicators OnCalculate is called with any existing history.
    5. Human may have to enter password, connection to server begins.
    6. New history is received, OnCalculate called again.
    7. A new tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.

    Unlike indicators, EAs are not reloaded on chart change, so you must reinitialize them, if necessary.
              external static variable - MQL4 programming forum #2 (2013)

  4. if(PositionGetDouble(POSITION_PRICE_CURRENT) > PositionGetDouble(POSITION_PRICE_OPEN) + (InputDistancia * _Point)) // Calcula se excedeu a distância para mover o SL
               {
                meutrade.PositionModify(PositionGetTicket(i), PositionGetDouble(POSITION_PRICE_OPEN, 0);

    You are repeatedly modifying the position every tick.  ERR_NO_RESULT

    You Server
    Change the SL to X It is at X!
    Change the SL to X It is at X!
    Change the SL to X You are insane

    Insanity: doing the same thing over and over again and expecting different results.
              Unknown

    Compute the new value, then check that you are moving the existing value at least a tick (in the currect direction).
              What is a TICK? - MQL4 programming forum (2014)

  5. alefyinacio: }' - unexpected end of program and '{' - unbalanced parentheses
    void OnTick()
     {
      
     for(int i = PositionsTotal(); i>= 0; i--) // Cataloga todas as operações da conta
      {
       if(PositionGetSymbol(i) == _Symbol)  // Filtra pelo ativo atual
         {
          //==== COMPRA ====
          if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY)  // Filtra somente operações de compra
            {…}
          //==== VENDA ====
          if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)  // Filtra somente operações de VENDA
            {…} // Filtra somente operações de VENDA
         }      // Filtra pelo ativo atual
      }         // Cataloga todas as operações da conta
    //+------------------------------------------------------------------+
    <<<<<<< Where is the end of OnTick?
 
William Roeder #:
  1. Do you really want to open an order every time you change symbol or timeframe, compile, restart the terminal, etc.?

  2. You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.

    1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

    2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close at a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

    3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)

      Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes.
      My GBPJPY shows average spread = 26 points, average maximum spread = 134.
      My EURCHF shows average spread = 18 points, average maximum spread = 106.
      (your broker will be similar).
                Is it reasonable to have such a huge spreads (20 PIP spreads) in EURCHF? - General - MQL5 programming forum (2022)

  3. Don't try to use any price (or indicator) or server related functions in OnInit (or on load or in OnTimer before you've received a tick), as there may be no connection/chart yet:
    1. Terminal starts.
    2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
    3. OnInit is called.
    4. For indicators OnCalculate is called with any existing history.
    5. Human may have to enter password, connection to server begins.
    6. New history is received, OnCalculate called again.
    7. A new tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.

    Unlike indicators, EAs are not reloaded on chart change, so you must reinitialize them, if necessary.
              external static variable - MQL4 programming forum #2 (2013)

  4. You are repeatedly modifying the position every tick.  ERR_NO_RESULT

    You Server
    Change the SL to X It is at X!
    Change the SL to X It is at X!
    Change the SL to X You are insane

    Compute the new value, then check that you are moving the existing value at least a tick (in the currect direction).
              What is a TICK? - MQL4 programming forum (2014)

I think this quote

Insanity: doing the same thing over and over again and expecting different results.

Was from Albert Einstein, though translated from German to English.

While the translation of "Wahnsinn" is Insanity, the understood meaning of "Wahnsinn" is not as strong in it's expression as the word "Insanity" is in English. It is more located between "Crazy" and "Insane", if it were on a scale.