2 verflixte Fehlermeldungen wollen nicht weg gehen

 

Liebe Community,

ich habe den ganzen Tag damit verbracht, einen Code in MetaEditor zu hinterlegen, aber 2 Fehlermeldungen bleiben sehr beharrlich.

Die Fehlermeldungen lauten wie folgt: '{' - unexpected end of program ( Zeile 106 Spalte 48/ '{' - unbalanced parentheses (Zeile 79 Spalte 1)

Ich habe alles versucht, um diese Fehlermeldungen zu eliminieren, aber ich habe es einfach nicht geschafft. Daher wende ich mich jetzt an euch: Hat jemand eine Idee woran es liegen könnte? 


Freundliche Grüße


//+------------------------------------------------------------------+

//|                                                   Indicators.mq4 |

//|                                  Copyright 2023, MetaQuotes Ltd. |

//|                                             https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2023, MetaQuotes Ltd."

#property link      "https://www.mql5.com"

#property version   "1.00"

#property strict

#property indicator_chart_window


//--- input parameters

input color    Color=clrYellow;

input bool     Input1=false;

input short    Input2=800;

input ushort   Input3=800;

input string   Input4="(1/0)";


// Declare input parameters

extern double LotSize = 1.0;

extern int MovingAveragePeriod = 20;

extern double StopLossPips = 20.0;

extern double TakeProfitPips = 40.0;


// Declare global variables

double MovingAverageBuffer[];

double LastTradePrice;

int LastTradeDirection;

int LastTradeBar;


//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit()

{

    //--- indicator buffers mapping

    

    // Resize the moving average buffer

    ArrayResize(MovingAverageBuffer, Bars - MovingAveragePeriod + 1);


    // Calculate the moving average

    for (int i = 0; i < Bars - MovingAveragePeriod + 1; i++)

    {

        double sum = 0.0;

        for (int j = i; j < i + MovingAveragePeriod; j++)

        {

            sum += Close[j];

        }

        MovingAverageBuffer[i] = sum / MovingAveragePeriod;

    }


    return(INIT_SUCCEEDED);

}


//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

{

    //--- 


    //--- return value of prev_calculated for next call

    return(rates_total);

}


//+------------------------------------------------------------------+

//| Handle the tick event                                            |

//+------------------------------------------------------------------+

void OnTick()

{

    // Get the current price

    double currentPrice = Bid;


    // Check if the last trade was a buy

    if (LastTradeDirection == 1)

    {

        // Check if the price has crossed below the moving average

        if (currentPrice < MovingAverageBuffer[LastTradeBar])

        {

            // Place a sell order at the current price

            double stopLoss = currentPrice + StopLossPips * Point;

            double takeProfit = currentPrice - TakeProfitPips * Point;

            OrderSend(Symbol(), OP_SELL, LotSize, currentPrice, 0, stopLoss, takeProfit, "Sell order", 0, 0, Red);

            LastTradeDirection = -1;

            LastTradePrice = currentPrice;

            LastTradeBar = Bars - 1;

        }

    }

    // Check if the last trade was a sell

    else if (LastTradeDirection == -1)

    {

        // Check if the price has crossed above the moving average

        if (currentPrice > MovingAverageBuffer[LastTradeBar])

        {

            // Place a buy order at the current price

            double stopLoss = currentPrice - StopLossPips * Point;

            double takeProfit = currentPrice + Take

 

Bitte den Code Deiner Meldung als Code formatieren, entweder mit Alt+S oder Mausklick auf .

Prüf doch vorher die Klammern, in der Fehlermeldung steht auch welcher Klammer das schließende Pendant fehlt.

 
Carl Schreiber #:

Bitte den Code Deiner Meldung als Code formatieren, entweder mit Alt+S oder Mausklick auf .

Prüf doch vorher die Klammern, in der Fehlermeldung steht auch welcher Klammer das schließende Pendant fehlt.

Moderne IDE's weisen ein mit Tooltips auf die Stelle hin, mit der "Fix-Option" ist es nur ein Klick


Schade, dass MetaQuotes so was nicht für wichtig hält. Es gibt Gründe, warum es fast alle so machen.

Verstehe diese Firma nicht.

 
Tldr. OP könntest du vielleicht mit gelb die Stelle markieren, wo Zeile 79 ist? Und vielleicht auch den Post ändern und Code mit dem Code Button einfügen?
Wenn man sowas hingerotzt bekommt hat keiner Lust sich das auch nur durchzulesen. Viel Glück.
 

Naja, was ist das? Oncalculate und ontick in einem code kann nicht funken


das eine ist ein ea, das andere ein indikator

 
Die OnTick() hört mitten drin auf. Scheint so, als müsste die einfach raus.
 
Anja Vivia Vogel #:
Die OnTick() hört mitten drin auf. Scheint so, als müsste die einfach raus.

Hallo Leute vielen Dank für eure Unterstützung.

Es gibt nun insgesamt 37 geöffnete und 37 geschlossene Klammern jetzt müsste es doch passen richtig? 


//+------------------------------------------------------------------+
//| MyStrategy.mq4                                                   |
//| Copyright 2023, MetaQuotes Ltd.                                   |
//| https://www.mql5.com                                              |
//+------------------------------------------------------------------+

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

//--- input parameters
input color Color=clrYellow;
input bool  Input1=false;
input short Input2=800;
input ushort Input3=800;
input string Input4="(1/0)";

// Declare input parameters
extern double LotSize = 1.0;
extern int MovingAveragePeriod = 20;
extern double StopLossPips = 20.0;
extern double TakeProfitPips = 40.0;

// Declare global variables
double MovingAverageBuffer[];
double LastTradePrice;
int LastTradeDirection;
int LastTradeBar;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   //--- indicator buffers mapping
   
   // Resize the moving average buffer
   ArrayResize(MovingAverageBuffer, Bars - MovingAveragePeriod + 1);
   
   // Calculate the moving average
   for (int i = 0; i < Bars - MovingAveragePeriod + 1; i++)
   {
      double sum = 0.0;
      for (int j = i; j < i + MovingAveragePeriod; j++)
      {
         sum += Close[j];
      }
      MovingAverageBuffer[i] = sum / MovingAveragePeriod;
   }
   
   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   //---
   
   //--- return value of prev_calculated for next call
   return(rates_total);
}

//+------------------------------------------------------------------+
//| Handle the tick event                                            |
//+------------------------------------------------------------------+
void OnTick()
   // Get the current price
   double currentPrice = Bid;

   // Check if the last trade was a buy
   if (LastTradeDirection == 1)
   {
      // Check if the price has crossed below the moving average
      if (currentPrice < MovingAverageBuffer[LastTradeBar])
      {
         // Place a sell order at the current price
         double stopLoss = currentPrice + StopLossPips * Point;
         double takeProfit = currentPrice - TakeProfitPips * Point;
         OrderSend(Symbol(), OP_SELL, LotSize, currentPrice, 0, stopLoss,
                   takeProfit, "Sell order", 0, 0, Red);
         LastTradeDirection = -1;
         LastTradePrice = currentPrice;
         LastTradeBar = Bars - 1;
      }
   }
   // Check if the last trade was a sell
   else if (LastTradeDirection == -1)
   {
      // Check if the price has crossed above the moving average
      if (currentPrice > MovingAverageBuffer[LastTradeBar])
      {
         // Place a buy order at the current price
         double stopLoss = currentPrice

Descubra las nuevas posibilidades de MetaTrader 5 con la comunidad y los servicios MQL5
Descubra las nuevas posibilidades de MetaTrader 5 con la comunidad y los servicios MQL5
  • 2023.05.04
  • www.mql5.com
MQL5 es un lenguaje built-in de estrategias comerciales para el terminal MetaTrader 5. Este lenguaje permite escribir sus propios sistemas automáticos de trading, indicadores técnicos, scripts y bibliotecas de funciones.
 
  1. Bitte editiere Deinen Code als Code mit Alt+S oder

  2. Was soll es werden EA oder Indikator beides geht nicht!!: Lies mal erst (erspart viel Zeit!!):
    Quickstart for newbies: https://www.mql5.com/de/articles/496
    und: https://www.mql5.com/de/articles/100
    Kochbuch : https://www.mql5.com/de/search#!keyword=Kochbuch
  3. Such doch erst: Es gibt fast nichts, was nicht schon für MT4/MT5 programmiert wurde => Suchen ist unsere AI: https://www.mql5.com/de/search

Quick Start: Short Guide for Beginners
Quick Start: Short Guide for Beginners
  • www.mql5.com
Hello dear reader! In this article, I will try to explain and show you how you can easily and quickly get the hang of the principles of creating Expert Advisors, working with indicators, etc. It is beginner-oriented and will not feature any difficult or abstruse examples.
 
Aaronio #:

Hallo,

dir wurde schon in Kommentaren erwähnt, dass da Parr Klammern fehlen.

//+------------------------------------------------------------------+
//| MyStrategy.mq4                                                   |
//| Copyright 2023, MetaQuotes Ltd.                                   |
//| https://www.mql5.com                                              |
//+------------------------------------------------------------------+

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

//--- input parameters
input color Color=clrYellow;
input bool  Input1=false;
input short Input2=800;
input ushort Input3=800;
input string Input4="(1/0)";

// Declare input parameters
extern double LotSize = 1.0;
extern int MovingAveragePeriod = 20;
extern double StopLossPips = 20.0;
extern double TakeProfitPips = 40.0;

// Declare global variables
double MovingAverageBuffer[];
double LastTradePrice;
int LastTradeDirection;
int LastTradeBar;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   //--- indicator buffers mapping
   
   // Resize the moving average buffer
   ArrayResize(MovingAverageBuffer, Bars - MovingAveragePeriod + 1);
   
   // Calculate the moving average
   for (int i = 0; i < Bars - MovingAveragePeriod + 1; i++)
   {
      double sum = 0.0;
      for (int j = i; j < i + MovingAveragePeriod; j++)
      {
         sum += Close[j];
      }
      MovingAverageBuffer[i] = sum / MovingAveragePeriod;
   }
   
   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   //---
   
   //--- return value of prev_calculated for next call
   return(rates_total);
}

//+------------------------------------------------------------------+
//| Handle the tick event                                            |
//+------------------------------------------------------------------+
void OnTick()
{ 
   // Get the current price
   double currentPrice = Bid;

   // Check if the last trade was a buy
   if (LastTradeDirection == 1)
   {
      // Check if the price has crossed below the moving average
      if (currentPrice < MovingAverageBuffer[LastTradeBar])
      {
         // Place a sell order at the current price
         double stopLoss = currentPrice + StopLossPips * Point;
         double takeProfit = currentPrice - TakeProfitPips * Point;
         OrderSend(Symbol(), OP_SELL, LotSize, currentPrice, 0, stopLoss,
                   takeProfit, "Sell order", 0, 0, Red);
         LastTradeDirection = -1;
         LastTradePrice = currentPrice;
         LastTradeBar = Bars - 1;
      }
   }
   // Check if the last trade was a sell
   else if (LastTradeDirection == -1)
   {
      // Check if the price has crossed above the moving average
      if (currentPrice > MovingAverageBuffer[LastTradeBar])
      {
         // Place a buy order at the current price
         double stopLoss = currentPrice

   }
 }
} // OnTick Ende

Gruß Igor

 
Igor Widiger #:

Hallo,

dir wurde schon in Kommentaren erwähnt, dass da Parr Klammern fehlen.

Gruß Igor

Igor, das war vor mehr als einem halben Jahr - er hat's wohl oder eine Alternative gefunden.

 
Carl Schreiber #:

Igor, das war vor mehr als einem halben Jahr - er hat's wohl oder eine Alternative gefunden.

Hallo,

ja, habe ich gesehen. Ich hoffe, dass er daraus was gelernt hat.

Gruß Igor

Grund der Beschwerde: