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.
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.
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.
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?

- 2023.05.04
- www.mql5.com
-
Bitte editiere Deinen Code als Code mit Alt+S oder
- 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 - 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

- www.mql5.com
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

- Freie Handelsapplikationen
- Über 8.000 Signale zum Kopieren
- Wirtschaftsnachrichten für die Lage an den Finanzmärkte
Sie stimmen der Website-Richtlinie und den Nutzungsbedingungen zu.
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