[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 546

 
who knows if the test speed can be increased?
 

Good afternoon. Can you advise me - the task is to draw vertical lines every minute. How to link the drawing not just to minutes, but to the opening price of the minute. The difficulty is that the opening price of the minute should be identified on non-standard time, i.e. not a minute. I have written a code snippet, but I do not understand how to enter the opening price of the minute, if the induced variable will be set to a non-standard time

new_Minute=TimeMinute(Time[i]) != TimeMinute(Time[i+1]); // new_Minute

Ind_Buffer_0[i]=0

if(new_Minute && Period()<30 ) Ind_Buffer_0[i]=max;

...and then the standard drawing using objects.

Maybe somebody can tell me what, if anything, can be done.

 
Lonely_man:

Good afternoon. Can you advise me - the task is to draw vertical lines every minute. How to link the drawing not just to minutes, but to the opening price of the minute. The difficulty is that the opening price of the minute should be identified on non-standard time, i.e. not a minute. I have written a code snippet, but I do not understand how to enter the opening price of the minute, if the induced variable will be set to a non-standard time

new_Minute=TimeMinute(Time[i]) != TimeMinute(Time[i+1]); // new_Minute

Ind_Buffer_0[i]=0

if(new_Minute && Period()<30 ) Ind_Buffer_0[i]=max;

...and then the standard drawing using objects.

Maybe somebody can tell me what, if anything, can be done.

The vertical line has no coordinate - price.
 
paladin80:
In while, we should set a condition that can accept at least two values, e.g. flag (true or false). If it is a constant (true) and not a condition, then while is not needed. Remove while (true) and brackets and you will get the same result.


If you remove the while statement, then how will the continue statement work?

After all, in case of an error, we need to re-check conditions and open orders.

 if (Fun_Error(GetLastError())==1)      // Обработка ошибок
 continue;                              // Повторная попытка
 return;                                // Выход из start()

The continue statement transfers control to the beginning of the nearest external while or for statement, causing the beginning of the next iteration.

Maybe I do not understand something?

 

Good afternoon.

I have a trading strategy formed to open pending orders on an already formed penultimate bar [number 1]. That is, it opens positions (pending orders for buystop and sellstop) and they will be triggered if the price moves 20 pips beyond the maximum/minimum of the price range of the 1st bar (Opening price).

There is also an automatic deletion of pending orders which have not been triggered, based on the following: If a new bar named 1 has been formed, the open price of a pending order(s) will not coincide with the maximum/maximum of the new current bar 1 +/- 20 pips (most probably, because highs/minimums of two adjacent bars rarely coincide).

But for some reason it happens so that first it will open both positions, but in a few seconds will close one of them (though the new bar under number 1 has not yet formed).

Gentlemen of experts, I am a beginner and maybe I am not taking into account some subtleties. Can you please tell me where the error is possible.

 RefreshRates();
for(int n=1;n<=OrdersTotal();n++)            //цикл перебора всех имеющихся ордеров
{
  if(OrderSelect(n-1,SELECT_BY_POS)==true)   //если найден ордер, то...
  {
    if((OrderType()==4)&& (OrderOpenPrice()!= High[1]+20*Point))                      // проверяем его тип (buystop/sellstop), если его тип buystop и цена покупки не совпадает с максимумом текущего 1-го бара, то..
      {
          OrderDelete(OrderTicket());                                                  // удаляем его
         
       }
    if((OrderType()==5) && (OrderOpenPrice()!= Low[1]-20*Point))                       // если его тип sellstop и цена продажи не совпадает с минимумом текущего 1-го бара, то ...
    {      
           
            OrderDelete(OrderTicket());                                                //удаляем его
         
    }
  }
}
Files:
 

When comparing fractional numbers, they must be normalised to a significant digit.

When deleting orders, count down from the end, not the beginning.

 
... that's right,- and also - forbid the expert to work until a new bar has been formed.
 
Pacman:


If you remove the while statement, how will the continue statement work?

After all, in case of an error, we need to re-check conditions and open orders.

The continue statement transfers control to the beginning of the nearest external while or for statement, causing the beginning of the next iteration.

Maybe I don't understand something?

Don't worry, while(true) statements are very often used when neither the number of iterations, nor the conditions for loop termination are known.

That's why its termination, say, when many conditions nested in the given loop are fulfilled, is terminated by the break operator.

Or else, there are owls (for example, mcllts) that work not by a tick and therefore not with start function, but continuously and loop on a continuous basis usingwhile(true) operator.

 
Equilibrium:
Hello, good day, please help me, I can not debug my Expert Advisor (opening and closing orders do not work as expected (by crossing a stochastic each time), open at stochastic very rarely and I can not understand why ((((), also all orders are closed only at stoplo or takeprofit (Ticket number error, also can not understand where the error). thanks for any answers:

The Ticket error is most likely because your Ticket variable is initialized twice - at the beginning and in the function

Try another name in the function, at leastTicket1 :)

 
Can you tell me how to find out the price of the trend line on each bar?