Miracles with the tester. - page 2

 
Tried different ways - and
ArrayInitialize
и
Циклом 
// ===Если это первый запуск обнулим все буферы:)
if(prev_calculated <= 0)// проверка на первый старт расчёта индикатора
{
for(int i=0;i<=rates_total-1;i++)
{
eeee[i]=EMPTY_VALUE;
}
//Print("!!!Обнулили все буферные массивы!!!");
}

Запускаю первый тест - выдает фигню, второй раз - еще фигню, с третьего раза начинает выдавать правдивый результат уже постоянно.
Не могу понять в чем дело.

Тестировал сегодня с 13.02.12 - 25.02.12 - всего один сигнал на продажу и один сигнал на закрытие продажи.
Как и говорил - с третьего раза начинает постоянно выдавать уже правдивый результат - а до этого ерунду выдает.
А теперь представьте, что вы запускаете оптимизацию - я же не могу по три раза оптимизацию запускать, - короче я не знаю что делать.
Могу конечно код индюка вставить в советник - но вызывать его удобнее из другого индюка.
Кто еще что скажет.

Выкладываю исходники - они уже настроены. 
Запустите тест на ЕвроБакс с 13.02.12 - 25.02.12 - правильный результат -35.20. А будет тестер выдавать первые разы короче хрень.
Я не вижу ошибки в коде - вот как бы в чем дело. Часть кода из статей, часть свой.
Хочеться конечно найти причину и доверять тестеру с первого раза - особенно это касается оптимизации.

Files:
MQL5.zip  269 kb
 
1CMaster:
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.

Усреднение ценовых рядов без дополнительных буферов для промежуточных расчетов
Усреднение ценовых рядов без дополнительных буферов для промежуточных расчетов
  • 2010.10.25
  • Nikolay Kositsin
  • www.mql5.com
Статья о традиционных и не совсем традиционных алгоритмах усреднения, упакованных в максимально простые и достаточно однотипные классы. Они задумывались для универсального использования в практических разработках индикаторов. Надеюсь, что предложенные классы в определенных ситуациях могут оказаться достаточно актуальной альтернативой громоздким, в некотором смысле, вызовам пользовательских и технических индикаторов.
 
1CMaster:

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.
 
1CMaster:

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.

 
MoneyJinn:

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

   if(prev_calculated==0)
     {
      ArrayInitialize(SignalBuyBuffer,0);
      ArrayInitialize(SignalSellBuffer,0);
      ArrayInitialize(HighBuffer,0);
      ArrayInitialize(LowBuffer,0);
      ArrayInitialize(OpenBuffer,0);
      ArrayInitialize(CloseBuffer,0);
      ArrayInitialize(ColorBuffer,0);
      ArrayInitialize(TrendBuffer,0);
     }

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)

//---- основной цикл расчета
   for(i=first; i<rates_total && !IsStopped(); i++)
     {     
       SignalBuyBuffer[i]=0;
        SignalSellBuffer[i]=0;
        HighBuffer[i]=0;
        LowBuffer[i]=0;
        OpenBuffer[i]=0;
        CloseBuffer[i]=0;
        ColorBuffer[i]=0;
        TrendBuffer[i]=0;

        if(i == 88366 )
        {
         Print(""+DoubleToString(maxHigh,5)+": "+DoubleToString(minLow,5));
        }

        maxHigh=high[iHighest(high,period,i-1)];
        minLow=low[iLowest(low,period,i-1)];        
        if(open[i-1] > close[i-1]) {

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)

                    ~TBalanceSlopeCriterion() { delete(balance_Ptr); }
 
Thank you all. I will be testing further.
 

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

 
Optimisation and single pass results do not match (service-desk - #329165 + EA there)
Reason: