Moving average is not updating its value - page 2

 
FMIC:

 You are using the"start()" event handle which is called every tick and you are checkingthe iATR() and iMA() values on every tick but stuck in a loop.

Please study more examples in the Tutorial and in Code Base until you understand this!


It doesn't matter that I'm stuck in a loop because I made an external function and I call this function inside the loop. But still I'm getting the same values.
 
bmhassene1: It doesn't matter that I'm stuck in a loop because I made an external function and I call this function inside the loop. But still I'm getting the same values.

Don't you think that when someone more experience tells you, that your code for a Tick Event Handler should NOT be in a loop, that maybe he knows a little more about it than you?

The "start()" function is an event handler. It is NOT like the "main()" function in C. An event handler should handle the event (in this case for a single tick) and then release the thread so that it can continue processing and be called again for the next tick event. Your "external function" will be of little use if your processing is not done correctly, especially in the Strategy Tester which will pause the incoming Tick Data until you return from the event handler.

Also, please use the modern updated style of MQL programing which is the OnTick(), OnInit(), etc. instead of the older methods.

 
bmhassene1: It doesn't matter that I'm stuck in a loop because I made an external function and I call this function inside the loop. But still I'm getting the same values.
You get the same values because you are "stuck in a loop." "It doesn't does Matter."
You asked for help. We have given you the answer and you rejected it.
 

Ok thanks for your answer FMIC 

 WHRoeder Chill I'm just debating to understand better the process I'm not rejecting anything :)

 
bmhassene1: Chill I'm just debating to understand better the process I'm not rejecting anything :)
"It doesn't matter that I'm stuck in a loop" sure sounds like a rejection to me, and it is definitely not a question.
 
bmhassene1:

It doesn't matter that I'm stuck in a loop because I made an external function and I call this function inside the loop. But still I'm getting the same values.

The fact that the values do not change should tell you that it DOES matter that you are stuck in a loop!

I don't pretend to know exactly how indicator calls such as iMA are handled by mql4, but it is obvious that the indicator is running in the background and working with the same data that is available to the EA.

No new tick for the EA, no new tick for the background indicator, so while stuck in a loop, the indicator is not updated.

Now you could  possibly get over this by a RefreshRates() before the iMA calls to update the data available to the EA and therefore the indicator, but I don't believe that this is a good idea. Far better to get rid of the loop altogether.

Reason: