Unexpected end to program for MT4

 
void OnTick()
{
    // Define Alligator parameters
    int Jaws_Period = 13;
    int Jaws_Shift = 8;
    int Teeth_Period = 8;
    int Teeth_Shift = 5;
    int Lips_Period = 5;
    int Lips_Shift = 3;

    // Calculate Alligator values
    double Jaws_0 = iAlligator(NULL, 0, Jaws_Period, Jaws_Shift, Teeth_Period, Teeth_Shift, Lips_Period, Lips_Shift, MODE_SMA, PRICE_CLOSE, MODE_GATORJAW, 0);
    double Teeth_0 = iAlligator(NULL, 0, Jaws_Period, Jaws_Shift, Teeth_Period, Teeth_Shift, Lips_Period, Lips_Shift, MODE_SMA, PRICE_CLOSE, MODE_GATORTEETH, 0);
    double Lips_0 = iAlligator(NULL, 0, Jaws_Period, Jaws_Shift, Teeth_Period, Teeth_Shift, Lips_Period, Lips_Shift, MODE_SMA, PRICE_CLOSE, MODE_GATORLIPS, 0);

    // Check conditions for placing a buy order
    bool AlligatorCondition = Lips_0 > Teeth_0 && Teeth_0 > Jaws_0 && Lips_0 > Jaws_0 &&
                              Ask > Jaws_0 && Ask > Teeth_0 && Ask > Lips_0;}
        
    if (AlligatorCondition && OrdersTotal() == 0)
    {
        // Place Buy Order
        int BuyOrder = OrderSend(NULL, OP_BUY, 0.08, Ask, 1, Ask - 0.5, Ask + 2.5, NULL, 123456, 0, clrGreen);
        Print("Buy Order Took Place");
    }

    bool Info_On_Chart = true; // Display info on chart
    
    bool isCondition1 = PRICE_CLOSE >= Lips_0 && Lips_0 > Teeth_0 && Teeth_0 > Jaws_0 && Lips_0 > Jaws_0 &&
                        PRICE_CLOSE >= Lips_1 && Lips_1 > Teeth_1 && Teeth_1 > Jaws_1 && Lips_1 > Jaws_1 &&
                        PRICE_CLOSE >= Lips_2 && Lips_2 > Teeth_2 && Teeth_2 > Jaws_2 && Lips_2 > Jaws_2;

    bool isCondition2 = PRICE_CLOSE <= Lips_0 && Lips_0 < Teeth_0 && Teeth_0 < Jaws_0 && Lips_0 < Jaws_0 &&
                        PRICE_CLOSE <= Lips_1 && Lips_1 < Teeth_1 && Teeth_1 < Jaws_1 && Lips_1 < Jaws_1 &&
                        PRICE_CLOSE <= Lips_2 && Lips_2 < Teeth_2 && Teeth_2 < Jaws_2 && Lips_2 < Jaws_2;
                      
    

    if (Alligator == true && OrdersTotal() == 0)
    {
        int BuyOrder = OrderSend(NULL, OP_BUY, 0.08, Ask, 1, Ask - 0.5, Ask + 1.5, NULL, 123456, 0, clrGreen);
        Print("Buy Order Took Place");
    }

    if (Alligator == true && isCondition1 == true && OrdersTotal() == 0)
    {
        int BuyOrder = OrderSend(NULL, OP_BUY, 0.08, Ask, 1, Ask - 0.5, Ask + 1.5, NULL, 123456, 0, clrGreen);
    }

    if (Alligator == true && isCondition2 == true && OrdersTotal() == 0)
    {
        int BuyOrder = OrderSend(NULL, OP_BUY, 0.08, Ask, 1, Ask - 0.5, Ask + 1.5, NULL, 12345678, 0, clrGreen);
    }

I keep getting unexpected end to program and unbalanced parenthesis, anyone see the issue? I'm not sure where the snag is, thanks for any help.

 
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 

I sincerely hope this is not ChatGPT (or other A.I.) generated code. Because if it is, then please, don't request help with it.

It generates horrible code, mixing MQL4 and MQL5. Please use the Freelance section for such requests — https://www.mql5.com/en/job

Trading applications for MetaTrader 5 to order
Trading applications for MetaTrader 5 to order
  • 2023.11.21
  • www.mql5.com
The largest freelance service with MQL5 application developers
 
im not using chat gpt IS my code mixing mt4 with mt5 language? thanks for the assist
 

I gave you clear instructions, yet you posted a new post with again improperly formatted code, instead of editing your original post and doing it properly.

 
Jason Cuenca:I keep getting unexpected end to program and unbalanced parenthesis, anyone see the issue? I'm not sure where the snag is, thanks for any help.

That is because your program is incomplete. Where is the closing brace "}" for the OnTick() function?


 
        int BuyOrder = OrderSend(NULL, OP_BUY, 0.08, Ask, 1, Ask - 0.5, Ask + 2.5, NULL, 123456, 0, clrGreen);
        Print("Buy Order Took Place");
  1. Be careful with NULL.

    1. On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.
    2. Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
    3. Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
    4. MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
      MT5: create them.
    5. Cloud Protector Bug? - MQL4 programming forum (2020)

  2. Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (MT5 / MT4+strict), it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 programming forum (2012)
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles (2014)You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.

  3. You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.

    1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

    2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close at a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

    3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)

      Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes.
      My GBPJPY shows average spread = 26 points, average maximum spread = 134.
      My EURCHF shows average spread = 18 points, average maximum spread = 106.
      (your broker will be similar).
                Is it reasonable to have such a huge spreads (20 PIP spreads) in EURCHF? - General - MQL5 programming forum (2022)

 
    bool isCondition1 = PRICE_CLOSE >= Lips_0 && Lips_0 > Teeth_0 && Teeth_0 > Jaws_0 && Lips_0 > Jaws_0 &&
                        PRICE_CLOSE >= Lips_1 && Lips_1 > Teeth_1 && Teeth_1 > Jaws_1 && Lips_1 > Jaws_1 &&
                        PRICE_CLOSE >= Lips_2 && Lips_2 > Teeth_2 && Teeth_2 > Jaws_2 && Lips_2 > Jaws_2;
PRICE_CLOSE is the constant zero. Get the actual price.
Reason: