'if' - expressions are not allowed on a global scope

William Roeder  
  1. Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
              Messages Editor

  2.  double Close[2], Open[2], High[2], Low[2];

    These are the names of the Predefined Variables. You can not redefine them. Change the names.

  3.     if (PinBarCheck()) {
          OpenPrice = Ask;      
         HighPrice = iHigh(NULL, 0, 1);
          LowPrice = iLow(NULL, 0, 1);
           Ticket = OrderSend(Symbol(), OP_BUY, Lots, OpenPrice, 3); 
        }  
    
    //+------------------------------------------------------------------+
    //| Check for pin bar formation                                  |
    //+------------------------------------------------------------------+    
    bool PinBarCheck() {    

    The if must be part of a function. You ended the function before the if. Always post all relevant code (using Code button) or attach the source file.

Mohamed Ibrahim  

kindly find the complete file for your review and advice, as I still have error

Thanks in advance.

Files:
William Roeder  
Mohamed Ibrahim #: as I still have error
// Pin bar trading strategy

// Define variables
double takeProfit, stopLoss;
int magicNumber = 12345; // unique identifier for trades

// Identify pin bar pattern
 if (pinBarPattern) {
    // Open three orders at 0.01 each
    for (int i = 0; i < 3; i++) {
        if (buy) {

Of course, you have errors.

  1. Your if and its code, is not inside any function.
  2. You have not defined or initialized any pinBarPattern or buy variable. Likewise, the rest of your code. You have nonsense.
  3. You have only four choices:

    1. Search for it (CodeBase or Market). Do you expect us to do your research for you?

    2. Try asking at:

    3. MT4: Learn to code it.
      MT5: Begin learning to code it.

      If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

    4. Or pay (Freelance) someone to code it. Top of every page is the link Freelance.
                Hiring to write script - General - MQL5 programming forum (2019)

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
              No free help (2017)