help fixing an error

 

I'm new in the world of programing and i read a few articles on writing expert advisors, and i tried to write my own one but i keep getting these two errors :

'}' - unexpected end of program

'{' - unbalanced parentheses

 I don't know how to fix this can anyone tell me what should i 

thank you 

 

I understand your frustration, this can be one of the hardest things to get to grips with when starting to program.

Basically parentheses as they are known, are both a { and } symbol.

The error you are getting is because you have either a { without a }, or a } without a {

e.g.

myfunction() {

... some stuff here



Notice in the above I forgot to finish with a }, thus I would get a unbalanced parentheses error.

It can also work the other way around

e.g.

myfunction()

... some stuff here

}


In the above I forgot the {

I suspect what you have is quite a few if/else type statements and you've forgotten to open or close one of these { } tags.


I hope this helps.

 

thank you for your comment 

i don't think that's the problem because i looked at the code million times and i can't find the problem so i even wrote a new expert advisor startin from zero and in the end i got the same error

and even when i remove everything in the void ontick function i still get the same error 

i think it would be better if i put the code here :

 

 

 

 

#property copyright "karem talli"

#property link      "karem.talli@hotmail.com"

#property version   "1.00"

//--- The Trade Class

#include <Trade\Trade.mqh>

//--- The PositionInfo Class

#include <Trade\PositionInfo.mqh>

//--- The AccountInfo Class

#include <Trade\AccountInfo.mqh>

//--- The SymbolInfo Class

#include <Trade\SymbolInfo.mqh>

//INPUT PARAMETERS:

input int ma_period=8; // Moving average period

input int adx_period=8; // ADX period

input double vol=0.1; // Lots to trade

input int EA_magic=1515; // EA magic number

input int dev=100; // Deviation

input int take=250; // Take profit

input int stop=50; // Stop loss

/*OTHER PARAMETERS:*/

double adx[] , plus[] , minus[] , ma[];

double mahandle , adxhandle;

double tkp , stl;

//CLASSES: 

CTrade trade;

CPositionInfo poinfo;

CSymbolInfo symbol;

CAccountInfo accinfo;

// TYLER

int Tyler()

{

     int durden=5;

     if (poinfo.Select(_Symbol)==true)

     {

       if (poinfo.Type()==POSITION_TYPE_BUY)

       {

         durden=1;

         if (/*CONDITIONS TO CLOSE A LONG POSITION*/)

         {

           durden=3;

         }

       }

       if (poinfo.Type()==POSITION_TYPE_SELL)

       {

         durden=2;

         if (/*CONDITIONS TO CLOSE A SHORT POSITIONS*/)

         {

           durden=4;

         }

       }

     }

     return(durden);

}

// MIKE THE CLOSER

void Mike()

{

    if (trade.PositionClose(_Symbol,dev))

    {

      Alert("Open position has been closed");

    } 

    else

    {

      Alert("Position was not closed - error: ",trade.ResultRetcodeDescription());

    }

}

// MOMBASA

int Mombasa()

{

     int troy=3;

     if (/*buy conditions*/)

     {

       troy=1;

     }

     if (/*sell conditions*/)

     {

       troy=2;

     }

     return(troy);

}

// SHAQ

void Shaq(int type)

{

     if (type==1)

     {

       double buyprice=NormalizeDouble(symbol.Bid(),_Digits);             //--- latest Bid price

       double stoploss=NormalizeDouble(symbol.Bid()+stl*_Point,_Digits);   //--- Stop Loss

       double takeprofit=NormalizeDouble(symbol.Bid()-tkp*_Point,_Digits); //--- Take Profit

       if (trade.PositionOpen(_Symbol,ORDER_TYPE_BUY,vol,buyprice,stoploss,takeprofit))

       {

         Alert("A long position has been opened with deal ticket no: ",trade.ResultDeal());

       }

       else

       {

         Alert("The Buy order request at Vol:",trade.RequestVolume(),

               ", sl:", trade.RequestSL(),", tp:",trade.RequestTP(), 

               ", price:", trade.RequestPrice(), 

               " could not be completed -error:",trade.ResultRetcodeDescription());

         return;

       }

     }

     if (type==2)

     {

       double sellprice=NormalizeDouble(symbol.Ask(),_Digits);             //--- latest Bid price

       double stopploss=NormalizeDouble(symbol.Ask()+stl*_Point,_Digits);   //--- Stop Loss

       double takeeprofit=NormalizeDouble(symbol.Ask()-tkp*_Point,_Digits); //--- Take Profit

       if (trade.PositionOpen(_Symbol,ORDER_TYPE_SELL,vol,sellprice,stopploss,takeeprofit))

       {

         Alert("A short position has been opened with deal ticket no: ",trade.ResultDeal());

       }

       else

       {

         Alert("The Sell order request at Vol:",trade.RequestVolume(),

               ", sl:", trade.RequestSL(),", tp:",trade.RequestTP(), 

               ", price:", trade.RequestPrice(), 

               " could not be completed -error:",trade.ResultRetcodeDescription());

         return;

     }

}

//| Expert initialization function                                   |

//+------------------------------------------------------------------+

int OnInit()

  {

      trade.SetExpertMagicNumber(EA_magic);

      trade.SetDeviationInPoints(dev);

      mahandle=iMA(_Symbol,_Period,ma_period,0,MODE_EMA,PRICE_CLOSE);

      adxhandle=iADX(_Symbol,_Period,adx_period);

      if ( mahandle<0 || adxhandle<0 ) 

         {

         Alert("Error creating handles for indicators! - error: ",GetLastError());

         return(1);

         }

   return(0);

  }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

     IndicatorRelease(adxhandle);

     IndicatorRelease(mahandle);

  }

//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

void OnTick()

  {

     MqlRates myrate[];

     ArraySetAsSeries(myrate,true);

     ArraySetAsSeries(adx,true);

     ArraySetAsSeries(plus,true);

     ArraySetAsSeries(minus,true);

     ArraySetAsSeries(ma,true);

     // copy rates

     if (CopyRates(_Symbol,_Period,0,4,myrate) < 0)

     {

       Alert("Error copying rates - error: ",GetLastError());

       return;

     }

     //check if we have enough bars

     static datetime lastime;

     datetime now = myrate[0].time;

     if (now==lastime)

     {

       return;

     }

     lastime=now;

     // copying buffers

     if ( CopyBuffer(adxhandle,0,0,4,adx) < 3 || CopyBuffer(adxhandle,1,0,4,plus) < 3 || CopyBuffer(adxhandle,2,0,4,minus) < 3 )

     {

       Alert("Error copying ADX buffers - error: ",GetLastError());

       return;

     } 

     if ( CopyBuffer(mahandle,0,0,4,ma) < 3)

     {

       Alert("Error copying MA buffer - error: ",GetLastError());

       return;

     }

     tkp = take;

     stl = stop;

     void Tristen()

     {

       int smilla = Tyler();

       if ( smilla == 1 || smilla == 2 )

       {

         return;

       }

       if ( smilla == 3 || smilla == 4 )

       {

         Mike();

       }

       if ( smilla == 5 )

       {

         becca = Mombasa();

         if ( becca == 1 )

         {

           Shaq(1);

         }

         if ( becca == 2 )

         {

           Shaq(2);

         }

       }

     }

  

  }

//+------------------------------------------------------------------+
 

i finally found the problem it wasn't in the ontick where i was looking the whole time

thank you i appreciate your effort to help  

 
Comments that do not relate to this topic, have been moved to "Help fixing error (mql4)".
 

Please use the </> button to insert your above code.


 

 i need help with this ANYONE?

'}' - unexpected end of program RSI_Value_EA.mq4 173 1

'{' - unbalanced parentheses RSI_Value_EA.mq4 40 1

 
Siya Faku #:

 i need help with this ANYONE?

'}' - unexpected end of program RSI_Value_EA.mq4 173 1

'{' - unbalanced parentheses RSI_Value_EA.mq4 40 1

Count your brackets.

You can use the styler to line them up and you can even activate highlight matching brackets in the editor options so that they become visible.
 
Siya Faku #:

 i need help with this ANYONE?

'}' - unexpected end of program RSI_Value_EA.mq4 173 1

'{' - unbalanced parentheses RSI_Value_EA.mq4 40 1

Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the file.
     How To Ask Questions The Smart Way. (2004)
          Be precise and informative about your problem

We can't see your broken code.

 
I am unable to backtest my strategy in the strategy tester. I keep getting multiple errors such as "Tester authorization error" and connection closed. Any Tips?
 
Brandon #: . Any Tips?

Don't Hijack other threads for your off-topic post. Next time, make your own, new, thread.

Reason: