1. Use
ArrayResize[fastBuffer,true]; ArrayResize[fslowBuffer,true]; ArrayResize[priceBuffer,true];
- Your code is hard to read
2. There is no technical data at all - at least you need to display not just a 'bool' comparison result, you need to display the numbers that you are comparing
1. Use
- Your code is hard to read
2. There is no technical data at all - at least you need to display not just a 'bool' comparison result, you need to display the numbers that you are comparing
Thank you for diving into the problem. I found the answer.
The thing is the first tick doesn't appears at a timer event. When I set timer at last 10 seconds of trade period, error passed away.
Details:
I try to log MA1[1], MA2[1], MA1[0], MA2[0] numbers as you advised. At a moment log shows that theу are correspondingly equal. And I made a guess that in some moment when timer event occurs no ticks on current period is appeared. That's why the last closed bar is the same as for the previous timer event. Similarly for MA. Then MA1[1], MA2[1], MA1[0], MA2[0] are the same for two contiguous timer events. So first EA compares MA1 and MA2 twice before the crossing and we haven't conditions for start a position. And next EA compares MA1 and MA2 twice after the crossing. Thus it skips the signal. After setting timer at last 10 seconds of trade period problem disappeared.
I want to apologize for the fact that I thought it was an MT5 bug. And great thanks to you.Thank you for diving into the problem. I found the answer.
The thing is the first tick doesn't appears at a timer event. When I set timer at last 10 seconds of trade period, error passed away.
Details:
I try to log MA1[1], MA2[1], MA1[0], MA2[0] numbers as you advised. At a moment log shows that theу are correspondingly equal. And I made a guess that in some moment when timer event occurs no ticks on current period is appeared. That's why the last closed bar is the same as for the previous timer event. Similarly for MA. Then MA1[1], MA2[1], MA1[0], MA2[0] are the same for two contiguous timer events. So first EA compares MA1 and MA2 twice before the crossing and we haven't conditions for start a position. And next EA compares MA1 and MA2 twice after the crossing. Thus it skips the signal. After setting timer at last 10 seconds of trade period problem disappeared.
I want to apologize for the fact that I thought it was an MT5 bug. And great thanks to you.Why do you use a timer? You work in OnTick - and only when a new bar is born.
Why do you use a timer? You work in OnTick - and only when a new bar is born.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I make an MA based simple Expert Advisor. Recently I noticed a skipping of entry point. I dug deeper and found a bug.
EA enters the market at a crossing of slow and fast MA (please see the code below). In the beginning of each timeframe period EA compares the values of two MA's for the last closed candle an does the same for one candle before it. If relations are deffernt it opens a position. Very simple logic.
So I was wondered when it skipped an entry point. I decided to alert compare results, and found that in two different moments MQL gives different results for the same comparison of two numbers.
Look at the log screenshot. Marked values due to EA code should be the same.
Will be grateful for any feedback.