Thank you for your clarification. It is most helpful.
Can you please confirm that, as implied by the examples and documentation, assigning a value to an array element beyond the existing array bounds automatically resizes the array.
Also pay attention to numerical sequence, which gives out the generator pseudo-casual number MathRand () without use of preliminary initialization MAthSrand () .
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Thank you for your clarification. It is most helpful.
Can you please confirm that, as implied by the examples and documentation, assigning a value to an array element beyond the existing array bounds automatically resizes the array.
Regards,
Mobius
//+------------------------------------------------------------------+ //| CheckArraysExpertAdvisor.mq4 | //| Copyright © 2007, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- double testArray[]; datetime currTime=TimeCurrent(); string timeinstring=DoubleToStr(currTime,0); string oldArray,newArray; int i,lastDigit=StrToInteger(StringSubstr(timeinstring,StringLen(timeinstring)-1))+3; int prevSize,currSize; Print("timeinstring=",timeinstring," lastDigit=",lastDigit); prevSize=ArraySize(testArray); currSize=lastDigit; for (i=0;i<prevSize;i++) oldArray=StringConcatenate(oldArray,"|",DoubleToStr(testArray[i],0)); ArrayResize(testArray,currSize); if (currSize>prevSize) for (i=prevSize;i<currSize;i++) testArray[i]=MathRand(); for (i=0;i<currSize;i++) newArray=StringConcatenate(newArray,"|",DoubleToStr(testArray[i],0)); Print("prevSize=",prevSize," ,currSize=",currSize); Print(oldArray); Print(newArray); Print("Waiting a new tick..."); //---- return(0); } //+------------------------------------------------------------------+"MQL4: MathRand"
"MQL4: MathSrand"