
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Is there a link to correct use of iCustom() taking into account these nuances ??? Because I'm tired of checking it and looking for what's wrong.
Take a look at the article Indicator by Indicator in MQL5:
Is it necessary to initialize indicator buffers?
Arrays in MQL5 are not initialized by default with any value, and this certainly applies to arrays that are assigned to indicator buffers using SetIndexBuffer(). If an array is an indicator buffer, its size will depend on the rates_total parameter in the OnCalculate() handler.
There may be a temptation to initialize all the indicator buffers with empty EMPTY_VALUE value using the ArrayInitialize() function, for example, once at the beginning of OnCalculate().
...
Dear Rosh - I read this article, but could not apply it, because I use the second form of OnCalculate call, because I need the time of each bar, not just the price.
The reason really is that there is junk in the indicator buffer. And the initialization of the buffer with empty values gives nothing, because in the tester, when new data appears, the indicator buffer automatically grows and in the beginning it really contains rubbish, and if the buffer is not filled on each bar, the rubbish stays there.
My EA runs on timer - it's much faster than OnTick() for some reason. And I can test it at weekend.
I am trying to find out what sits in each indicator buffer. The complexity is that one indicator calls another one based on its values.
I will try to select a clear period and set the size of buffers. I will determine the cause of false positives in the tester. Eh - it's a pity the tester doesn't have a debugger - everyone has been waiting for it.
I have an EA running on a timer - it's much faster than OnTick() for some reason. You can test it on weekends as well.
There is an article tester basics in MetaTrader 5 where it is shown:
We measured the testing time at different values of the timer parameter (the Timer event period). A graph showing the dependence of the testing time T on the Periodicity value was plotted on the obtained data.

It is clear that the smaller timer parameter at initialization of the timer by EventSetTimer(timer) function, the less period between OnTimer() handler calls and the longer testing time T under the same conditions.If real rubbish appears in iCustom(), the problem is definitely in initialisation.
Initialise the buffer with zero rather than Empty_Value. When each new bar appears, don't forget to zero the corresponding buffer cell.
If real rubbish appears in iCustom(), the problem is definitely in initialisation.
Initialize the buffer with zero instead of Empty_Value. When each new bar appears, do not forget to zeroize the corresponding buffer cell.
Yes, I did. In every indicator I make sure to zero out the values first - helped get rid of the rubbish.
for(i=first;i<rates_total-1 && !IsStopped();i++)
{EnterBuffer[i]=0;
EditBuffer[i]=0;
ExitBuffer[i]=0;
....
}
Now I'm testing it on the minute chart. On the hourly chart everything is working like clockwork)))) I do have some questions about the EA on the 1-minute chart.
As expected - no initialisation. In the FB indicator.
First of all, in the beginning of the OnCalculate function we should add the arrays initialization
Because the initialization that you have, does not always work
Secondly, in the main calculation cycle, at the very beginning of the cycle, add initialization of zero elements of arrays (for when a new bar is added to the chart, the indicator arrays are automatically increased, and these new elements are not initialized in any way, neither explicitly because prev_calculated>0, nor implicitly)
Besides, in CustomOptimisation.mqh in TBalanceSlopeCriterion class a destructor must be added (it doesn't affect the result, but it leads to memory leakage during testing)
I had a miracle with the tester too.
I test an EA with one name: the tester draws objects
...I saved and compiled the EA under another name::no objects
But I noticed that I have moved the terminal to another drive