[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 14

 

the function itself will stop working, if there is a requote by the else condition

if ( res!=-1){    
//..
}else{
    err = GetLastError();
    if ( err > 1) try = 0;
    Comment("Ошибка - ", err);          
}

try = 0, so the while loop will stop and openOrder() returns false

But if we use the while(!openOrder(...)){} construct, then it will continue chugging until it opens an order

 
keekkenen . That's what I'm curious about in your start() function while(!openOrder(...)){} you don't disclose what is done there in {}. Do you limit the number of attempts at requotes?
 

Since you have written that the order should open, I have given such a "rigid" construction, if it should open, it will open regardless of how many attempts it takes... If we open orders normally, then while is not needed, we can pass the number of attempts in try and in the function already determine whether to react to critical errors or ignore them and just try to open the order try once...


The point of while(!openOrder(...)){} is that we create an eternal loop, i.e., it will work until the order is opened.

Actually, define what tactics should be used when opening orders, we will help...

 

Here's the question:

I can't work with an array.

I initialise the array, fill it with any data, but when I read it, there are zeros.

What am I doing wrong?


double MASS[];

for (int i = 0; i < 10; i++)
 {
  MASS[ i]= i;
 }
for (int n = 0; n < 10; n++)
 {
  Print( MASS[ n]);
 }
 
Kontra писал(а) >>

I can't work with an array.

You have to specify the size of the array, e.g. when declaring it:

double MASS[10];

Or then:

ArrayResize(MASS,10);
 

What if I don't know what size my array will be?

And even if I do, it doesn't compile:

I insert an external variable:

extern int Razmer = 10;

And the rest of the text:

   double MASS[ Razmer];

for (int i = 0; i < 10; i++)
 {
  MASS[ i]= i;
 }
for (int n = 0; n < 10; n++)
 {
  Print( MASS[ n]);

The output is:

'Razmer' - integer number expected C:\Program Files\MetaTrader - Alpari2\experts\temp.mq4 (36, 16)
']' - comma or semicolon expected C:\Program Files\MetaTrader - Alpari2\experts\temp.mq4 (36, 22)
'MASS' - variable not defined C:\Program Files\MetaTrader - Alpari2\experts\temp.mq4 (40, 3)
'MASS' - variable not defined C:\Program Files\MetaTrader - Alpari2\experts\temp.mq4 (44, 9)

 
Kontra писал(а) >>

What if I don't know what size my array will be?

So, you have to use the ArrayResize function when you know how many elements will be in the array.

With an external variable, as you can see, it won't work:)

You may do it this way:

ArrayResize(MASS,Razmer);
 

Thank you, dear Surgeon.

It's working :)

 
int init()
  { 
   double A=AccountBalance()         //Определяем баланс
   double B=NormalizeDouble( A/50,0)  //Выполняем вычисления и делаем результат целым числом
   double Lots= B*0.01                //Вычисление лота.

if ( Lots>0)Alert("Лот будет ", Lots )

   return(0);
  }
What is the error here and how can it be implemented?
 

What exactly are you trying to achieve?

Reason: