Lesson 13 - Your First Expert Advisor (Part 1) - page 4

 

Unmatched Parentheses and Brackets

Some additional suggestions

Count the parentheses or brackets by incrementing by 1 for lefts and decrementing by one for rights. At the end, you should be zero, if positive or negative, then check where the missing or additional one should be.

Be sure your parentheses are () and your brackets are {}. With the small font and weak eyes, like mine, occasionally you may mistype a ) for a }. Substituting or retyping the intended character may correct the problem.

Use ctl z (undo) and ctl y (redo) to help you back track in your recent changes.

Finally, when all else fails comment out lines or partial lines with // and also comment out sections with /* */. When you comment out code and it compiles correctly, you know the error is in the commented out code. Then reduce the commented section and recompile again. if it fails, you know it is in the most recent uncommented code; if the compile succeeds, then it is still in the commented code. Soon you will narrow it down to a line or two.

Hope this helps, I have been coding for a long long time and matching () and {} still pose problems.

Tzuman

 

The persistent problem

Thank you for your advice, but as you can see from the screenshot I do visualy separate the codes for easyer understanding. I have counted the brackets multiple times from the begining of the code to the end and i have the same amount of opening brackets as the amount of closing brackets (for ifloops - {}, and for function parameters - ()). I do know other programing languages so it isn't a problem of explaining or understanding.

Thank you again for helping me.

 

Thanks for the great advice Tzuman.

Ish

 

Someone can help me? I'm going crazy. I can not finish this indicator (my first code) because this error appears. I already have revised the code and I can't find the wrong part.

the indicator code:

for_a_new_life.mq4

Files:
 
Kelch Monteiro:
Someone can help me? I'm going crazy. I can not finish this indicator (my first code) because this error appears. I already have revised the code and I can't find the wrong part.

the indicator code:

for_a_new_life.mq4

This is OK now as far as syntax is concerned but I do not know what should MA() do (it is not defined as a function within the code). You have to define a MA() function and replace "Period" in a call to it with some other name (or else metatrader will complain all the time)

Files:
 
mladen:
This is OK now as far as syntax is concerned but I do not know what should MA() do (it is not defined as a function within the code). You have to define a MA() function and replace "Period" in a call to it with some other name (or else metatrader will complain all the time)

thanks mladen!

I forgot the "i" before the "MA". lol.

Well I was trying to do build something with the reason between the diference of two Emas (fast and slow) and 2times of the force indicator. But I don't know how write the force indicator because it have the relation between the applied and previous bar. I'll smoke a cigarette in the porch and I'll try again.

 
mladen:
This is OK now as far as syntax is concerned but I do not know what should MA() do (it is not defined as a function within the code). You have to define a MA() function and replace "Period" in a call to it with some other name (or else metatrader will complain all the time)

I know what's wrong. I have to create the force index, and call it there in the formula. Should I create a buffer and one array, is correct?

 
Kelch Monteiro:
I know what's wrong. I have to create the force index, and call it there in the formula. Should I create a buffer and one array, is correct?

Kelch

Depends what that MA should do

If it is a simple moving average (iMA()) than you do not need one more buffer.

 

Kelch

Been looking at the formula : (FastEMA-SlowEMA/[2*Cn-(Cn-1)]*Vn])

Tried to translate it (I assumed the Cn and Cn-1 are close and previous close). Try it out

Files:
 
mladen:
Kelch

Been looking at the formula : (FastEMA-SlowEMA/[2*Cn-(Cn-1)]*Vn])

Tried to translate it (I assumed the Cn and Cn-1 are close and previous close). Try it out

really thanks mladen!

I saw it now.

I did the same. take a look:

for_a_new_life-1.ex4

for_a_new_life-1_1.mq4

I was testing the mine version and will test the yours too.

If this indicator is correctly, we did some great to catch reversal points.

it's because the difference between the both moving averages divided by the 2times force, can show when price is reverting in a trend with more sensitivity. Test it with another border indicator and I think you'll like.

some pics:

I'm too glad because this is my first contribution to the forum. And I could not did it without your help.

Many thanks Mladen!

Files:
five.jpg  202 kb
four.jpg  233 kb
one.jpg  205 kb
Reason: