Scrennshot at singnal indicator

Back to topics list To post a new topic, please log in or register
avatar
86
fly7680 2016.06.19 22:51
 
hello, I have another question for further growth in programming.
I have this script that I need to connect to my indicator, every sgnale / Arrow script run one scrennshot.
After studying the script I always get errors like I could solve?

Thank you all


P.S.: sorry for my English and my poor preparation in MQL4 code


//+-------------Script------------------------------+
extern string note1 = "Capture chart ON/OFF ";
extern bool ScreenshotON = true; 
extern string SavedChartsFolder = "charts screenshot/"; 


string PeriodDesc(int TF_0) {
   switch (TF_0) {
   case 1:
      return ("M1");
   case 5:
      return ("M5");
   case 15:
      return ("M15");
   case 30:
      return ("M30");
   case 60:
      return ("H1");
   case 240:
      return ("H4");
   case 1440:
      return ("D1");
   case 10080:
      return ("W1");
   case 43200:
      return ("MN");
   }
   return ("Unknown TF");
}
   
string DateTimeReformat(string dat_0) {
   string dat_8;
   string dat_ret_16 = "";
   dat_0 = " " + dat_0;
   int dat_len_24 = StringLen(dat_0);
   for (int dat_28 = 0; dat_28 < dat_len_24; dat_28++) {
      dat_8 = StringSetChar(dat_8, 0, StringGetChar(dat_0, dat_28));
      if (dat_8 != ":" && dat_8 != " " && dat_8 != ".") dat_ret_16 = dat_ret_16 + dat_8;
   }
   return (dat_ret_16);
} 
   
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start() {   

string pretxt_40;
   
pretxt_40 = SavedChartsFolder + Symbol() + "_" + PeriodDesc(Period()) + "_" + "strategy name"+"_" + DateTimeReformat(TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES|TIME_SECONDS));
WindowScreenShot(pretxt_40 + ".png",1200, 600, 0, -1, -1); // * careful with file type
PlaySound ("shutter.wav");            
}
   return(0);
//+-----------------------End Sript---------------------------------+


//+------------------------MY INDICATOR------------------------------+

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

#property indicator_type1 DRAW_ARROW
#property indicator_width1 1
#property indicator_color1 0xFFAA00
#property indicator_label1 ""

#property indicator_type2 DRAW_ARROW
#property indicator_width2 1
#property indicator_color2 0x0000FF
#property indicator_label2 ""

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

extern double Doji = 0.3;
extern int PeriodRSX = 4;
datetime time_alert; //used when sending alert
bool Audible_Alerts = true;

void myAlert(string type, string message)
  {
   if(type == "print")
      Print(message);
   else if(type == "error")
     {
      Print(type+" | RSInoRepaint @ "+Symbol()+","+Period()+" | "+message);
     }
   else if(type == "order")
     {
     }
   else if(type == "modify")
     {
     }
   else if(type == "indicator")
     {
      if(Audible_Alerts) Alert(type+" | RSInoRepaint @ "+Symbol()+","+Period()+" | "+message);
     }
  }

//+------------------------------------------------------------------+
//| 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; //omit some old rates to prevent "Array out of range" or slow calculation   
      //Indicator Buffer 1
      if(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, i) > 80 //Relative Strength Index > fixed value
      
      )
        {
         Buffer1[i] = Close[i] + 3 * Point(); //Signal and Scrennshot
         if(i == 0 && Time[0] != time_alert) { myAlert("indicator", ""); time_alert = Time[0]; } //Instant alert, only once per bar
        }
      else
        {
         Buffer1[i] = 0;
        }
      //Indicator Buffer 2
      if(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, i) < 20 //Relative Strength Index < fixed value
      
      )
        {
         Buffer2[i] = Close[i] - 3 * Point(); //Signal and Scrennshot 
        if(i == 0 && Time[0] != time_alert) { myAlert("indicator", ""); time_alert = Time[0]; } //Instant alert, only once per bar
        }
      else
        {
         Buffer2[i] = 0;
        }
     }
   return(rates_total);
  }
//+----------------------End MY INDICATOR--------------------------------------------+
Back to topics list  

To add comments, please log in or register