Please help

 

I am new to programming and got stuck with this error message saying unbalanced left parenthesis at the end. I checked and couldn't find where a parenthesis is left out. Please could somebody help me out! Many thanks for your time.



//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()

{
int counted_bars=IndicatorCounted();

int limit, i;
//---- indicator calculation
if (counted_bars==0)
{
if(Period() > 1440)
{
Print("Error - Chart period is greater than 1 day.");
return(-1); // then exit
}

}
if(counted_bars<0) return(-1);

limit=(Bars-counted_bars)-1;


for (i=limit; i>=0;i--)
{


// Monday
if ( 1 == TimeDayOfWeek(Time[i]) && 1 != TimeDayOfWeek(Time[i+1]) )
{
last_week_close = Close[i+1];
this_week_open = Open[i];

// WeeklyPivot
P = (last_3week_high + last_3week_low + last_week_close) / 3;

R1 = (2*P)-last_3week_low;
S1 = (2*P)-last_3week_high;
R2 = P+(last_3week_high - last_3week_low);
S2 = P-(last_3week_high - last_3week_low);
R3 = (2*P)+(last_3week_high-(2*last_3week_low));
S3 = (2*P)-((2* last_3week_high)-last_3week_low);

last_3week_low=iLow(NULL, 0, iLowest(NULL,0,MODE_LOW, 3, i);
last_3week_high=iHigh(NULL, 0, iHighest(NULL,0,MODE_HIGH, 3, i);


LabelShiftTime = Time[LabelShift];

ObjectCreate("WeeklyPivot", OBJ_TEXT, 0,LabelShiftTime,0);
ObjectSetText("WeeklyPivot", " Weekly Pivot Point "+DoubleToStr(P,4),fontsize,"Arial",PivotLabelColor);
SetIndexLabel(0, "W Pivot Point");
ObjectCreate("WSup1", OBJ_TEXT, 0, 0, 0);
ObjectSetText("WSup1", " W S1 "+DoubleToStr(S1,4),fontsize,"Arial",SupportLabelColor);
SetIndexLabel(1, "WSup1");
ObjectCreate("WRes1", OBJ_TEXT, 0, LabelShiftTime, 0);
ObjectSetText("WRes1", " W R1 "+DoubleToStr(R1,4),fontsize,"Arial",ResistanceLabelColor);
SetIndexLabel(2, "WRes1");
ObjectCreate("WSup2", OBJ_TEXT, 0, LabelShiftTime, 0);
ObjectSetText("WSup2", " W S2 "+DoubleToStr(S2,4),fontsize,"Arial",SupportLabelColor);
SetIndexLabel(3, "WSup2");
ObjectCreate("WRes2", OBJ_TEXT, 0, LabelShiftTime, 0);
ObjectSetText("WRes2", " W R2 "+DoubleToStr(R2,4),fontsize,"Arial",ResistanceLabelColor);
SetIndexLabel(4, "WWRes2");
ObjectCreate("WSup3", OBJ_TEXT, 0, LabelShiftTime, 0);
ObjectSetText("WSup3", " W S3 "+DoubleToStr(S3,4),fontsize,"Arial",SupportLabelColor);
SetIndexLabel(5, "WSup3");
ObjectCreate("WRes3", OBJ_TEXT, 0, LabelShiftTime, 0);
ObjectSetText("WRes3", " W R3 "+DoubleToStr(R3,4),fontsize,"Arial",ResistanceLabelColor);
SetIndexLabel(6, "WRes3");
ObjectMove("WeeklyPivot", 0, LabelShiftTime,P);
ObjectMove("WSup1", 0, LabelShiftTime,S1);
ObjectMove("WRes1", 0, LabelShiftTime,R1);
ObjectMove("WSup2", 0, LabelShiftTime,S2);
ObjectMove("WRes2", 0, LabelShiftTime,R2);
ObjectMove("WSup3", 0, LabelShiftTime,S3);
ObjectMove("WRes3", 0, LabelShiftTime,R3);

}

last_3week_high = MathMax(last_3week_high, High[i]);
last_3week_low = MathMin(last_3week_low, Low[i]);
PBuffer[i]=P;
S1Buffer[i]=S1;
R1Buffer[i]=R1;
S2Buffer[i]=S2;
R2Buffer[i]=R2;
S3Buffer[i]=S3;
R3Buffer[i]=R3;

}

//----
return(0);
}
//+------------------------------------------------------------------+

 
Please use this to post code . . . it makes it easier to read.

 

Sure I could find it for you but then you wouldn't have learned anything. This unbalanced parenthesis problem is common. Here's some ways to find it:

1) Figure out what you were last changing and look there.

2) Compile frequently so you never get too far from a problem area.

3) Comment out huge sections of code using /* */ over many lines until the problem area is found. Halve the size of the commented out area and repeat. This "binary search" doesn't take too long.


The way to find the problem is infinitely more valuable than just finding the missing bracket for you.

 

Try here . . .

last_3week_low=iLow ( NULL, 0, iLowest ( NULL,0,MODE_LOW, 3, i ) ; 
last_3week_high=iHigh ( NULL, 0, iHighest ( NULL,0,MODE_HIGH, 3, i ) ;
 
RaptorUK:

Try here . . .

Spoiler alert :-(
 
RaptorUK:

Try here . . .

. . . and next time look for more than 30s
 
dabbler:
Spoiler alert :-(
Sorry . . . posts crossed in the ether.
 

Parenthesis hunting can also be made slightly easier by changing font so the parenthesis is more easily seen.

Making sure you keep indenting your code for each new parenthesis and closing it before you continue writing code between the new parenthesis

commenting the closng parenthesis with the line of code that opend it.

 
Ickyrus:
Parenthesis hunting can also be made slightly easier by changing font so the parenthesis is more easily seen.
Or use a syntax highlighting text editor like notepad2
 
dabbler:

Sure I could find it for you but then you wouldn't have learned anything. This unbalanced parenthesis problem is common. Here's some ways to find it:

1) Figure out what you were last changing and look there.

2) Compile frequently so you never get too far from a problem area.

3) Comment out huge sections of code using /* */ over many lines until the problem area is found. Halve the size of the commented out area and repeat. This "binary search" doesn't take too long.


The way to find the problem is infinitely more valuable than just finding the missing bracket for you.

neat little trick "Comment out huge sections of code using /* */ over many lines until the problem area is found. Halve the size of the commented out area and repeat. This "binary search" doesn't take too long."

thanks....

 
Reason: