please help me to understand the code !!!

 
i been starting leaning mql4 code , and run into thise code:
//*
//* my_DailyOpen_indicator
//*
//* Revision 1.1  2005/11/13 Midnite
//* Initial DailyOpen indicator
//* based pm  
//*
#property copyright "Midnite"
#property link      "me@home.net"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_style1 2
#property indicator_width1 1

double TodayOpenBuffer[];
extern int TimeZoneOfData= 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
        SetIndexStyle(0,DRAW_LINE);
        SetIndexBuffer(0,TodayOpenBuffer);
        SetIndexLabel(0,"Open");
        SetIndexEmptyValue(0,0.0);
        return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
        return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int lastbar;
   int counted_bars= IndicatorCounted();
   
   if (counted_bars>0) counted_bars--;
   lastbar = Bars-counted_bars; 
   DailyOpen(0,lastbar);
   
   return (0);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int DailyOpen(int offset, int lastbar)
{
   int shift;
   int tzdiffsec= TimeZoneOfData * 3600;
   double barsper30= 1.0*PERIOD_M30/Period();//<<<<<<<<<<<<<<<<-----------thise line no clear to me-------
   bool ShowDailyOpenLevel= True;
   // lastbar+= barsperday+2;  // make sure we catch the daily open              
   lastbar= MathMin(Bars-20*barsper30-1, lastbar);//<<<<<<<<<<-------thise also not clear-------

        for(shift=lastbar;shift>=offset;shift--){
          TodayOpenBuffer[shift]= 0;
     if (ShowDailyOpenLevel){
       if(TimeDay(Time[shift]-tzdiffsec) != TimeDay(Time[shift+1]-tzdiffsec)){      // day change
         TodayOpenBuffer[shift]= Open[shift];         
         TodayOpenBuffer[shift+1]= 0;                                                           // avoid stairs in the line
       }
       else{
         TodayOpenBuffer[shift]= TodayOpenBuffer[shift+1];
       }
          }
   }
   return(0);
}
can same explain thise 2 lines of code what they are doing and how they work?

thanks in advance.

 

er007:
i been starting leaning mql4 code , and run into thise code:

 can same explain thise 2 lines of code what they are doing and how they work?



barsper30  is the number of bars on the chart timeframe that will be in a M30 bar,  so for a M5 chart the value will be 6,  for an M15 chart the value will be 2.  The 1.0 * is to type cast the ints to the double.

lastbar is the smaller ( MathMin ) of the 2 values 

 
RaptorUK:


barsper30  is the number of bars on the chart timeframe that will be in a M30 bar,  so for a M5 chart the value will be 6,  for an M15 chart the value will be 2.  The 1.0 * is to type cast the ints to the double.

lastbar is the smaller ( MathMin ) of the 2 values 


you dont divided from right to left ?

 

 https://docs.mql4.com/basis/operations/rules

 

can you tell me what  the calculation  on thise line meen?

 

 lastbar= MathMin(Bars-20*barsper30-1, lastbar);

for what the "20"  and the "-1"?

 

thank you a loot  i appreciated  very much.

 
er007:


you dont divided from right to left ?

 https://docs.mql4.com/basis/operations/rules

can you tell me what  the calculation  on thise line meen? 

 lastbar= MathMin(Bars-20*barsper30-1, lastbar);

for what the "20"  and the "-1"?

Divide from left to right ?   PERIOD_M30 / Period()  means  divide PERIOD_M30 by Period() . . .  or how many Period()s are there in PERIOD_M30


"can you tell me what  the calculation  on thise line meen? "
 

Not without spending a lot of time understanding all the rest of the code . . . .  I don't have time for that right now.

 
thank you a loot ...... looking forword to   participate here in thise great community .
Reason: