[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 398

 
How can I use synthetic bars(https://www.mql5.com/ru/articles/1353 ) to make the function inside the EA work only on open prices? On regular bars it was done by the open time of the current bar, like this if (Time[0] == prevtime4) return;
prevtime4=Time[0]; but the synthetic bars are without time...in theory you can write here if bid is the opening price, but I don't know how to do it.
 

How can I find the maximum tails of buy candlesticks?

I.e. the current candlestick is built, the previous buy candlestick, we determined the tail of the buy candlestick, then we continue to build the chart, the buy candlestick appears again and again we calculated the tail,

now how to find the maximum of these tails and write them in the variable????

int Sum_xb;
int Sum_xs;
datetime last_time;   // глобальная переменная
int Kol_vo_b;
int Kol_vo_s;
int Sr_zn_b;
int Sr_zn_s;
extern int Num_kolvo_b=10;
extern int Num_kolvo_s=10;
int Zn_b;
int Max_b;

int start()
  {
   
  int xBost_b;
  int xBost_s;
double hi=High[1];
double op=Open[1];
double cl=Close[1];
double lo=Low[1];


   if (last_time != Time[0])
   {
      // Ура, новый бар!
      last_time = Time[0];      // запоминаем новый бар
      if(Close[1]>Open[1])
      { 
xBost_b=(hi-cl)*10000;
Kol_vo_b++;
}
      if(Close[1]<Open[1])
      {
 xBost_s=(cl-lo)*10000; 
 Kol_vo_s++;
 
   }
   
if (Kol_vo_b==Num_kolvo_b)
{
Kol_vo_b=0;
Sum_xb=0;
}
if (Kol_vo_s==Num_kolvo_s)
{
Kol_vo_s=0;
Sum_xs=0;
}  
 
Sum_xb=Sum_xb+xBost_b;
Sr_zn_b=Sum_xb/Kol_vo_b;

Sum_xs=Sum_xs+xBost_s;
Sr_zn_s=Sum_xs/Kol_vo_s;

Zn_b=xBost_b;
if(xBost_b>Zn_b)
Max_b=xBost_b;
}




Comment("\n xBost_b=",xBost_b,"\n Sum_xb=",Sum_xb,"\n Kol_vo_b=",Kol_vo_b,"\n Sr_zn_b=",Sr_zn_b,
"\n\n\n\n kolvo_s=",xBost_s,"\n Sum_xs=",Sum_xs,"\n Kol_vo_s=",Kol_vo_s,"\n Sr_zn_s=",Sr_zn_s,"\n\n\n\n Max_b=",Max_b);

return(0);
  }

how to write this part of the code correctly to find the max!

Zn_b=xBost_b;
if(xBost_b>Zn_b)
Max_b=xBost_b;

 
People, can you tell me how to find the maximum?!
 
//Функция поиска максимума/минимума за заданное количество баров
// type-максимум или минимум, barsearch -количество баров

double yMaxDayPrice(int type,int barsearch)
{
    int    timeframe=1440;
    double minmax;

    if(type==2)
       {
           minmax=Low[iLowest(timeframe,0,MODE_LOW,barsearch,0)];
       }
    if(type==1)
       {
           minmax=High[iHighest(timeframe,0,MODE_HIGH,barsearch,0)];
       }
return(minmax);          
}
 
BeerGod:

can timeframe be replaced by null (current), for example?
 

https://docs.mql4.com/ru/series/ilowest you can, so that everything is accurate at the time of debugging, put the high and low values in the comment.

https://docs.mql4.com/ru/constants/timeframes

 

but this is a bit different than what I would like to see...

for buy bars we define the tail in points xBost_b=(hi-cl)*10000;

for the sell bars... xBost_s=(cl-lo)*10000;

B-Buy, S-Sell, ()-current bar

for example a series of bars:

1) B(S)-determine the tail of B

2)BS(B) - now define the tail of S

3) BSB(S) - now we define the tail of bar B once again and then we need to determine which tail is greater this one or that one, thesame for sell bars

But after recalculation (for example) 10 bars maximum will be reset and everything will go back to zero

for example:

int Sum_xb;
int Sum_xs;
datetime last_time;   // глобальная переменная
int Kol_vo_b;
int Kol_vo_s;
int Sr_zn_b;
int Sr_zn_s;
extern int Num_kolvo_b=10;
extern int Num_kolvo_s=10;
int Zn_b;
int Max_b;

int start()
  {
   
  int xBost_b;
  int xBost_s;
double hi=High[1];
double op=Open[1];
double cl=Close[1];
double lo=Low[1];


   if (last_time != Time[0])
   {
      // Ура, новый бар!
      last_time = Time[0];      // запоминаем новый бар
      if(Close[1]>Open[1])
      { 
xBost_b=(hi-cl)*10000;
Kol_vo_b++;
}
      if(Close[1]<Open[1])
      {
 xBost_s=(cl-lo)*10000; 
 Kol_vo_s++;
 
   }
   
if (Kol_vo_b==Num_kolvo_b)
{
Kol_vo_b=0;
Sum_xb=0;
}
if (Kol_vo_s==Num_kolvo_s)
{
Kol_vo_s=0;
Sum_xs=0;
}
 
I know how to get the most out of it in my head, but I can't convert it into code) I hope for your help!
 
DanLett:
I know how to get the most out of it in my head, but I can't convert it into code) I hope for your help!


I don't pretend to be right, as I am an amateur, but in one of my EAs I found maxima and minima in the same way, as you have already been told:

extern int count = 10;

..............................

highprice = High[iHighest(NULL,0,MODE_HIGH,count,0)];

..............................

lowprice = Low[iLowest(NULL,0,MODE_LOW,count,0)];

 
BeerGod:


It's not a good idea to post code with errors