i need help for the error 'SymbolInfoDouble' - function declarations are allowed on global, namespace or class scope only

 
Hello guys, i need help with my programm cause im not the best at programming but it always show me the 'SymbolInfoDouble' - function declarations are allowed on global, namespace or class scope only error can someone help me ? thats the code

...

Improperly formatted code removed by moderator. Please EDIT your post and use the CODE button (Alt-S) when inserting code.

Code button in editor

Hover your mouse over your post and select "edit" ... 

...

 
  1. Before posting the code formate it withe Styler in the Editor(in Tools).
  2. Post your code as code with either ALT+S or
  3. Error messages having globe scope indicate incorrect bracket placements - which are easier to detect in formatted code (see 1.)
  4. You cant declare any function within another function - check theses brackets.
 
Carl Schreiber #:
  1. Before posting the code formate it withe Styler in the Editor(in Tools).
  2. Post your code as code with either ALT+S or
  3. Error messages having globe scope indicate incorrect bracket placements - which are easier to detect in formatted code (see 1.)
  4. You cant declare any function within another function - check theses brackets.
thank you very much for your quick reply i really appreciate it, could you help me to solve this problem because i have absolutely no idea how or what i need to change to make the program work correctly
 
Carl Schreiber #:
  1. Before posting the code formate it withe Styler in the Editor(in Tools).
  2. Post your code as code with either ALT+S or
  3. Error messages having globe scope indicate incorrect bracket placements - which are easier to detect in formatted code (see 1.)
  4. You cant declare any function within another function - check theses brackets.
//+------------------------------------------------------------------+
//|                                                     Spread Limit |
//+------------------------------------------------------------------+
#property version   "1.00"
#property strict

// Declare global variable to store tick information
MqlTick m_tick;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
   //--- check spread every tick
   SymbolInfoTick(Symbol(),m_tick);

   //--- check spread limit
   CheckSpread();

   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
   //--- update tick information
   SymbolInfoTick(Symbol(),m_tick);

   //--- check spread limit
   CheckSpread();
}

//+------------------------------------------------------------------+
//| Check spread limit function                                      |
//+------------------------------------------------------------------+
void CheckSpread()
{
   //--- get spread for the symbol
   double  SymbolInfoDouble(
   string                   EURUSD,      // Symbol
   ENUM_SYMBOL_INFO_DOUBLE  prop_id    // Identifikator der Eigenschaft 
   );

   //--- disable trading buttons if spread is too high
   if (MODE_SPREAD > 10)
   {
      ExpertRemove();
   }
}

//+-----------------------------------------------------------------+
heres the code with alt s
 

And what are the compiler errors now?

Beside your try do you know that there's virtually nothing that hasn't already been programmed for MT4/MT5 and is ready for you - so searching gives better results than AI or ChatGPT and it's a lot faster: https://www.mql5.com/en/search

Anyway here is a list of all function where you can search with CTRL+F: https://www.mql5.com/en/docs/function_indices

Quickstart for newbies: https://www.mql5.com/de/articles/496
und: https://www.mql5.com/de/articles/100
(Schrittweiser Leitfaden für Anfänger zum Schreiben eines Expert Advisors in MQL5)
Kochbücher: https://www.mql5.com/de/search#!keyword=kochbuch

And a final hint: place the cursor on a function or keyword of MQL5 and press F1 to see immediately how it can be used_ Parameters, return value ... many with examples to copy, paste, and change.

Documentation on MQL5: List of MQL5 Functions
Documentation on MQL5: List of MQL5 Functions
  • www.mql5.com
List of MQL5 Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Carl Schreiber #:

And what are the compiler errors now?

Beside your try do you know that there's virtually nothing that hasn't already been programmed for MT4/MT5 and is ready for you - so searching gives better results than AI or ChatGPT and it's a lot faster: https://www.mql5.com/en/search

  1. 'SymbolInfoDouble' - function declarations are allowed on global, namespace or class scope only, that the error code
  2. i just want an ea wich is always active, shows me the current spread for EURUSD on the top right and the important thing, it should make it unable to Sell or buy EURUSD if the spread is going over 10 so just deactivate the sell/buy buttons
 
  1. An EA cannot stop the trading generally only for itself if there is an return e.g. at the beginning of OnTick().
  2. Here: double  SymbolInfoDouble(... you forgot to name a variable like:  double sprd  = SymbolInfoDouble(
  3. DONT'T use ChatGPT we're tired correcting the rubish it creates.
  4. Ask Google for "site:mql5.com show spread" or learn to code!
Reason: