unexpectet end of programm/unbalanced parentheses

 

Can someone help me fix this 2 errors?


void OnStart()

  {

input ENUM_TRAIL_TYPE trailType = ENUM_TRAIL_TYPE(0); // modified
input int ATRPeriod = 28;
input int ATRFactor = 5;
input bool show_fib_entries = true;

double norm_o = iOpen(NULL, 0, 0);
double norm_h = iHigh(NULL, 0, 0);
double norm_l = iLow(NULL, 0, 0);
double norm_c = iClose(NULL, 0, 0);
//}

// Wilders moving average
double Wild_ma(double _src, int _malength)
{
static double _wild = 0.0;
_wild = (_wild == 0.0 ? _src : _wild * (_malength - 1) / _malength + _src / _malength);
return(_wild);
}

// True range calculations
void TrueRange()
{
double HiLo = Min(norm_h - norm_l, 1.5 * NormalizeDouble(iMA((norm_h - norm_l), ATRPeriod), _Digits));
double HRef = (norm_l <= norm_h[1]) ? (norm_h - norm_c[1]) : ((norm_h - norm_c[1]) - 0.5 * (norm_l - norm_h[1]));
double LRef = (norm_h >= norm_l[1]) ? (norm_c[1] - norm_l) : ((norm_c[1] - norm_l) - 0.5 * (norm_l[1] - norm_h));
double trueRange = (trailType == ENUM_TRAIL_TYPE(0)) ? Max(HiLo, HRef, LRef) : Max(norm_h - norm_l, abs(norm_h - norm_c[1]), abs(norm_l - norm_c[1]));
}

// Trade logic
void TradeLogic()
{
double loss = ATRFactor * Wild_ma(trueRange, ATRPeriod);
double Up = norm_c - loss;
double Dn = norm_c + loss;
double TrendUp = Up;
double TrendDown = Dn;
int Trend = 1;
TrendUp = (norm_c[1] > TrendUp[1]) ? Max(Up, TrendUp[1]) : Up;
TrendDown = (norm_c[1] < TrendDown[1]) ? Min(Dn, TrendDown[1]) : Dn;
Trend = (norm_c > TrendDown[1]) ? 1 : (norm_c < TrendUp[1]) ? -1 : (Trend[1] == EMPTY_VALUE) ? 1 : Trend[1];
double trail = (Trend == 1) ? TrendUp : TrendDown;
static double ex = 0.0;
ex = (Trend == 0) ? ex[1] : (Trend == 1) ? Max(ex[1], norm_h) : Min(ex[1], norm_l);
}

// Plot TP and SL
void PlotTPandSL()
{
Plot(trail, "Trailingstop", Trend == 1 ? Green : Trend ==
}

 
  1. The first step is to style your code properly, or to use the automatic styler in MetaEditor. This will make it easier for you to spot problems.
  2. The first problem, is that you commented out your closing braces for the OnStart() function (see the text below — "//} <- Fix this by removing the "//"").
// The code below was styled with the "Allman" style
void OnStart()
{
   input ENUM_TRAIL_TYPE trailType = ENUM_TRAIL_TYPE(0); // modified
   input int ATRPeriod = 28;
   input int ATRFactor = 5;
   input bool show_fib_entries = true;
   double norm_o = iOpen(NULL, 0, 0);
   double norm_h = iHigh(NULL, 0, 0);
   double norm_l = iLow(NULL, 0, 0);
   double norm_c = iClose(NULL, 0, 0);
//} <- Fix this by removing the "//"
// Wilders moving average
double Wild_ma(double _src, int _malength)
{
   static double _wild = 0.0;
   _wild = (_wild == 0.0 ? _src : _wild * (_malength - 1) / _malength + _src / _malength);
   return(_wild);
}
// True range calculations
void TrueRange()
{
   double HiLo = Min(norm_h - norm_l, 1.5 * NormalizeDouble(iMA((norm_h - norm_l), ATRPeriod), _Digits));
   double HRef = (norm_l <= norm_h[1]) ? (norm_h - norm_c[1]) : ((norm_h - norm_c[1]) - 0.5 * (norm_l - norm_h[1]));
   double LRef = (norm_h >= norm_l[1]) ? (norm_c[1] - norm_l) : ((norm_c[1] - norm_l) - 0.5 * (norm_l[1] - norm_h));
   double trueRange = (trailType == ENUM_TRAIL_TYPE(0)) ? Max(HiLo, HRef, LRef) : Max(norm_h - norm_l, abs(norm_h - norm_c[1]), abs(norm_l - norm_c[1]));
}
// Trade logic
void TradeLogic()
{
   double loss = ATRFactor * Wild_ma(trueRange, ATRPeriod);
   double Up = norm_c - loss;
   double Dn = norm_c + loss;
   double TrendUp = Up;
   double TrendDown = Dn;
   int Trend = 1;
   TrendUp = (norm_c[1] > TrendUp[1]) ? Max(Up, TrendUp[1]) : Up;
   TrendDown = (norm_c[1] < TrendDown[1]) ? Min(Dn, TrendDown[1]) : Dn;
   Trend = (norm_c > TrendDown[1]) ? 1 : (norm_c < TrendUp[1]) ? -1 : (Trend[1] == EMPTY_VALUE) ? 1 : Trend[1];
   double trail = (Trend == 1) ? TrendUp : TrendDown;
   static double ex = 0.0;
   ex = (Trend == 0) ? ex[1] : (Trend == 1) ? Max(ex[1], norm_h) : Min(ex[1], norm_l);
}
// Plot TP and SL
void PlotTPandSL()
{
   Plot(trail, "Trailingstop", Trend == 1 ? Green : Trend ==
}
 

3. However, now that we have fixed the closing brace, you now have 104 errors and 8 warnings ...

'TestScript.mq5'        TestScript.mq5  1       1
'input' - unexpected token      TestScript.mq5  4       4
'ENUM_TRAIL_TYPE' - declaration without type    TestScript.mq5  4       10
'input' - unexpected token      TestScript.mq5  5       4
'input' - unexpected token      TestScript.mq5  6       4
'input' - unexpected token      TestScript.mq5  7       4
'Min' - undeclared identifier   TestScript.mq5  23      18
'norm_h' - undeclared identifier        TestScript.mq5  23      22
'norm_l' - undeclared identifier        TestScript.mq5  23      31
',' - unexpected token  TestScript.mq5  23      37
'-' - some operator expected    TestScript.mq5  23      29
'1.5' - semicolon expected      TestScript.mq5  23      39
'norm_h' - undeclared identifier        TestScript.mq5  23      66
'norm_l' - undeclared identifier        TestScript.mq5  23      75
'ATRPeriod' - undeclared identifier     TestScript.mq5  23      84
'iMA' - wrong parameters count  TestScript.mq5  23      61
   built-in: int iMA(const string,ENUM_TIMEFRAMES,int,int,ENUM_MA_METHOD,int)   TestScript.mq5  23      61
')' - unexpected token  TestScript.mq5  23      104
result of expression not used   TestScript.mq5  23      43
'norm_l' - undeclared identifier        TestScript.mq5  24      19
'norm_h' - undeclared identifier        TestScript.mq5  24      29
'1' - some operator expected    TestScript.mq5  24      36
')' - unexpected token  TestScript.mq5  24      38
')' - semicolon expected        TestScript.mq5  24      38
')' - unexpected token  TestScript.mq5  24      38
syntax error, boolean expression expected       TestScript.mq5  24      40
'norm_h' - undeclared identifier        TestScript.mq5  24      43
'norm_c' - undeclared identifier        TestScript.mq5  24      52
'1' - some operator expected    TestScript.mq5  24      59
')' - unexpected token  TestScript.mq5  24      61
')' - ':' colon sign expected   TestScript.mq5  24      61
')' - unexpected token  TestScript.mq5  24      61
')' - expression expected       TestScript.mq5  24      61
':' - unexpected token  TestScript.mq5  24      63
'norm_h' - undeclared identifier        TestScript.mq5  24      67
'norm_c' - undeclared identifier        TestScript.mq5  24      76
'1' - some operator expected    TestScript.mq5  24      83
'norm_l' - undeclared identifier        TestScript.mq5  24      96
'norm_h' - undeclared identifier        TestScript.mq5  24      105
'1' - some operator expected    TestScript.mq5  24      112
')' - unexpected token  TestScript.mq5  24      114
result of expression not used   TestScript.mq5  24      74
result of expression not used   TestScript.mq5  24      87
')' - unexpected token  TestScript.mq5  24      115
'norm_h' - undeclared identifier        TestScript.mq5  25      19
'norm_l' - undeclared identifier        TestScript.mq5  25      29
'1' - some operator expected    TestScript.mq5  25      36
')' - unexpected token  TestScript.mq5  25      38
')' - semicolon expected        TestScript.mq5  25      38
')' - unexpected token  TestScript.mq5  25      38
syntax error, boolean expression expected       TestScript.mq5  25      40
'norm_c' - undeclared identifier        TestScript.mq5  25      43
'1' - some operator expected    TestScript.mq5  25      50
'norm_l' - undeclared identifier        TestScript.mq5  25      55
')' - unexpected token  TestScript.mq5  25      61
')' - ':' colon sign expected   TestScript.mq5  25      61
')' - unexpected token  TestScript.mq5  25      61
')' - expression expected       TestScript.mq5  25      61
':' - unexpected token  TestScript.mq5  25      63
'norm_c' - undeclared identifier        TestScript.mq5  25      67
'1' - some operator expected    TestScript.mq5  25      74
'norm_l' - undeclared identifier        TestScript.mq5  25      79
'norm_l' - undeclared identifier        TestScript.mq5  25      96
'1' - some operator expected    TestScript.mq5  25      103
'norm_h' - undeclared identifier        TestScript.mq5  25      108
')' - unexpected token  TestScript.mq5  25      114
result of expression not used   TestScript.mq5  25      77
result of expression not used   TestScript.mq5  25      87
result of expression not used   TestScript.mq5  25      106
')' - unexpected token  TestScript.mq5  25      115
'trailType' - undeclared identifier     TestScript.mq5  26      24
'ENUM_TRAIL_TYPE' - undeclared identifier       TestScript.mq5  26      37
'0' - some operator expected    TestScript.mq5  26      53
'Max' - undeclared identifier   TestScript.mq5  26      59
',' - unexpected token  TestScript.mq5  26      67
'HiLo' - some operator expected TestScript.mq5  26      63
'HRef' - ':' colon sign expected        TestScript.mq5  26      69
')' - semicolon expected        TestScript.mq5  26      79
'abs' - class type expected     TestScript.mq5  26      104
'abs' - variable already defined        TestScript.mq5  26      129
   see previous declaration of 'abs'    TestScript.mq5  26      104
'abs' - class type expected     TestScript.mq5  26      129
variable 'abs' not used TestScript.mq5  26      104
'ATRFactor' - undeclared identifier     TestScript.mq5  31      18
'trueRange' - undeclared identifier     TestScript.mq5  31      38
'ATRPeriod' - undeclared identifier     TestScript.mq5  31      49
'norm_c' - undeclared identifier        TestScript.mq5  32      16
'norm_c' - undeclared identifier        TestScript.mq5  33      16
'norm_c' - undeclared identifier        TestScript.mq5  37      15
'1' - some operator expected    TestScript.mq5  37      22
'1' - some operator expected    TestScript.mq5  37      35
')' - unexpected token  TestScript.mq5  37      37
syntax error, boolean expression expected       TestScript.mq5  37      39
'Max' - undeclared identifier   TestScript.mq5  37      41
',' - unexpected token  TestScript.mq5  37      47
'Up' - some operator expected   TestScript.mq5  37      45
'TrendUp' - ':' colon sign expected     TestScript.mq5  37      49
'1' - some operator expected    TestScript.mq5  37      57
']' - unexpected token  TestScript.mq5  37      58
'?' - some operator expected    TestScript.mq5  37      39
')' - unexpected token  TestScript.mq5  37      59
':' - unexpected token  TestScript.mq5  37      61
expression has no effect        TestScript.mq5  37      63
'norm_c' - undeclared identifier        TestScript.mq5  38      17
'1' - some operator expected    TestScript.mq5  38      24
'1' - some operator expected    TestScript.mq5  38      39
')' - unexpected token  TestScript.mq5  38      41
syntax error, boolean expression expected       TestScript.mq5  38      43
'Min' - undeclared identifier   TestScript.mq5  38      45
',' - unexpected token  TestScript.mq5  38      51
104 errors, 8 warnings          100     9
 

4. There are just too many problems to address.

The next question is ... Do you know how to code in MQL, even if at least the basics?