Unexpected End of Program. Unbalanced parenthesis

 

Good Day All,

I was wonder if of you mql4 pros can help with with two errors I can't seem to get rid of showing:

Here is the code:


#property version "1.00"

#property strict



extern int  BiggestCandleRange    = 6;

extern bool RoomToTheLeft         = true;

extern int  RoomToTheLeftCandles  = 10;

extern double RoomThreshold       = 5.0; 



extern int EntryPips               = 40;

extern int TakeProfitPips          = 300;

extern double LotsPerTrade         = 1;

extern int  Slippage               =4;

extern int ExpirationTime          = 3600;



datetime CurrentBarTime;



int onInit()

{



   return(INIT_SUCCEEDED);

}



void OnDeinit(const int reason)

{



}

void OnTick()

{  -(unbalanced parenthesis error here)

    if ( Time[0] > CurrentBarTime )

    {

    //A new bar is created

   

    CurrentBarTime = Time[0];

    

    // 1. Is it an engulfing candle (higher high and lower low)

    if ( High[1] > High[2] && Low[1] < Low[2] )

    {

      //Alert("There is an engulfing candle at", CurrentBarTime);

     

      // 2. Check if range is the biggest over the last X amount of candles

     int HighestRangeCandle = GetHighestPreviousRangeCandle(BiggestCandleRange);

     {

     if( HighestRangeCandle == 1 )

     {

         //Alert("The previous candle is the biggest one over the last " + IntegerToString(BiggestCandleRange)

        bool isBull = false;

            if( Open [1] < Close[1] )

                isBull = true;   



        if( RoomToTheLeft == true )

        {

                    

            bool IsRoomToTheLeft = IsThereRoomToTheLeft( isBull );

            if( IsRoomToTheLeft == false )  

            {

               return; 

            }  



            Alert("The previous candle is the biggest engulfing and has room to the left")

        }

        

        if( isBull == true )

        {

            //Create a buy order



            double EntryPoint = High[1] + EntryPips*Point();

            double Stoploss   = Open[1];

            double Takeprofit = EntryPoint + TakeProfitPips*Point();



            int ticket = OrderSend(Symbol(),OP_BUYSTOP,LotsPerTrade,EntryPoint,Slippage,StopLoss,Takeprofit,"This is an automated Bullish Big Shadow Trade",false,CurTime()+ExpirartionTime);

            if (ticket == false )

            {

                Alert("Something went wrong with creating the BUY order: ", GetLastError());

            }

        }else{

          // Create a sell order

            double EntryPoint = Low[1] + EntryPips*Point();

            double Stoploss   = Open[1];

            double Takeprofit = EntryPoint - TakeProfitPips*Point();



            int ticket = OrderSend(Symbol(),OP_SELLSTOP,LotsPerTrade,EntryPoint,Slippage,StopLoss,Takeprofit,"This is an automated Bearish Big Shadow Trade",false,CurTime()+ExpirartionTime);

            if (ticket == false )

            {

                Alert("Something went wrong with creating the SELL order: ", GetLastError());

            }    



        }

     



bool IsThereRoomToTheLeft( bool is Bull )

{

    double Range = High[1] - Low[1];

    if( isBull == false )

    }

    //Is a Bearish Candle - look at the highs of the previous candles

    int HighestIndex = iHighest(NULL,0,MODE_HIGH,RoomToTheLeftCandles,2);

    double HighestValue = High[HighestIndex];



    if( HighestValue < High[1] )

    {

        //There is room to the left but how much?   



        double RoomAvailable        = High[1] - HighestValue;

        double HowMuchRoomIsThere   = (RoomAvailable/Range)*100;



        if( HowMuchRoomIsThere > RoomThreshold )

        {

            return true;                       

        }else{

            return false;

        }

    }else{ 

       //Is A Bullish candle - look at the low of the previous candle



        int LowestIndex = iLowest(NULL,0,MODE_LOW,RoomToTheLeftCandles,2);

        double LowestValue = Low[LowestIndex];



        if( LowestValue > Low[1] )

        {   

        //There is room to the left but how much?   



            double RoomAvailable        = LowestValue - Low[1];

            double HowMuchRoomIsThere   = (RoomAvailable/Range)*100;



            if( HowMuchRoomIsThere > RoomThreshold )

            {

                return true;                       

        }else{

            return false;

        }



    

       

}

           

int GetHighestPreviousRangeCandle (int bars)

{

   double Output[100] = {};

   

   for( int counter = 1; counter <= bars; counter++ )

   {

      Output[counter] = High[counter] - Low[counter];

   }

   

   int HighestIdInOutput = ArrayMaximum(Output);

   

   return HighestIdInOutput;

   }

{

}

{


(unexpected end of program error here)

 Thank you so much in advance.

 
In future please post in the correct section
I will move your topic to the MQL4 and Metatrader 4 section.
 
Did you code this yourself?

And do you know how you do this 
 
Ahmet Metin Yilmaz:
Did you code this yourself?

And do you know how you do this 


Hi Ahmet i took a Udemy class and did the code based on the book Naked Trader. 
 
  1. int onInit(){   return(INIT_SUCCEEDED);   }
    Misspelled standard function.

  2. kmmr12: I was wonder if of you mql4 pros can help with with two errors I can't seem to get rid of showing:
    You don't have two errors, you have dozens. I suggest you throw that away and start coding from scratch. It is that bad.
  3. void OnTick()
    {  -(unbalanced parenthesis error here)
    
        if ( Time[0] > CurrentBarTime )
        {    -(unbalanced parenthesis error here)
        -(same indent)
        if ( High[1] > High[2] && Low[1] < Low[2] )
        {    -(unbalanced parenthesis error here)
         int HighestRangeCandle = GetHighestPreviousRangeCandle(BiggestCandleRange);
         {   -(why is there an opening brace here)
    
         if( HighestRangeCandle == 1 )
         {   -(unbalanced parenthesis error here)
            ⋮
            if( isBull == true )
            {
            ⋮
            }
    -(FIVE unbalanced parenthesis errors above)
    bool IsThereRoomToTheLeft( bool is Bull ) -(therefor function imbedded)
    {
        double Range = High[1] - Low[1];
        if( isBull == false )
        } -(What is this closing brace doing here.)
    I stopped looking at this point.
    

  4. Simplify your code where possible.
    bool isBull = false;
    if( Open [1] < Close[1] )
    isBull = true;
    
    bool isBull = Open [1] < Close[1];
    
    if( HowMuchRoomIsThere > RoomThreshold )
          {
              return true;
          }else{
              return false;
          }
    
    return HowMuchRoomIsThere > RoomThreshold;
    
<
 

Hi William 

Thanks for the feedback.

Reason: