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

 
hoz:

And where is this variable set explicitly, if it's not a secret? :) I see in the libraryb-PSI@Base.mqh that it's only declared:

But there's essentially nothing further. In fact, the value of the current instrument is returned by default through Symbol(). So why do we need a variable here?

I have already answered this question in the section about multicurrency - current symbol = Symbol() - this is only a special case.

P.S. Your approach is interesting: you take somebody else's code and try "to fit" it to your logic - you have every right, but don't ask me: "Why your logic is different from mine!

 
TarasBY:

I have already answered this question, where about multicurrency - current symbol = Symbol() - this is only a special case.

P.S. You have an interesting approach: you take someone else's code and try to "fit" it to your logic - you have every right, but don't ask me: "Why your logic is different from mine!



I'm not going to adjust it. I just want to study how it is implemented. But I will not copy anything. I'm interested to see how a pro thinks. That's the real reason. So, here it is.

I am looking at the void fGet_MarketInfo (string fs_Symbol, int fi_Ticket = 0) function:

if (fs_Symbol != bs_Symbol || fi_Ticket < 0)

This variable is not declared inside this function. It is not declared in other 2 base files (inclusion and function) either. It's not clear where to look for it. That's what I'm asking. I want to understand where it originally appeared at all, i.e. declared. If you don't mind telling me...

There is also one more strange thing with another variable. The following lines in thebool fCheck_LevelsBLOC function:

   if (fi_Type == 0) li_cmd = 0; else if (fi_Type == 1) li_cmd = 1;
    else if (fi_Type % 2 == 0) li_cmd = 1; else li_cmd = 0;
    ld_Price = bda_Price[li_cmd];

bda_Price[li_cmd] is first mentioned in theb-PSI@Base.mqh library:

bda_Price[2];

Elements of the array are not specified. So they are equal to zero each. It means that an expression whatever parameter of the li_cmd array will take the value 0?

ld_Price = bda_Price[li_cmd];
 
bikrus13:
Hello everyone. please respond to all who can create a script that increases the lots when opening a deal.

Are you opening a tender here for job satisfaction??? Usually it's not the tasks that satisfy...

If you don't understand something, ask us, we'll help you.

Or go to the job - there satisfy both you and the job ... for a fee

 
Is it possible to find out prices (Ask and Bid) in the history by time from the EA? For example Asc 10 min ago or 10 sec ago. There are known functions to get a time series of bars with opening and closing prices and Hai Lows in a certain period of time, but at a specific point in time how to know the Ask and Bid.
 
Dikii:
Is it possible to find out prices (Ask and Bid) in the history by time from the EA? For example Asc 10 min ago or 10 sec ago. There are known functions to get a time series of bars with opening and closing prices and Hai Lows in a certain period of time, but at a specific point in time how to know the Ask and Bid.

There is no Ask, only Bid! By the way, everyone would like that, myself included!
 
borilunad:

Asq no way, only Bid! By the way, everyone would like that, myself included!

Explain how to find out Bid 10 seconds ago preferably in code.
 

I asked about arrays earlier. Still don't seem to get it right. When you run it on the tester there is a division by zero. It means there is zero in some array. I cannot figure out where the error is. Code in appendix. Comments are in Russian in WORDe. Sorry about that. My Metaeditor does not support the Russian language.

Help me find the error(s). And if you don't mind explaining them.

Неполучилось сразу и два файла поместить. Вордовский документ неразрешается всавлять. Как иначе проконтировать на русском незнаю , только полностью код скопировать с ворда и поместить сюда

//быстры MA
extern int     MA_Period1     =  8;
extern int     plius1         =  100;
extern int     MA_Shift1      =  0;
extern int     MA_Method1     =  0;                                                 
//медленый MA
extern int     MA_Period2     =  13;
extern int     plius2         =  100;
extern int     MA_Shift2      =  0;
extern int     MA_Method2     =  3;                                                 
//начало флета
//поиск флета по сигналу или время
extern bool  start       =  true;    // true ->по сигналу, false->по времени
// по сигналу начинаем с данного времени
extern int     startHourFlatMA        =  16;    
extern int     startMinFlatMA        =  00;
//сигнал есть, ждем пока закроется  BarEnd бар
extern int     BarEnd         =  240;
datetime       LastTime;
//datetime       startTime;
// по времени начьнем искать флет с
extern int     startHourFlat        =  0;   
extern int     startMinFlat         =  0;    
//конец флета в промежутке времени или по истечению времени
//начало промежутка
extern int     startHourEnd        =  4;    
extern int     startMinEnd         =  45;
//конец промежутка, и истечение времени по времени
extern int     endHourEnd        =  7;    
extern int     endMinEnd         =  30;

//включение фильтра Volumes
extern bool volFiltr = true;            //true -> включено,   false -> выключено
//skirtumas tarp penktadienio uzdarymo ir pirmadienio atidarymo
extern int   gep = 300;  
bool           susikirtimas = false;      //пересечение индикаторных линий
bool           flat; 
//массивы
double chPriceH[], chPriceL[], chPriceO[], chPriceC[], chTime[];
double avgPriceH[], avgPriceL[], avgPriceO[], avgPriceC[]; 
int iH, iL ,iO, iC, iT;
double C[], T[], y[];
int i = -1;                      // индекс массива
int j = -1;                      // индекс массива
int n = -1;                              // индекс массива
double max;                               //максимаьная разница между элементами масивов

int init ()
{
ArrayResize(chPriceH, 0);
ArrayResize(chPriceL, 0);
ArrayResize(chPriceO, 0);
ArrayResize(chPriceC, 0);
ArrayResize(chTime, 0);
ArrayResize(avgPriceH, 0); 
ArrayResize(avgPriceL, 0); 
ArrayResize(avgPriceO, 0); 
ArrayResize(avgPriceC, 0); 
ArrayResize (C, 0); 
ArrayResize (T, 0);
ArrayResize (y, 0);
}
 int start()
 {
   double volMA11, volMA12, volMA21, volMA22;  
   double x[], y[]; 
   
   Print("***старт***");
   
   if(!TF_F_NewBar())return(0);
 
   Print("---1-собираем данные индикаторов---");
   volMA11 = iCustom(NULL, 15, "volumeMA",  2, 1);         
   volMA12 = iCustom(NULL, 15, "volumeMA",  2, 2);
   volMA21 = iCustom(NULL, 15, "volumeMA",  3, 1);
   volMA22 = iCustom(NULL, 15, "volumeMA",  3, 2);
   Print("volMA11 = "+volMA11);
   Print("volMA12 = "+volMA12);
   Print("volMA21 = "+volMA21);
   Print("volMA22 = "+volMA22);
   Print("----1 данные собраны---END");   
   Print("---2 какой день недели--");
   if(DayOfWeek()==1 || DayOfWeek()==2 || DayOfWeek()==3 || DayOfWeek()==4)
   {         
      Print("DayOfWeek = "+DayOfWeek());
  Print("----2---END");    
      if(Hour() >= startHourFlatMA && Minute() >= startMinFlatMA)
  Print("---3 проверка времени, разрешается ли искать флет---");
      {
         Print("время начала флета >=  "+Hour()+":"+Minute());
 Print("----3--end");
 Print("---4 есть ли пересечение линий индикатора----");
         if(volMA21 - volMA11 > 0 && volMA12 - volMA22 > 0)
         {                                                                                   //если было пересечение
            susikirtimas = true;
            Print("пересечение = "+susikirtimas);
Print("---4---END");
Print("---5 жшдем окончания  M240 свечи--");
            LastTime = iTime(NULL, BarEnd, 1);
            Print("LastTime = "+LastTime);
            //startTime = Time[1];
         }      
         if(susikirtimas == true && iTime(NULL, BarEnd, 1)!= LastTime)
         {
            LastTime = iTime(NULL, BarEnd, 1);
            flat = true;
            Print("flat = "+flat);
         }
         if(flat == true)
         {
Print(-начало флета есть");
Print("-- 6 собираем данные в массивы--");
            //увеличиваем число элементов массива на один
            i++; 
            Print("увеличиваем длину массива в зависимости от i "); 
            ArrayResize(avgPriceH,i); 
            ArrayResize(avgPriceL,i); 
            ArrayResize(avgPriceO,i); 
            ArrayResize(avgPriceC,i);           
             
            Print("с каждой новой свечой должны получить новые элементы массивов");
            avgPriceH[i] = High[1];  Print("AVG элемент avgPriceH["+i+"] = "+avgPriceH[i]);   
            avgPriceL[i] = Low[1];   Print("AVG элемент avgPriceL["+i+"] = "+avgPriceL[i]);   
            avgPriceO[i] = Open[1];  Print("AVG элемент avgPriceO["+i+"] = "+avgPriceO[i]);   
            avgPriceC[i] = Close[1]; Print("AVG mэлементasyvo elementas avgPriceC["+i+"] = "+avgPriceC[i]);            
            j++; Print("индех канальных массивов  j = "+j);      
            ArrayResize(chPriceC,j); Print("CH masyvo ilgis chPriceC = "+j); 
            ArrayResize(chTime,j);     Print("CH masyvo ilgis chTime = "+j); 
            //включен ли фильтр
            if(volFiltr)
            {               
               //да
               Print("да включен");
               Print("volMA11 = "+volMA11, "   Volume[1] = "+Volume[1]); 
               if(volMA11 - Volume[1] >= 0)//фильтр
               {
                  Print("записываем Close[1] ir Time[1] в массивы");
                  chPriceC[j] = Close[1];  Print("masyvo elementas chPriceC["+j+"] = "+j);                   
                  chTime[j] = Time[1];     Print("masyvo elementas chTimev["+j+"] = "+j); 
               }
               else
               {
                  //renkam
                  chPriceC[j] = 0;    Print("masyvo elementas chPriceC["+j+"] = "+j); 
                  chTime[j] = 0;      Print("masyvo elementas chTimev["+j+"] = "+j); 
               }
            }
Print("получилис отфильтрваные массивы с нулями ");
            else // jei filtras isjungtas, tada duomenys kanalo skaiciavimui
            {
               //renkam
               Print("если фильтр выключен");
               Print("pradedam rinkti Close[1] ir Time[1] duomenis i masyvus po filtracijos");
               //chPriceH[j] = High[1]; Print("masyvo elementas chPriceH["+j+"] = "+j); 
               //chPriceL[j] = Low[1];  Print("masyvo elementas chPriceL["+j+"] = "+j); 
               chPriceC[j] = Close[1];  Print("masyvo elementas chPriceC["+j+"] = "+j); 
               //chPriceO[j] = Open[1]; Print("masyvo elementas chPriceO["+j+"] = "+j); 
               chTime[j] = Time[1];     Print("masyvo elementas chTimev["+j+"] = "+j);                                                                                              
            }
         //suzinom kokio ilgio masyvai
         Print("после того как массивы собраны узнаем их длину");
         Print("ArrayRange(chPriceC, 0) = "+iC);         
         Print("фильтруем их от нулей, после фильтрции длина массивов меньше чем была до фильтрции");                 
         for(int k = 0; k <= iC; k++)        
         {            
            if(chPriceC[k] > 0)          
            {
               n++;                           
                ArrayResize(C,n);
                ArrayResize(T,n);
                C[n] = chPriceC[k];
               T[n] = chTime[k];        
               Print("naujo masyvo elementas C["+n+"] = "+C[n]);
               Print("naujo masyvo elementas irasytas T["+n+"] = ",T[n]);
               Print("naujo atfiltruoto masyvo ilgis n = ",n);
            }
         }         
       }              
     }
   }
Print("так масивы набирается свеча за свечой пока несработает 7 – ая часть кода"); 

   Print("----------- 6 массивы набирается------------------------end");
Print("----------- 7 массивы набраны------------------------end"); 

   //if(DayOfWeek()==0 || DayOfWeek()==6) return(0);
   
   if(((Hour() >  startHourEnd && Minute() > startMinEnd) &&                                          //jei jau laikas po 6.30
Print("если начялось время начала поиска конца флета"); 

      (volMA11 - volMA21 > 0 && volMA22 - volMA12 > 0))  ||                               //пересечение индикаторных линий
      (Hour() >  endHourEnd && Minute() > endMinEnd))
      {                                                      // или кончилось время флета
        susikirtimas = false; //сбрасываем флаг начала пересичения инд. линий на вход во флет
         flat = false;  //сбрасываем флаг начала флета
         i = -1; //Возвращаем начальные индексы массивов
         j = -1;
   //ищем линию регрении     
        ArrayChLR(C, y, max);//ArrayLR(x, y)
//ищем точки для фибо уровней
        double y161Plus_1 = y[1] + max/50 * 161;
        double y261Plus_1 = y[1] + max/50 * 261;
        double y361Plus_1 = y[1] + max/50 * 361;
        double y423Plus_1 = y[1] + max/50 * 423;
        
        double y161Minus_1 = y[1] - max/50 * 161;
        double y261Minus_1 = y[1] - max/50 * 261;
        double y361Minus_1 = y[1] - max/50 * 361;
        double y423Minus_1 = y[1] - max/50 * 423;
        
        double y161Plus_2 = y[n-1] + max/50 * 161;
        double y261Plus_2 = y[n-1] + max/50 * 261;
        double y361Plus_2 = y[n-1] + max/50 * 361;
        double y423Plus_2 = y[n-1] + max/50 * 423;
        
        double y161Minus_2 = y[n-1] - max/50 * 161;
        double y261Minus_2 = y[n-1] - max/50 * 261;
        double y361Minus_2 = y[n-1] - max/50 * 361;
        double y423Minus_2 = y[n-1] - max/50 * 423;
        
        //turim po dvi kainos koordinate, o laiko galim paimti is masyvo T[]
        //galim brezti linijas
        //y=(y2-y1)/(x2-x1)*(x-x1)+y1
        double y161Plus_3 = (y161Plus_2-y161Plus_1)/(T[n]-T[1])*(StrToTime("20:00")-T[1])+y161Plus_1;
        double y261Plus_3 = (y261Plus_2-y261Plus_1)/(T[n]-T[1])*(StrToTime("20:00")-T[1])+y261Plus_1;
        double y361Plus_3 = (y361Plus_2-y361Plus_1)/(T[n]-T[1])*(StrToTime("20:00")-T[1])+y361Plus_1;
        double y423Plus_3 = (y423Plus_2-y423Plus_1)/(T[n]-T[1])*(StrToTime("20:00")-T[1])+y423Plus_1;
        
        double y161Minus_3 = (y161Plus_2-y161Plus_1)/(T[n]-T[1])*(StrToTime("20:00")-T[1])+y161Plus_1;
        double y261Minus_3 = (y261Plus_2-y261Plus_1)/(T[n]-T[1])*(StrToTime("20:00")-T[1])+y261Plus_1;
        double y361Minus_3 = (y361Plus_2-y361Plus_1)/(T[n]-T[1])*(StrToTime("20:00")-T[1])+y361Plus_1;
        double y423Minus_3 = (y423Plus_2-y423Plus_1)/(T[n]-T[1])*(StrToTime("20:00")-T[1])+y423Plus_1;
        //чертим линии 
        SetTLine(Thistle, "", T[1], y161Plus_1, StrToTime("20:00"), y161Plus_3, 0, 1);
        SetTLine(Thistle, "", T[1], y261Plus_1, StrToTime("20:00"), y261Plus_3, 0, 1);
        SetTLine(Thistle, "", T[1], y361Plus_1, StrToTime("20:00"), y361Plus_3, 0, 1);
        SetTLine(Thistle, "", T[1], y423Plus_1, StrToTime("20:00"), y423Plus_3, 0, 1);
        
        SetTLine(Thistle, "", T[1], y161Minus_1, StrToTime("20:00"), y161Minus_3, 0, 1);
        SetTLine(Thistle, "", T[1], y261Minus_1, StrToTime("20:00"), y261Minus_3, 0, 1);
        SetTLine(Thistle, "", T[1], y361Minus_1, StrToTime("20:00"), y361Minus_3, 0, 1);
        SetTLine(Thistle, "", T[1], y423Minus_1, StrToTime("20:00"), y423Minus_3, 0, 1);
        
         
      } 
      
   return(0);
 }

 //-----------------------------------------------------------------------------------------------------
 
void ArrayChLR(double& x[], double& y[], double& max) {
  double a, b, c, sx=0, sx2=0, sxy=0, sy=0;
  int    i, n=ArraySize(x);

  if (n>1) {
    for (i=0; i<n; i++) {
      sx+=i+1;
      sy+=x[i];
      sxy+=(i+1)*x[i];
      sx2+=(i+1)*(i+1);
    }
    a=sx*sy-n*sxy;
    c=sx*sx-n*sx2;
    if (c!=0) a=a/c; else a=0;
    b=(sy-a*sx)/n;
    ArrayResize(y, n);
    max = 0; 
    double dif[];
    ArrayResize(dif, n);
    for (i=0; i<n; i++) 
    {
      y[i]=a*(i+1)+b;
      dif[i] = MathAbs(Close[i] - y[i]);
      if(dif[i] > max) max = dif[i];      
    }
  } else Print("ArrayLR(): per mazas x masyvo elementu skaicius! n=", n);
}

 
Files:
 
Dikii:
Is it possible to find out prices (Ask and Bid) in the history by time from the EA? For example Asc 10 min ago or 10 sec ago. There are known functions of getting time series of bars with opening and closing prices and Hai Lows in a certain period of time, but at a specific point in time how to find out the Ask and Bid.

There is ticks.raw file in the folder /history/server/, from there you can theoretically get both Bid and Ask by the symbols from Market Watch for a short time before the current moment. Do a forum search in this direction... I can't say anything specific about the data storage mechanism in that file from memory.
 
gince:

I asked about arrays earlier. Still don't seem to get it right. When you run it on the tester there is a division by zero. It means there is zero in some array. I cannot figure out where the error is. Code in appendix. Comments are in Russian in WORDe. Sorry about that. My Metaeditor does not support the Russian language.

Help me find the error(s). And if you don't mind explaining them.


I recommend to write Print(to what we divide) before each division - you will immediately know where the zero is.
 
alsu:

I recommend entering Print(to what we divide); before each division, you will immediately know where the zero is
.

There is only one division. And according to the CMM function (although it is full) it says that there is not enough data in the resulting array in the function. I cannot understand why. This is why I get division by zero.