[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 613

 

Yes they are int type, but I thought the result is output immediately without assignment. Thanks, I'll give it a try.


Gut it's working.

 


This is what I got. If anyone is interested, I can post the source code. This script generates statistics by bars. I analysed the daily bars on this chart.


I found an interesting pattern. The percentages are almost the same for all periods. There is +-5% difference. In the ratio of bulls to bears by one, two and three in a row.

 
ChAnton:


This is what I got. If anyone is interested, I can post the source code. This script generates statistics by bars. I analysed the daily bars on this chart.


I found an interesting pattern. The percentages are almost the same for all periods. There is +-5% difference. In the ratio of bulls to bears by one, two and three in a row.


Put it out there, it's interesting to see.
 
//+------------------------------------------------------------------+
//|                                                 Анализ баров.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//для метатрейдера 4

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+

#property show_inputs
extern int Periods = 5;                     // Период таймсерии
extern int Nachalo = 1;                     // Начало баров откуда начинается анализ
extern int Konec = 500;                     // Конец баров на каком баре заканчивается анализ
extern int Bolee = 0;                       // тело бара больше установленной величины (для расчета от 0 указывать -1)
extern int Menee = 50;                      // тело бара меньше установленной величины
extern int Teny = 100;                      // минимальная величина тени с обоих сторон
extern int Otkr = 100;                      // минимальное отклонение от точки открытия

int start()
  {
  int i;      //счетчик
  double nul = 0; //количество баров размер тела которых равно нулю
  double vverh = 0;  //Бар вверх бычий
  double vniz = 0;   //Бар вниз медвежий
  double dvavverh = 0;  //Бар вверх 2 подряд
  double dvavniz = 0;   //Бар вниз 2 подряд
  double trivverh = 0;  //Бар вверх 3 подряд
  double trivniz = 0;   //Бар вниз 3 подряд
  double vibor = 0;  //Бар удовлетворяющий условию поиска
  double Maks =0;//максимальный бар
  double Mun =10000;//минимальный бар
  double ten = 0;//тени с обоих сторон превышающие установленную величину
  double otkrytie = 0; // смещение цены в обе стороны на эту величину с момента открытия бара
  double L; //вре'менная переменная
  string S;
  
  string Symb;
  //используемый фин. инструмент - торговая пара
  Symb=Symbol();  
  string P;
  if (Periods == 1) P = "PERIOD_M1";
  if (Periods == 2) P = "PERIOD_M5";
  if (Periods == 3) P = "PERIOD_M15";
  if (Periods == 4) P = "PERIOD_M30";
  if (Periods == 5) P = "PERIOD_H1";
  if (Periods == 6) P = "PERIOD_H4";
  if (Periods == 7) P = "PERIOD_D1";
  if (Periods == 8) P = "PERIOD_W1";
  if (Periods == 9) P = "PERIOD_MN1";
//----
  if ( Konec > iBars( Symb, P) )
  {
   Konec = iBars( Symb, P);
  } 
  Alert ("___________________________________________________________");

//----
  /*   iTime("USDCHF",PERIOD_H1,i)
       iOpen("USDCHF",PERIOD_H1,i)
       iHigh("USDCHF",PERIOD_H1,i)
       iLow("USDCHF",PERIOD_H1,i)
       iClose("USDCHF",PERIOD_H1,i)
       iVolume("USDCHF",PERIOD_H1,i));    */
            
  for(i=Nachalo;i<=Konec;i++)
    {
     if (iOpen(Symb,P,i) == iClose(Symb,P,i)) nul = nul + 1; //количество нулевых баров
    
     if (iOpen(Symb,P,i) < iClose(Symb,P,i)) vverh = vverh + 1; //количество бычьих баров
     
     if (iOpen(Symb,P,i) > iClose(Symb,P,i)) vniz =  vniz  + 1; //количество медвежьих баров
     
     if (iOpen(Symb,P,i) < iClose(Symb,P,i))
         if (iOpen(Symb,P,i+1) < iClose(Symb,P,i+1)) 
             dvavverh = dvavverh + 1; //количество бычьих баров
     
     if (iOpen(Symb,P,i) > iClose(Symb,P,i)) 
         if (iOpen(Symb,P,i+1) > iClose(Symb,P,i+1))
             dvavniz =  dvavniz  + 1; //количество медвежьих баров
     
     if (iOpen(Symb,P,i) < iClose(Symb,P,i)) 
         if (iOpen(Symb,P,i+1) < iClose(Symb,P,i+1))
             if (iOpen(Symb,P,i+2) < iClose(Symb,P,i+2))
                 trivverh = trivverh + 1; //количество бычьих баров
     
     if (iOpen(Symb,P,i) > iClose(Symb,P,i)) 
         if (iOpen(Symb,P,i+1) > iClose(Symb,P,i+1))
             if (iOpen(Symb,P,i+2) > iClose(Symb,P,i+2))
                 trivniz =  trivniz  + 1; //количество медвежьих баров
              
     L = iOpen(Symb,P,i) - iClose(Symb,P,i);
     if (L < 0) L = L * (-1);
     
     if (L < Menee * Point) if (L >  Bolee * Point) vibor = vibor + 1; //количество выбранных баров
     
     L = L / Point;
     if (L > Maks) Maks = L;
     if (L < Mun) Mun = L;
     
     if (iOpen(Symb,P,i) < iClose(Symb,P,i))
         if (iOpen(Symb,P,i) - iLow(Symb,P,i)> Teny*Point)
             if (iHigh(Symb,P,i) - iClose(Symb,P,i)> Teny*Point)
                ten = ten + 1;    

     if (iOpen(Symb,P,i) > iClose(Symb,P,i))
         if (iClose(Symb,P,i) - iLow(Symb,P,i)> Teny*Point)
             if (iHigh(Symb,P,i) - iOpen(Symb,P,i)> Teny*Point)
                ten = ten + 1; 
                
                
     if (iHigh(Symb,P,i) - iOpen(Symb,P,i)> Otkr*Point)
         if (iOpen(Symb,P,i) - iLow(Symb,P,i)> Otkr*Point)
                otkrytie = otkrytie + 1;                
                

    }
     
  Alert ("Максимальный бар = " , Maks , " ----- ","Минимальный бар = " , Mun);
  
  Alert ("Бары удовлетворяющие условию по размеру отклонений >",Otkr ," пунктов = " , otkrytie, " --- ", otkrytie/(Konec/100), " % " );
  Alert ("Бары удовлетворяющие условию по размеру теней >",Teny ," пунктов = " , ten, " --- ", ten/(Konec/100), " % " );
  Alert ("Бары удовлетворяющие условию по размеру тела > ",Bolee ," пунктов и < ",Menee  ," пунктов = " , vibor, " --- ", vibor/(Konec/100), " % " );
  
  Alert ("                            ",trivverh/(Konec/100), " % " , " -------------------------- ", trivniz/(Konec/100), " % " );
  Alert ("3 быка подряд = " , trivverh, " ----- ","3 медведя подряд  = " , trivniz );
  
  Alert ("                               ",dvavverh/(Konec/100), " % "," ------------------------------ ",   dvavniz/(Konec/100), " % " );
  Alert ("2 быка подряд = " , dvavverh, " ----- ","2 медведя подряд  = " , dvavniz );
  
  Alert ("                             ",nul/(Konec/100), " % " ,
         " -------------------- ", vverh/(Konec/100), " % ",
         " ------------------------- ",vniz/(Konec/100) , " % " );
  Alert ("нулевые бары = " , nul, " ----- ","бычьи бары = " , vverh, " ----- ","медвежьи бары = " , vniz );
  
  Alert ("Общее количество баров на графике ",P," : ",iBars( Symb, P)); 
  Alert ("Количество анализируемых баров = " , Konec);

   return(0);
  }
//+------------------------------------------------------------------+
There are unresolved problems. Percentages are inaccurate +-0.5% why I can't understand it yet. Also, the analysis uses the period that is set on the chart, rather than the one specified in the script settings.
 
I've downloaded a few EAs with good results, but I've tried them in the Strategy Tester, and the results are much worse.
 

There's a homemade indicator, but I've dumbed it down, I want to get the value of

day_max and day_min, can you tell me how to pull it out? It is clear that with iCustom, but I can't figure out how.(Due to the fact that this indicator is very difficult to put in an owl:(... for me)


property copyright "DOC"
#property link "none"


#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Green
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double day_max;
double day_min;

 
Good afternoon, could you please tell me how to check if an order is open on this financial instrument?)
 
Ali007:
(Please tell me how to check if an order is opened on this symbol))

Here's a tip:

We loop through all open orders and look at the order symbol: if it is interesting to us, we increase the counter, or return "true", depending on what we need next. If we have gone through all orders and have not found the necessary symbol, we return "false" or zero, if we have to determine the number of orders.

 
Ali007:
Good afternoon, could you please tell me how to check if an order is open on this financial instrument?)

bool got_order=false;

for(int i=OrdersTotal()-1;i>=0;i--)
{
   if(OrderSelect(i,SELECT_BY_POS))
      if(OrderSymbol()==Symbol())
         if(OrderType()==OP_BUY||OrderType()==OP_SELL) 
         {
            got_order=true;break;
         }
}
 
VladislavVG:

Here's a tip:

We loop through all open orders and look at the order symbol: if it is interesting to us, we increase the counter, or return "true", depending on what we need next. If we have cycled through all orders and have not found the necessary symbol, we return "false", or zero, if we wanted to determine the number of orders.

Thank you very much!
How can we go through all of the open orders? What function should we use? OrderSelect?
Reason: