Lesson 14 - Your First Expert Advisor (Part 2)

 
Files:
lesson14.pdf  89 kb
 

finally the part 2 is out, thank you very much.

have been waiting for a life time

 

Sorry!

fubifx:
finally the part 2 is out, thank you very much. have been waiting for a life time

fubifx,

I'm so sorry for the delay.

I have a damn car that I spent the most of my time repairing it.

If you lend me your car, maybe I write the lesson everyday

 

Error and Question

Stop losses points are always set above the current asking price on a buy or below the current bid price on a sell.

I believe that should be "Stop losses are always set BELOW the current bid price on a buy and ABOVE the current asking price on a sell"

Question: Why is the line

int Crossed (double line1 , double line2)

positioned where it is, i.e., after the expert deinitialization function and before the expert start function?

Thanks again for a great course!

 

Thanks!

barry:
I believe that should be "Stop losses are always set BELOW the current bid price on a buy and ABOVE the current asking price on a sell"

Hi Barry,

You are right! I'll change that.

barry:
Question: Why is the line
int Crossed (double line1 , double line2)[/CODE] positioned where it is, i.e., after the expert deinitialization function and before the expert start function? Thanks again for a great course!

int Crossed (double line1 , double line2)

The above line is the function declaration

It means we want to create Crossedfunction which takes two double data type parametersand returnsan integer.

When you callthis function you have to pass to it two double parameters and it will return an integer to you.

[CODE] shortEma = iMA(NULL,0,8,0,MODE_EMA,PRICE_CLOSE,0);

longEma = iMA(NULL,0,13,0,MODE_EMA,PRICE_CLOSE,0);

int isCrossed = 0;

isCrossed = Crossed (shortEma,longEma);

You have to declare the function before using (calling) it. The place of the function doesn't matter, I placed it above start() function, but you can place it anywhere else.

 

Can we download all the lessons?

Thanks al lot

 

All the lessons

zhu28ming:
Can we download all the lessons? Thanks al lot

zhu28ming,

You will find a list with all the lessons here:

https://www.mql5.com/en/forum

 

Indicators into Experts

Hi

Code Guru

How do we make a indicator into a expert ?

Doc

 

Some fundamental questions

The program is running all the time? i mean so i can save the info in an array between every tick?

And the "int start()" function runs once for every tick?

Thanks in advance iincome

 

How to add arrows to Expert Advisor?

Please for the help: how to add to Expert Advisor pointers (arrows) showing coming into being of trading conditions (but not the concrete transaction!). This would be very useful for the purpose of the visual presentation of the rightness of the prompt from the EA under of tests before transactions.

I know that one can add pointers to indicators using code:

//---- indicator line

IndicatorBuffers(2);

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0,233);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1,234);

........

But what to make, if EA uses with several indicators. Then pointers would be added to EA code. Please for the help how can I make this.

 

change indicators

hi guru,

please help,

how to change ema to wma? and how to make it works with all pairs and in all timeframe?

thx,

dede