Questions from Beginners MQL4 MT4 MetaTrader 4 - page 113

 
Hello!!! I want to do the following:
I need my EA to open all orders (Sell and Buy), even if they are already open and that it would do it not when all conditions converge, but on the next candle!!! Help plz......I am grateful in advance...

At the moment I have this in my code:

PHP code:
void start()
{
if(
NewBar())
{
// algorithm itself etc.
}
}

bool NewBar()
{
static
datetimelastbar=0;
datetime curbar=iTime(Symbol(),0,0);
if(
lastbar!=curbar)
{
lastbar=curbar;
return(
true);
}
return(
false);
}
 
qroner:
void Uchet_Orderov_Function(string _Simvol, int _Magic, int &_Mas[8]){
ArrayInitialize(_Mas, 0);
int Ticket=-1;
for(int pos=OrdersTotal()-1; pos>=0; pos--){
if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==_Simvol&&
OrderMagicNumber()==_Magic && OrderTicket()!=Ticket){
Ticket=OrderTicket();
switch(OrderType()){
case 0:{_Mas[0]++;_Mas[6]++;break;}
case 1:{_Mas[1]++;_Mas[6]++;break;}
case 2:{_Mas[2]++;_Mas[7]++;break;}
case 3:{_Mas[3]++;_Mas[7]++;break;}
case 4:{_Mas[4]++;_Mas[7]++;break;}
case 5:{_Mas[5]++;_Mas[7]++;break;}
}
}
}

}

Here's the function.

I just thought the problem wasn't in the code as there are no errors in standard mode.

Anyway, no one seems to answer...

 
qroner:

Anyway, no one seems to be answering...

The terminal tells you that the error is in line 69, but you show the program text, where there are fewer lines... How do you want to answer?
 
qroner: Anyway, it looks like nobody will answer...

There don't seem to be any errors in the function you posted. I am confused by the use of OrderTicket()!=Ticket to sift out adjacent orders with the same ticket. Check and make sure that there are no such orders. If the (69,25) is specified by the compiler , look at position 25 of line 69 - the error is there. Type this one line.

 
Vladimir: The terminal tells you that the error is line 69, but you show the program text with fewer lines... What do you want to answer based on?

I really wonder what he has in line 69

 

Phew, thought no one would react.

Here is that part of the code:

66 double Volatility(int _period){

67 double summ = 0;

68 for(int i=1; i<=_period; i++)

69 summ+=MathAbs(High[i]-Low[i])

70 return(NormalizeDouble(summ/_period, Digits))

71 }

Thanks for the tip

 
qroner:

Phew, thought no one would react.

Here is that part of the code:

66 double Volatility(int _period){

67 double summ = 0;

68 for(int i=1; i<=_period; i++)

69 summ+=MathAbs(High[i]-Low[i])

70 return(NormalizeDouble(summ/_period, Digits))

71 }

Thanks for the tip.

Everything is clear. The error is in the line summ+=MathAbs(High[i]-Low[i]); counting 25 positions from the edge will probably return to High[i].

I wrote Alert(Low[-1]); the compiler requires a positive number. I wrote int n=-1; Alert(Low[n]); - when executing Array out of rangre. But how can i<0 ??? maybe it's the lack of historical data? check the date interval from ... to ...

 

PLEASE ADVISE WHICH TRADER TO CHOOSE OR THE EXACT SERVER NAME

 
qroner:

Phew, thought no one would react.

Here is that part of the code:

66 double Volatility(int _period){

67 double summ = 0;

68 for(int i=1; i<=_period; i++)

69 summ+=MathAbs(High[i]-Low[i])

70 return(NormalizeDouble(summ/_period, Digits))

71 }

Thanks for the tip

double Volatility(int _period)
  {
    double summ = 0;

    for(int i=1; i<=_period; i++)
        if(ArraySize(High) > i && ArraySize(Low) > i)
           summ+=MathAbs(High[i]-Low[i]);

    return(NormalizeDouble(summ/_period, Digits));
 }
double Volatility(int _period)
  {
    double summ = 0;
    int src = MathMin(MathMin(_period, ArraySize(High)), ArraySize(Low));

    for(int i=1; i<src; i++)
        summ+=MathAbs(High[i]-Low[i]);

    return(NormalizeDouble(summ/_period, Digits));
 }

It seems that _period sometimes has a value larger than array items. Hence the array overruns.

Choose one of the options.

 
Good afternoon ! How can I create a trigger ? For example I need this condition if(iClose(NULL,HTF,4)<BlueLine) if it is executed DayDown = 1 ! Q: How can DayDown be left as 1 and not polled until the next day ?
Reason: