Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
We have reached the edge of the moon in our way to the truth, I’m not under the impact of alcoholic poisoning (I don’t drink at all), but I’m so happy to reach the last part of explaining or first expert advisor. Yes! This is the last part of the expert advisor lesson.
I hope you enjoyed the journey discovering how to write our simple yet important expert advisor.
Yep, excellent work, thanks for all this amazing help. It's going to take a few days to get to grips with all this but it's been really helpful to have your lessons.
you have decleared the two static variables inside the block of the function. then every time start function recieves a quote it will call the crossed function,and every time when start calls crossed, crossed will first initilize the two varibles to zero,so how could you compare current_direction with last_direction?
int Crossed (double line1 , double line2)
{
static int last_direction = 0;
static int current_dirction = 0;
you have decleared the two static variables inside the block of the function. then every time start function recieves a quote it will call the crossed function,and every time when start calls crossed, crossed will first initilize the two varibles to zero,so how could you compare current_direction with last_direction?
int Crossed (double line1 , double line2)
{
static int last_direction = 0;
static int current_dirction = 0;
There are two kinds of variables in MQL4, normal variables and static variables;
The static variables are very like the normal variables with only one extra feature:
The initialization of the static variables occurs only one time.
Which means if you write a line of code like that:
static int last_direction = 0;
You mean:
If this is the first call of the program, initialize the variable to 0, else (if it's the second, third, fourth etc call) don't initialize the variable again.
But if you used a normal variable instead of static variable, every time you call your program the initialization of the variable will be occurred.