Volume Question

 

I'm trying to add the total amount of volume over a number of periods.  The following code displays the volume of each period from the start of the day to the current candle.  Not able to add the volume amounts of each candle together.  Can anyone show me what I'm missing?  Also, the code for placing an arrow at the candle with the highest and lowest volume amount works, but does not return the correct candle number.


Thanks!

     extern string Settings_n_1 = "--------------------------";
extern int Side = 1;
extern int MP_Y = 0; 
extern int MP_X = 0;	

     static datetime New_Time;
     bool New_Bar = false;


      double PeriodTotal = (((Hour()*60) + Minute())/5);

      Fun_New_Bar();         
      if(New_Bar != false)   
      {PeriodCnt = PeriodCnt + 1;}  
        




      Alert("PeriodCnt =  ",PeriodCnt,"    Hour =  ",Hour(),"    Minute =  ",Minute(),"   PeriodTotal =  ",DoubleToStr(NormalizeDouble(PeriodTotal,2),1),"   PeriodTotal =  ",DoubleToStr(PeriodTotal,Digits));
   








   int CntBarsz = PeriodTotal;
   
   int lowshiftl=iLowest(NULL,0,MODE_VOLUME,CntBarsz,0);
    double Minimuml=Open[lowshiftl];  
   datetime lowtimel=Time[lowshiftl];
                        
   int maxshifth=iHighest(NULL,0,MODE_VOLUME,CntBarsz,0);
    double Maximumh=Open[maxshifth];  
   datetime maxtimeh=Time[maxshifth];
        

   for(j=1;j<CntBarsz-1;j++)                    
     {                                           
      if (Low[j]< Minimuml)                        
         {Minimuml=Low[j]; int nl = CntBarsz;    // ((PeriodTotal-5)-1)         
         
ObjectDelete("UpSymblBz");         
ObjectCreate("UpSymblBz", OBJ_ARROW, 0, lowtimel,Minimuml);         
//ObjectCreate("UpSymbolBz", OBJ_ARROW, 0, Time[0],Minimuml);  
ObjectSet("UpSymblBz", OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
ObjectSet("UpSymblBz", OBJPROP_COLOR,White);
                 
      }}  

   for(i=1;i<CntBarsz-1;i++)                    
     {                
      if (High[i]> Maximumh)                       
         {Maximumh=High[i]; int mh = i;  //   ( i+1 )             
         
ObjectDelete("DnSymblBz");  
ObjectCreate("DnSymblBz", OBJ_ARROW, 0, maxtimeh,Maximumh);                  
//ObjectCreate("DnSymbolBz",OBJ_ARROW, 0, Time[0], Maximumh);  
ObjectSet("DnSymblBz", OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
ObjectSet("DnSymblBz", OBJPROP_COLOR,White);        
         
     }}       









      int Val_1, Val_2 = iVolume(NULL,PERIOD_M5,i), Sum;                                  
                                             
      for(i=0;i<CntBarsz-1;i++)  
       
     {  
     
     Val_1=iVolume(NULL,PERIOD_M5,i);
                                                                 
     Sum = Val_1 + Val_2; 
                                                         
     Alert("i =  ",i,"  Sum =  ",Val_1,"    Total =  ",Sum);  
                                                            
     }      








      ObjectDelete("MP18163");
      text=(" H =  " + mh + "   L =  " + nl);  //  
      Write("MP18163", Side, MP_X+1400, MP_Y+230, text, 14, "Tahoma", White);







 // Write Procedure
    void Write(string LBL, double side, int pos_x, int pos_y, string text, int fontsize, string fontname, color Tcolor=CLR_NONE)
       {
       ObjectCreate(LBL, OBJ_LABEL, 0, 0, 0);
       ObjectSetText(LBL,text, fontsize, fontname, Tcolor);
       ObjectSet(LBL, OBJPROP_CORNER, side);
       ObjectSet(LBL, OBJPROP_XDISTANCE, pos_x);
       ObjectSet(LBL, OBJPROP_YDISTANCE, pos_y);
       }

void Fun_New_Bar()
  {
   New_Bar = false;
   
   if (New_Time!= Time[0])
   
      {
       New_Time = Time[0];
       New_Bar = true;
      }}





    
 
Yellowbeard: .  Can anyone show me what I'm missing? 
     static datetime New_Time;
     bool New_Bar = false;

     double PeriodTotal = (((Hour()*60) + Minute())/5);
:
  1. Code that executes must be inside of a function.
  2. Your code doesn't compile.
  3. learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
 

Sorry.  I left out a few things.   Hopefully this helps.

 //+------------------------------------------------------------------+
//| Custom_Test_M83Fa |
//| me |
//| http://www.metatrader.info |
//+------------------------------------------------------------------+

#property copyright "me"
#property link "http://"  


extern string Settings_n_1 = "--------------------------";
extern int Side = 1;
extern int MP_Y = 0; 
extern int MP_X = 0;    


     int PeriodCnt, i, j;
     string UpSymblBz, DnSymblBz, text;
     static datetime New_Time;
     bool New_Bar = false;



//+------------------------------------------------------------------+
//| expert initialization function  |
//+------------------------------------------------------------------+

int init() 
{    
//----



//---- 
return(0);  
}

//+------------------------------------------------------------------+
//| expert deinitialization function  |
//+------------------------------------------------------------------+
int deinit() 
{
//----
    
//---- 
return(0); 
} 



//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() 
{


      double PeriodTotal = (((Hour()*60) + Minute())/5);

      Fun_New_Bar();         
      if(New_Bar != false)   
      {PeriodCnt = PeriodCnt + 1;}  
        

      Alert("PeriodCnt =  ",PeriodCnt,"    Hour =  ",Hour(),"    Minute =  ",Minute(),"   PeriodTotal =  ",DoubleToStr(NormalizeDouble(PeriodTotal,2),1),"   PeriodTotal =  ",DoubleToStr(PeriodTotal,Digits));
   

   int CntBarsz = PeriodTotal;
   
   int lowshiftl=iLowest(NULL,0,MODE_VOLUME,CntBarsz,0);
    double Minimuml=Open[lowshiftl];  
   datetime lowtimel=Time[lowshiftl];
                        
   int maxshifth=iHighest(NULL,0,MODE_VOLUME,CntBarsz,0);
    double Maximumh=Open[maxshifth];  
   datetime maxtimeh=Time[maxshifth];
        

   for(j=1;j<CntBarsz-1;j++)                    
     {                                           
      if (Low[j]< Minimuml)                        
         {Minimuml=Low[j]; int nl = CntBarsz;    // ((PeriodTotal-5)-1)         
         
ObjectDelete("UpSymblBz");         
ObjectCreate("UpSymblBz", OBJ_ARROW, 0, lowtimel,Minimuml);         
//ObjectCreate("UpSymbolBz", OBJ_ARROW, 0, Time[0],Minimuml);  
ObjectSet("UpSymblBz", OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
ObjectSet("UpSymblBz", OBJPROP_COLOR,White);
                 
      }}  

   for(i=1;i<CntBarsz-1;i++)                    
     {                
      if (High[i]> Maximumh)                       
         {Maximumh=High[i]; int mh = i;  //   ( i+1 )             
         
ObjectDelete("DnSymblBz");  
ObjectCreate("DnSymblBz", OBJ_ARROW, 0, maxtimeh,Maximumh);                  
//ObjectCreate("DnSymbolBz",OBJ_ARROW, 0, Time[0], Maximumh);  
ObjectSet("DnSymblBz", OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
ObjectSet("DnSymblBz", OBJPROP_COLOR,White);        
         
     }}       



      int Val_1, Val_2 = iVolume(NULL,PERIOD_M5,i), Sum;                                  
                                             
      for(i=0;i<CntBarsz-1;i++)  
       
     {  
     
     Val_1=iVolume(NULL,PERIOD_M5,i);
                                                                 
     Sum = Val_1 + Val_2; 
                                                         
     Alert("i =  ",i,"  Sum =  ",Val_1,"    Total =  ",Sum);  
                                                            
     }      



      ObjectDelete("MP18163");
      text=(" H =  " + mh + "   L =  " + nl);  //  
      Write("MP18163", Side, MP_X+1400, MP_Y+230, text, 14, "Tahoma", White);




return(0);         
}        

//+------------------------------------------------------------------+


//+------------------------------------------------------------------+



 // Write Procedure
    void Write(string LBL, double side, int pos_x, int pos_y, string text, int fontsize, string fontname, color Tcolor=CLR_NONE)
       {
       ObjectCreate(LBL, OBJ_LABEL, 0, 0, 0);
       ObjectSetText(LBL,text, fontsize, fontname, Tcolor);
       ObjectSet(LBL, OBJPROP_CORNER, side);
       ObjectSet(LBL, OBJPROP_XDISTANCE, pos_x);
       ObjectSet(LBL, OBJPROP_YDISTANCE, pos_y);
       }

void Fun_New_Bar()
  {
   New_Bar = false;
   
   if (New_Time!= Time[0])
   
      {
       New_Time = Time[0];
       New_Bar = true;
      }}
   
Reason: