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

 
Cycle from the current bar deep into history, checking for crossovers, exiting at the first event and memorising the bar number
 
can I have a link with information on how to do this?
 

Easier to write :

   int p_time   = 0;
   int p_signal = 0;
   for(int i=0;i<Bars;i++){
      double ma_10 = iMA(Symbol(),Period(),MA1_Period,0,MA1_Metod,MA1_App_Price,i);
      double ma_11 = iMA(Symbol(),Period(),MA1_Period,0,MA1_Metod,MA1_App_Price,i+1);
      double ma_20 = iMA(Symbol(),Period(),MA2_Period,0,MA2_Metod,MA2_App_Price,i);
      double ma_21 = iMA(Symbol(),Period(),MA2_Period,0,MA2_Metod,MA2_App_Price,i+1);
      if(ma_10 >= ma_20 && ma_11 < ma_21){// пересечение в одну сторону
         p_time = Time[i];// время бара при пересечении
         p_signal = 1;
         break;
      }
      if(ma_10 <= ma_20 && ma_11 > ma_21){// пересечение в другую
         p_time = Time[i];// время бара при пересечении
         p_signal = -1;
         break;
      }
   }
   if(p_signal!=0){
      
      // действия при пересечении
   }
 
Time[i] это будет номер бара или само время?
 

GarKain:

Time[i] это будет номер бара или само время?


i - bar number

Time[i] - its time

 
Do I understand correctly, if I write i instead of Time[i], I get the bar number?

And if I use such a script in an EA, then when a new crossing occurs, the value of i will change to a new one?
 
GarKain:
Am I right, if I write i instead of Time[i], I will get the bar number?

and if I use this script in my EA, then when a new crossing occurs, the value of i will change to a new one?


Time[0] - will return the zero bar open time, Time[1] will return the first bar open time (the one which precedes the zero bar), Time[i] will return the bar open time, whose number is in the i variable

 
drknn:


Time[0] - will return the opening time of the zero bar, Time[1] will return the opening time of the first bar (the one which precedes the zero bar), Time[i] will return the opening time of the bar whose number lies in the i variable

is this a question?
 
GarKain:
is that a question?

Bygones :)
 

Hello!

Help me find an indicator that outputs support and resistance levels from data in a text file.

It should look similar to this one: https://www.mql5.com/en/code/8096 but with differences:

Need to be able to choose the colour, line width and a comment for each line, ie, the CSV structure is something like this:

date price weight colour comment

date price weight colour comment

etc.

Thank you.

Reason: