Download MetaTrader 5
To add comments, please log in or register
Code Base will help you in mastering your theoretical skills. Come and learn!
reza90
13
reza90 2016.11.28 17:37 

Hi

What is the problem the following code?

string stat3()
if (stat1>stat2)
    return("buy");
else if (stat1<stat2)

  return("sell");


Carl Schreiber
6578
Carl Schreiber 2016.11.28 17:47  
Load your code (not only this snippet) in a different editor and count the brackets: { and } and ( and ) and then start to find where have you either one of them too many or too less.
reza90
13
reza90 2016.11.28 17:54  
Carl Schreiber:
Load your code (not only this snippet) in a different editor and count the brackets: { and } and ( and ) and then start to find where have you either one of them too many or too less.
//+------------------------------------------------------------------+
//|                                                         6060.mq4 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
extern int stat1 = 50;
extern int stat2 = 100;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
  
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
 
  }
//---
  
  //+------------------------------------------------------------------+
string stat3()
if (stat1>stat2)
    return("buy");
else if (stat1<stat2)
  return("sell");
whroeder1
14457
whroeder1 2016.11.28 18:58  
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. void OnTick()
      {

      }
    ^^^^^^^^^^^ OnTick has ended. vvvvvvvvvv everything below is on global scope.
honest_knave
Moderator
2149
honest_knave 2016.11.28 19:32  
reza90:

void OnTick()
  {
 
  }
//---
  
  //+------------------------------------------------------------------+
string stat3()
if (stat1>stat2)
    return("buy");
else if (stat1<stat2)
  return("sell");
string stat3()
  {
   if (stat1>stat2)      return("buy");
   else if (stat1<stat2) return("sell");
   return("");
  }
reza90
13
reza90 2016.11.28 20:02  
honest_knave:
string stat3()
  {
   if (stat1>stat2)      return("buy");
   else if (stat1<stat2) return("sell");
   return("");
  }
Thank you dear friend
/
To add comments, please log in or register