WindowScreenShot

 

hello, I added the screenshot function to each of the output buffer 1 and 2, I would like an opinion from you on the correct coding, as the markets are closed and I can not do live testing

//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 2

#property indicator_type1 DRAW_ARROW
#property indicator_width1 1
#property indicator_color1 Blue
#property indicator_label1 ""

#property indicator_type2 DRAW_ARROW
#property indicator_width2 1
#property indicator_color2 Lime
#property indicator_label2 ""

//--- indicator buffers
double Buffer1[];
double Buffer2[];


string GetFileName()
{
string T=TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES);
string Str=Symbol()+"_"+StringSetChar(T,StringFind(T,":"),'.')+".gif";
return (Str);
}

string GetFileName2()
{
string T=TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES);
string Str=Symbol()+"_"+StringSetChar(T,StringFind(T,":"),'.')+".gif";
return (Str);
}



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {  
   IndicatorBuffers(2);
  
   SetIndexBuffer    (0, Buffer1);
   SetIndexEmptyValue(0, 0);
   SetIndexArrow     (0, 242);
  
   SetIndexBuffer    (1, Buffer2);
   SetIndexEmptyValue(1, 0);
   SetIndexArrow     (1, 241);  
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
   int limit = rates_total - prev_calculated;
   //--- counting from 0 to rates_total
   ArraySetAsSeries(Buffer1, true);
   ArraySetAsSeries(Buffer2, true);
   //--- initial zero
   if(prev_calculated < 1)
     {
      ArrayInitialize(Buffer1, 0);
      ArrayInitialize(Buffer2, 0);
     }
   else
      limit++;
  
   //--- main loop
   for(int i = limit-1; i >= 0; i--)
     {
      if (i >= MathMin(5000-1, rates_total-1-50)) continue;  
    


     //Indicator Buffer 1 Sell
      if(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 2+i) < 90
      && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) > 90
      )
        {        
         Buffer1[i] = High[i] + 10 * Point();
        }
        
   string FileName;  
   if (Buffer1[i])
   {    
    FileName=GetFileName();
    WindowScreenShot(FileName,1280,720);
   }

                  
      //Indicator Buffer 2 Buy
      if(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE,2+i) > 10
      && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE,1+i) < 10      
      )
        {        
         Buffer2[i] = Low[i] - 10 * Point();          
        }
        
   string FileName2;  
   if (Buffer2[i])
   {    
    FileName2=GetFileName2();
    WindowScreenShot(FileName2,1280,720);
   }

        
      
     }
   return(rates_total);
  }
  
//+------------------------------------------------------------------+
 
         Buffer1[i] = High[i] + 10 * Point();
        }
   if (Buffer1[i])
BufferX is a double not a boolean. Your condition will always be true.
 
whroeder1:
         Buffer1[i] = High[i] + 10 * Point();
        }
   if (Buffer1[i])
BufferX is a double not a boolean. Your condition will always be true.
How could I integrate this function to each of the buffer signal?
 

I modified the code in this way, is that correct?

//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 2

#property indicator_type1 DRAW_ARROW
#property indicator_width1 1
#property indicator_color1 Blue
#property indicator_label1 ""

#property indicator_type2 DRAW_ARROW
#property indicator_width2 1
#property indicator_color2 Lime
#property indicator_label2 ""

//--- indicator buffers
double Buffer1[];
double Buffer2[];


string GetFileName()
{
string T=TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES);
string Str=Symbol()+"_"+StringSetChar(T,StringFind(T,":"),'.')+".gif";
return (Str);
}

string GetFileName2()
{
string T=TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES);
string Str=Symbol()+"_"+StringSetChar(T,StringFind(T,":"),'.')+".gif";
return (Str);
}


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {  
   IndicatorBuffers(2);
  
   SetIndexBuffer    (0, Buffer1);
   SetIndexEmptyValue(0, 0);
   SetIndexArrow     (0, 242);
  
   SetIndexBuffer    (1, Buffer2);
   SetIndexEmptyValue(1, 0);
   SetIndexArrow     (1, 241);  
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
   int limit = rates_total - prev_calculated;
   //--- counting from 0 to rates_total
   ArraySetAsSeries(Buffer1, true);
   ArraySetAsSeries(Buffer2, true);
   //--- initial zero
   if(prev_calculated < 1)
     {
      ArrayInitialize(Buffer1, 0);
      ArrayInitialize(Buffer2, 0);
     }
   int i=0;
    


     //Indicator Buffer 1 Sell
      if(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 2+i) < 90
      && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 1+i) > 90
      )
      
      string FileName;
        {  
         FileName=GetFileName();
         WindowScreenShot(FileName,1280,720);      
         Buffer1[i] = High[i] + 10 * Point();
        }
        
  
                  
      //Indicator Buffer 2 Buy
      if(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE,2+i) > 10
      && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE,1+i) < 10      
      )
      
      string FileName2;
        {    
         FileName2=GetFileName2();
         WindowScreenShot(FileName2,1280,720);    
         Buffer2[i] = Low[i] - 10 * Point();          
        }    
      
    
      
    
   return(rates_total);
  }
  
//+------------------------------------------------------------------+
Reason: