Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 737

 
Alexey Viktorov:
What is the dimensionality of the NewsArr array in the second dimension?

Unfortunately, I don't understand. What is the second dimension?

Ah, I guess I get it: NewsArr takes on values 0,1,2 and 3. This?

This must be: string NewsArr[4][1000];

 
novichok2018:

Unfortunately, I don't understand. What is the second dimension?

Ah, I guess I get it: NewsArr takes on values 0,1,2 and 3. This?

This must be: string NewsArr[4][1000];

First dimension and second dimension.

But it's probably the wrong answer.
 
Alexey Viktorov:

The first dimension and the second dimension.

But you must have answered something wrong.

Where do I look for the dimensionality of the second dimension?

Or is the dimensionality of the first dimension 4 and the second dimension 1000?
 
novichok2018:

And where do you look for the dimensionality of the second dimension?

Or is the first dimension 4 and the second 1000?

Yes. But something is messed up in this post

Forum on trading, automated trading systems and strategy testing

Any questions newbies have on MQL4, help and discussion on algorithms and codes

novichok2018, 2019.01.16 15:52

Probably a silly question since no one is answering, but how else to deal with EA stopping and resuming after compilation?

The platform gives a message:array out of range (284,17).

line 284: NewsArr[0][NomNews]=StringSubstr(TEXT,sh,sh2-sh);position 17 opens a square bracket with NomNews, which is globally initiated by 0.

I changed 0 to 1, to no avail.
Changed the line if(NomNews==300)break; 300 to 360000, to no av ail.

I compile it - it works fine for a few minutes. And what to do?

When the number of values in the second dimension is 1000 and

if(NomNews==300)break;
There can't be an array overrun in the second dimension.


 
psyman:

I have no anchor points, only vertical movement, and I set the horizontal once across the width of the screen. It's not a problem to count from the other side, but it's surprising that the same action is performed differently in different functions.


And another question - if I want to output Bid as a label text, which function should I use to do it optimally -OnChartEvent orOnCalculate?

OBJ_LABEL has an anchor point even if you didn't set it. By default it is the upper left corner. The Bid is changed in OnCalculate and you can change the text in the label there.

 
Alexey Viktorov:

Yes. But there is something confusing in this message

When the number of values in the second dimension is 1000 and

There cannot be an array out of range in the second dimension.


No, there seems to be no confusion. Here is the copied message: 2019.01.16 20:14:11.110 OnNews_M5_EURUSD EURUSD,M5: array out of range in 'OnNews_M5_EURUSD.mq4' (284,17).

I showed line 284 above.
 
novichok2018:

No, I don't think I've got anything wrong. Here is the copied message: 2019.01.16 20:14:11.110 OnNews_M5_EURUSD EURUSD,M5: array out of range in 'OnNews_M5_EURUSD.mq4' (284,17).

I showed line 284 above.

Position 17 opens a square bracket with NomNews, which is globally initiated by 0.

So, you have a zero-dimensional array cell size in the second dimension...

 
Artyom Trishkin:

So your array cell size in the second dimension is zero...

This is whereNomNews is located:

datetime TimeNewsFunck(int nomf)

{

string s=NewsArr[0][nomf];

string time=StringConcatenate(StringSubstr(s,0,4),".",StringSubstr(s,5,2),".",StringSubstr(s,8,2)," ",StringSubstr(s,11,2),":",StringSubstr(s,14,4));

return((datetime)(StringToTime(time) + GMTplus*3600))

}

//345678901234567890////////////////////////////////////////////////////////////////////////////////

void UpdateNews()

{

string TEXT=ReadCBOE();

int sh = StringFind(TEXT, "pageStartAt>")+12;

int sh2= StringFind(TEXT,"</tbody>");

TEXT=StringSubstr(TEXT,sh,sh2-sh);


sh=0;

while(!IsStopped())

{

sh = StringFind(TEXT, "event_timestamp",sh)+17;

sh2= StringFind(TEXT, "onclick",sh)-2;

if(sh<17 || sh2<0)break;

NewsArr[0][NomNews]=StringSubstr(TEXT,sh,sh2-sh);


sh = StringFind(TEXT,flagCur,sh)+10;

sh2= sh+3;

if(sh<10 || sh2<3)break;

NewsArr[1][NomNews]=StringSubstr(TEXT,sh,sh2-sh);

if(OnlySymbolNews && StringFind(ValStr,NewsArr[1][NomNews])<0)continue;


sh = StringFind(TEXT, "title",sh)+7;

sh2= StringFind(TEXT, "Volatility",sh)-1;

if(sh<7 || sh2<0)break;

NewsArr[2][NomNews]=StringSubstr(TEXT,sh,sh2-sh);

if(StringFind(NewsArr[2][NomNews], "High")>=0 && !HighNews)continue;

if(StringFind(NewsArr[2][NomNews], "Moderate")>=0 && !MidleNews)continue;

if(StringFind(NewsArr[2][NomNews], "Low")>=0 && !LowNews)continue;


sh=StringFind(TEXT, "left event",sh)+12;

int sh1=StringFind(TEXT, "Speaks",sh);

sh2=StringFind(TEXT,"<",sh);

if(sh<12 || sh2<0)break;

if(sh1<0 || sh1>sh2)NewsArr[3][NomNews]=StringSubstr(TEXT,sh,sh2-sh);

else NewsArr[3][NomNews]=StringSubstr(TEXT,sh,sh1-sh);


NomNews++;

if(NomNews==300)break;

}

}

Values from 0 to 300. Set globally to 4?

 
novichok2018:


Values from 0 to 300. Should I set it globally to 4?

It still gives a message at 12 minutes.

 
novichok2018:

Still gives a message at the 12th minute.

I can tell from all this that NomNews gets into the While loop already in a state greater than 999. Then you need to find out what is causing it and reset this variable somewhere.

To check this, write it at the beginning of the loop:

if(NomNews > 999)
{
   Print(NomNews);
   break;
}