Einzelnen Beitrag anzeigen
  #1 (permalink)  
Alt 28.04.23
Lennox Lennox ist offline
Neues Mitglied
 
Registriert seit: Apr 2023
Beiträge: 5
Lennox befindet sich auf einem aufstrebenden Ast
Standard 2 Fehlermeldungen bitte um Hilfe

Liebe Community,

ich bin neu hier und buchstäblich den ganzen Tag erfolglos damit verbracht, einen Code in MetaEditor zu hinterlegen. 2 Fehlermeldungen wollen einfach nicht weggehen und ich bin inzwischen echt mit meinem Latein am Ende.

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

Ich habe alles versucht, um diese Fehlermeldungen zu eliminieren, aber ich habe es einfach nicht geschafft.

Vielleicht hat hier der ein oder andere eine Idee, woran es liegen könnte.
Es handelt sich wirklich nur um 2 kleine Fehler. Ich bin mir sicher, dass jemand von Ihnen da draußen das Problem bereits gelöst hat und ich würde mich sehr freuen, wenn Sie Ihr Wissen mit mir teilen könnten.

Vielen Dank im Voraus für Ihre Hilfe!

//+------------------------------------------------------------------+
//| 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