can i use these () {} so much ?? - page 3

 

i just add some trade time, but error show unbalanced left parenthesis.........

i really wanna get mad.

 
albert_lim83:

i just add some trade time, but error show unbalanced left parenthesis.........

i really wanna get mad.

Cont thee left { or ( and count the right } or ) . . . they have to balance . . .
 
where the error ???
 
thanks ...
 

this is a really creative indentation style, I haven't seen this style before (the way you give the else branch a higher indentation, very confusing, and also it seems it is not consistent).


You should make yourself familiar and then consequently apply the 1tbs style, this is the most used style nowadays.


And btw, is it even allowed to put a ; between the condition () of the if and before its {} block?


Edit: Why did you remove the code we were discussing here? It was here a few seconds ago! Put it back!

 
i m trying to separate the trading time with different tp,sl...
 

haha ...becuz that 's my holy grail...

i dont wish to share it out.

 
//+------------------------------------------------------------------+
//|                                                   NightMare1.mq4 |
//|                                             Copyright 2012, Abu. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, Abu."
#property link      "http://www.metaquotes.net"

extern string Name_Expert = "NightMare";
extern double StartHour1 = 0000;
extern double StopHour1  = 0759;
extern double StartHour2 = 0800;
extern double StopHour2  = 1859;
extern double StartHour3 = 1900;
extern double StopHour3  = 2359;
extern double LongTP1  = 80;
extern double ShortTP1 = 80;
extern double longSL1  = 150;
extern double ShortSL1 = 150;
extern double LongTP2  = 180;
extern double ShortTP2 = 180;
extern double longSL2  = 150;
extern double ShortSL2 = 150;
extern double LongTP3  = 50;
extern double ShortTP3 = 50;
extern double longSL3  = 150;
extern double ShortSL3 = 150;
extern double LotSize = 0.1;
extern double MaxOrders = 5;
extern double SafetyPercent = 50;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   if(AccountFreeMargin()<(SafetyPercent/100)*AccountBalance())
   {
   Print("We have no money. Free Margin = ", AccountFreeMargin());
   return(0);
   }
      if(Bars<50)
      {
      return(0);
      }
         if(OrdersTotal()>MaxOrders())
         {
         return(0);
         }
            double diClose0=iClose(NULL,5,0);
            double diMA1=iMA(NULL,5,5,0,MODE_EMA,PRICE_OPEN,1);
            double diClose2=iClose(NULL,5,0);
            double diMA3=iMA(NULL,5,4,0,MODE_EMA,PRICE_OPEN,1);
      
            if (TimeCurrent()>StartHour1())&(TimeCurrent()<StopHour1())
            {
                  if ((diClose0<diMA1))
                  {
                  OrderSend(Symbol(),LongTP1,0.1,Ask,3,Bid-15*Point,Bid+15*Point); //----
                  return(0);
                  }
                     else
                     if ((diClose2>diMA3))
                     {
                     OrderSend(Symbol(),ShortSL1,0.1,Ask,3,Bid-15*Point,Bid+15*Point); //----
                     return(0);
                     } 

            return(0);                      
            }
                     
            if (TimeCurrent()>StartHour2())&&(TimeCurrent()<StopHour2())
            {  
                  if ((diClose0<diMA1))
                  {
                  OrderSend(Symbol(),LongTP2,0.1,Ask,3,Bid-15*Point,Bid+15*Point) //----
                  return(0);
                  }
                     else
                     if ((diClose2>diMA3))
                     {
                     OrderSend(Symbol(),ShortSL2,0.1,Ask,3,Bid-15*Point,Bid+15*Point); //----
                     return(0);
                     }
            return(0);
            }        
            if (TimeCurrent()>StartHour3())&&(TimeCurrent()<StopHour3())
            {
                  if ((diClose0<diMA1))
                  {
                  OrderSend(Symbol(),LongTP3,0.1,Ask,3,Bid-15*Point,Bid+15*Point) //----
                  return(0);
                  }
                     else
                     if ((diClose2>diMA3))
                     {
                     OrderSend(Symbol(),ShortSL3,0.1,Ask,3,Bid-15*Point,Bid+15*Point) //----
                     return(0);
                     }
            return(0);                     
            }
   return(0);
   }
 

after i change that unbalanced left parenthesis error,

now another error appear ...

 
albert_lim83:

haha ...becuz that 's my holy grail...

Then go and pay someone for help and don't waste our time with your private bullshit problems.

Reason: