hidden feature in b670??

 

Hi,

I was looking at the source code of the Traders Dynamic Index.

First of all I cannot start this indicator by the debugger (- the green button is grey and so disabled??)

BUT I can attach it to a chart and it works perfectly!!

OK - Now I did this:

1) I saved the source code under a different name tdi_test.mq4 and I compiled it - no error, no warning :)

2) The debugger-button becomes green :))

3) I attached it to a chart - no problem, no array out of range :))))

4) I place a breakpoint at the first line after:

   int limit = Bars-counted_bars-1;
   for(int i=limit; i>=0; i--) {
      RSIBuf[i] = (iRSI(NULL,0,RSI_Period,RSI_Price,i)); // <= here is my debugger break point
      MA = 0;
      for(int x=i; x<i+Volatility_Band; x++) {
         RSI[x-i] = RSIBuf[x]; // 
         MA += RSIBuf[x]/Volatility_Band;
      }
      UpZone[i] = (MA + (1.6185 * StDev(RSI,Volatility_Band)));
      DnZone[i] = (MA - (1.6185 * StDev(RSI,Volatility_Band)));  
      MdZone[i] = ((UpZone[i] + DnZone[i])/2);
   }

Beside my breakpoint everything else is nothing but the original code!!

5) I start the indicator by debugger:

      1st loop: Bars=33298, i=33297, x=33297

      2nd loop-1: Bars=33298, i=33297, x=33298

and NOW I do get the (expected!!) array out of range.

(The RSIBuff is the first indicator buffer (size=Bars), the RSI array has the size of Volatility_Band)

As x-1=1 only the RSIBuff[x] is out of range - ok.

BUT WHY this code works if it not running in the debugger and why?

Ans NOW it does not work any more at a chart - its window is just empty.

Ok I removed it from the chart and re-applied it but I do get the array-out-of-range error and the indicator isn't working anymore.

Is it a hidden feature of the mt4 to tolerate initial array out of ranges?

Hard to understand the logic behind it!

For financial software one should stick to a kind of no-error-tolerance, it could become dangerous otherwise and you don't know when!

 

When using the Debugger the code is automatically compiled using #property strict, even if it doesn't exist in the code.

Without #property strict (old behavior) you don't get this "array out of range" error.

 
angevoyageur:

When using the Debugger the code is automatically compiled using #property strict, even if it doesn't exist in the code.

Without #property strict (old behavior) you don't get this "array out of range" error.

AAHHH! 

And I cannot define a 'no_strict' for the debugger - correct?
 
gooly:

AAHHH! 

And I cannot define a 'no_strict' for the debugger - correct?
Excat, you can't