iStochastic - array out of range

 

Hi Experts,

I use iStochastic function to check Main and Signal values and do something with them.

but when i call the array, the error <array out of range> shown in the journal section.

the code is here:

int stoHandle;
double mainLin[];
double sigLin[];
ArraySetAsSeries(mainLin,true);
ArraySetAsSeries(sigLin,true);

stoHandle=iStochastic(_Symbol,_Period,21,3,3,MODE_SMA,STO_LOWHIGH);
CopyBuffer(stoHandle,0,0,3,mainLin);
CopyBuffer(stoHandle,1,0,3,sigLin);
Print(mainLin[0], " : " , sigLin[0]);

I did this with many indicators like iADX, iMA, etc...

Only iStochastic Shows (array out of range)

any help will be appreciated

 
alitavana:

Hi Experts,

I use iStochastic function to check Main and Signal values and do something with them.

but when i call the array, the error <array out of range> shown in the journal section.

the code is here:

I did this with many indicators like iADX, iMA, etc...

Only iStochastic Shows (array out of range)

any help will be appreciated

Interesting... no problem on my PC.

 
  1. CopyBuffer(stoHandle,0,0,3,mainLin);
    CopyBuffer(stoHandle,1,0,3,sigLin);
    To avoid the error Check your return codes for errors, and report them including GLE/LE. Don't look at it unless you have an error. Don't just silence the compiler, it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
    Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.

  2. It takes time to compute, get the handle in OnInit.
This website uses cookies. Learn more about our Cookies Policy.