OpLi_gw_V40_Lite

Download script
Author: Copyright � 2010, Xrust Soluton.
10 Views
0 Downloads
0 Favorites
OpLi_gw_V40_Lite
//+------------------------------------------------------------------+
//|                     Options Levels & Volumes XR © V40 + Lite.mq4 |
//|                                 Copyright © 2010, Xrust Soluton. |
//|                                       http://www.opmarketvol.com |
//|                                 xrustx@gmail.com xrust@mksat.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Xrust Soluton."
#property link      "http://www.opmarketvol.com"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Coral
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 DodgerBlue
#import "user32.dll"
   int GetWindowDC(int dc);
   int ReleaseDC(int h, int dc);
  bool GetWindowRect(int h, int& pos[4]);
#import
#import "gdi32.dll"
   int GetPixel(int dc, int x, int y);
#import
#import "kernel32.dll"
int WinExec(string cmd, int showConsole);
int  GetTimeZoneInformation(int& TZInfoArray[]);
#import
#import "inet.ex4"
  void request(string nm);
#include <WinUser32.mqh>
//+------------------------------------------------------------------+   
extern  string      SymbolSet          = "";//
extern    bool      Lite               = true;//
extern    bool      Pro                = false;//
extern    bool      ShowHistory        = true;//
extern    bool      ShowHistoryVolumes = true;//
extern    bool      ShowHistActLevels  = true;//
extern    bool      ShowActiveLevels   = false;//
extern    bool      ShowActiveColor    = true;//
extern     int      DepthHistoryInDays = 3;//
extern     int      VolumeFilter       = 0;//
extern    bool      nearest            = false;//
extern     int      near_to_the_price  = 2;//
extern     int      OnlineFwdInBars    = 10;//
extern     int      WidthHistoryLines  = 2;//
extern     int      WidthOlineLines    = 3;//
extern     int      HistoryFontSize    = 7;//
extern     int      OnlineFontSize     = 14;//
extern  string      FontName           = "Times new roman";//
//+------------------------------------------------------------------+
bool      Langvage_Ru_Engl   = true;
color      Option_Call_Color  = FireBrick;//
color      Call_In_Money_Clr  = DodgerBlue;//
color      Option_Put_Color   = MidnightBlue;//
color      Put_In_Money_Clr   = OrangeRed;//
//+------------------------------------------------------------------+
string requestfn = "request.opd";
string   symbols = "symbols.ini";
string      name = "";
string       ext = "_opt_hist.csv"; 
string  copyrite = "OptionsLevels&VolumesXR ©  ";
string       exp = "Expiration date = ";
string       cnm = "Contract name = ";
//+------------------------------------------------------------------+
string  nolistru = "Ýòîò èíñòðóìåíò íå ïîääåðæèâàåòñÿ, èëè åãî íåò â ñïèñêå.";
string  nolisten = "This currency is not supported, or it is not in the list."; 
string  entnamru = "Âåäèòå èìÿ èíñòðóìåíòà â ïåðåìåííóþ SymbolSet";
string  entnamen = "Enter the name of the currency in the variable SymbolSet";
string  erronlru = "Íåò äîñòóïà ê ôàéëó îíëàéí äàííûõ.\nÏîâòîð çàïðîñà áóäåò ïðîèçâåäåí ïðè ñëåäóþùåì îáðàùåíèè ê ñåðâåðó.\nÈëè ïåçàïóñòèòå èíäèêàòîð âðó÷íóþ.";
string  erronlen = "No file access online data.\n Perhaps you have not activated your account.\n Please contact technical support.";
string  indvisru = "Â ðåæèìå âèçóàëèçàöèè, èíäèêàöèÿ áóäåò \n îòðàæàòüñÿ êîððåêòíî òîëüêî íà òàéì ôðåéìå Ì5";
string  indvisen = "In the visual mode, the indication will \n display correctly only in the time frame M5";
string  faterrru = "Ïåðåçàãðóçèòå ñèñòåìó èëè\nîáðàòèòåñü http://realvolumes.ucoz.ru/forum/2-4-1";
string  faterren = "Fatal error\nreboot the system or contact http://realvolumes.ucoz.ru/forum/2-4-1";
string  errsinru = "Íåò äîñòóïà ê ôàéëó ñèíîíèìîâ\nÑèñòåìà áóäåò îñòàíîâëåíà\n×åðåç ";
string  errsinen = "No access to the symbols.ini file\nsystem will be stopped \nthrough";
string  errdayru = "Îæèäàéòå, èäåò äîêà÷êà èñòîðèè ïî ÒÔ D1, èëè çàêà÷àéòå ñàìîñòîÿòåëüíî";
string  errdayen = "Wait, is History download for D1 TimeFrame, or upload your own";
//+------------------------------------------------------------------+
int    date[365];
int       tz[43];
string  in[1000],copy[1000];
int  near1,near2;
int  prewtime =0;
bool     wait = false;
bool noonline = false;
bool geraze = true;
int Win_color;
int days;
//+------------------------------------------------------------------+
double price[];
double resist[];
double resstop[];
double supstop[];
double support[];
double midup[];
double middn[];
double online[15][4];
//+------------------------------------------------------------------+
void init(){
//+------------------------------------------------------------------+
   SetIndexStyle(0,DRAW_SECTION,STYLE_DOT);
   SetIndexBuffer(0,resist);
   SetIndexLabel(0,"StopResistanse");
   SetIndexStyle(1,DRAW_SECTION,STYLE_SOLID,2);
   SetIndexBuffer(1,resstop);
   SetIndexLabel(1,"Resistanse");
   SetIndexStyle(2,DRAW_SECTION,STYLE_SOLID,2);
   SetIndexBuffer(2,supstop);
   SetIndexLabel(2,"Support");
   SetIndexStyle(3,DRAW_SECTION,STYLE_DOT);
   SetIndexBuffer(3,support);
   SetIndexLabel(3,"StopSupport");   
//+------------------------------------------------------------------+
  near1=7-near_to_the_price; near2=8+near_to_the_price;  
//+------------------------------------------------------------------+
  if(isfile(symbols)!=0){request(symbols);wait=true;}else{wait=false;}
//+------------------------------------------------------------------+
  recalcdate();
//+------------------------------------------------------------------+  
  int hd=FileOpen("opml.tmp",FILE_CSV|FILE_READ);
  if(hd>0){FileReadString(hd);
  if(FileReadString(hd)==".en"){Langvage_Ru_Engl=false;}else{Langvage_Ru_Engl=true;}
  FileClose(hd);
  }  
//+------------------------------------------------------------------+  
   for(int i=0;i<100;i++){
     if(iTime(Symbol(),1440,i)<1){
       i--;
       if(Langvage_Ru_Engl){
         Comment(errdayru);
       }else{
         Comment(errdayen);
       }
     }
   }
//+------------------------------------------------------------------+   
return;}
//+------------------------------------------------------------------+
bool busy(){if(GlobalVariableCheck("busy")){return(true);}else{return(false);}}
//+------------------------------------------------------------------+
void deinit(){
  if(UninitializeReason()==REASON_REMOVE||
     UninitializeReason()==REASON_CHARTCLOSE||
     UninitializeReason()==REASON_PARAMETERS||
     UninitializeReason()==REASON_RECOMPILE||
     UninitializeReason()==REASON_ACCOUNT){
    ObjectDelete("cpo");
    ObjectDelete("exp");
    ObjectDelete("cnm");
    ObjectDelete("oicpo");
    ObjectDelete("oiexp");
    ObjectDelete("oicnm");
    delgr();
    int prewtime =0;
  }
  Comment("  ");
return;}
//+------------------------------------------------------------------+
void start(){//return;
static int pc =0;int col;
int x,i,tm0,tm1;string mode = "";
static int asd=0,sinerr = 30;
static string tmexp,contrnm;
//-------------------------------------------------------------------+
col = GetWndColor(Symbol());
if(col>0){
  Option_Call_Color  = Pink;//
  Call_In_Money_Clr  = Blue;//
  Option_Put_Color   = LightBlue;//
  Put_In_Money_Clr   = Red;//
}else{
  Option_Call_Color  = FireBrick;//
  Call_In_Money_Clr  = DodgerBlue;//
  Option_Put_Color   = MidnightBlue;//
  Put_In_Money_Clr   = Coral;//
}
if(col!=pc){pc=col;prewtime=0;}
//-------------------------------------------------------------------+
if(sinerr<=0){
       if(Langvage_Ru_Engl){
         Comment(faterrru);
       }else{
         Comment(faterren);
       }
  return;
}
if(iTime(Symbol(),1440,i)<1){
       if(Langvage_Ru_Engl){
         Comment(faterrru,"\nÍåäîñòàòî÷íî èñòîðèè ïî ÒÔ D1");
       }else{
         Comment(faterren,"\nEnough history on D1 TimeFrame");
       }
  return;
}
if(newday()){recalcdate();asd=0;}
//----áëîê ïðîâåðêè ñèìâîëà íà ñîîîòâåòñòâèå ñïèñêó------------------+
static int wc=0,errcount=0;
//----
  if(SymbolSet==""){SymbolSet=SymbolControl();} 
  if(SymbolControl()=="404"){
    request(symbols);
    sinerr--;
    if(Langvage_Ru_Engl){
      Comment(errsinru,sinerr," ñåê");
    }else{
      Comment(errsinen,sinerr," sec");
    }  
    return;
  }
//----
  if(SymbolSet==""){
    if(Langvage_Ru_Engl){
      Comment(nolistru,"\n",entnamru);
    }else{
      Comment(nolisten,"\n",entnamen);
    }   
    return;
  }
//----Çàïðàøèâàåì è âûâîäèì äàííûå-----------------------------------+
static int filecount=0;
bool c;
bool first=true;
int maxday;
string filenm;
//----
  maxday = ArraySize(date)-1;
  if(prewtime>TimeCurrent()){return;}
  if(!ShowHistory){
      prewtime=TimeCurrent()+300;
      filecount=0;  
      filenm = SymbolSet+date[filecount]+ext;
      if(!busy()){request(filenm);}else{prewtime=TimeCurrent()+10;Print("wait 10 sek");return;}
  }else{
    if(filecount>=maxday){
      prewtime=TimeCurrent()+300;
      recalcdate();
      filecount=0;
      filenm = SymbolSet+date[filecount]+ext;
      if(!busy()){request(filenm);}else{prewtime=TimeCurrent()+10;Print("wait 10 sek");return;}
    }
  }
  filenm = SymbolSet+date[filecount]+ext;
  if(date[filecount]==0){recalcdate();return;}
  if(filecount!=0){if(isfile(filenm)!=0){if(!busy()){request(filenm);}else{prewtime=TimeCurrent()+10;Print("wait 10 sek");return;}}}
  
    if(errcount>2){
      date[filecount]=0;
      filecount++; 
      errcount=0;
    }   
    if(!ReadFile(filenm,date[filecount])){errcount++;return;}
    if(date[0]==0){
      if(Langvage_Ru_Engl){
        Comment(erronlru);
      }else{
        Comment(erronlen);
      }
    }else{Comment("  ");}
    int razm = ArraySize(in)-1; 
    if(TimeHour(TimeCurrent())+(timesdvig()/3600)<0){i=1;}else{i=0;}
    if(date[filecount]>=StrToTime(TimeToStr(TimeCurrent()-(86400*i),TIME_DATE))){//òîëüêî ñâåæèå äàííûå
    if(IsTesting()||IsVisualMode()||IsOptimization()){
       ShowHistory=false;
       OnlineFontSize=HistoryFontSize;
       if(Period()>5){
          if(Langvage_Ru_Engl){
             Comment(indvisru);
          }else{
             Comment(indvisen);
          }
       }  
       if(StrToInteger(StringSubstr(in[asd],0,10))<TimeCurrent()){
          asd++;
          return;
       }
       i=asd;
       tm0=TimeCurrent()+(Period()*OnlineFwdInBars*60+timesdvig());
       tm1=StrToInteger(StringSubstr(in[i-1],0,10));      
    }else{//if(IsTesting()||IsVisualMode()||IsOptimization()){
       i=razm;
       tm0=TimeCurrent()+(Period()*OnlineFwdInBars*60+timesdvig());
       tm1=StrToInteger(StringSubstr(in[i],0,10));     
    }        
       ArrayResize(copy,ArraySize(in));
       ArrayCopy(copy,in,0,0,WHOLE_ARRAY);
       in[i]=StringSubstr(in[i],10);
       int timeperenos = tm1;
          delonl();
          for(x=0;x<15;x++){int pos;
             pos=StringFind(in[i],",",1);
             double callprs =nd(StrToDouble(StringSubstr(in[i],1,pos)));
             online[x][0]=callprs;
             in[i]=StringSubstr(in[i],pos);         
             pos=StringFind(in[i],",",1);
             double callvol =nd(StrToDouble(StringSubstr(in[i],1,pos)));
             online[x][1]=callvol;
             in[i]=StringSubstr(in[i],pos);            
             pos=StringFind(in[i],",",1);
             double putprs =nd(StrToDouble(StringSubstr(in[i],1,pos)));
             online[x][2]=putprs;
             in[i]=StringSubstr(in[i],pos);            
             pos=StringFind(in[i],",",1);
             double putvol =nd(StrToDouble(StringSubstr(in[i],1,pos)));
             online[x][3]=putvol;
             in[i]=StringSubstr(in[i],pos);
             if(callvol!=0&&callprs!=0&&tm0!=0&&tm1!=0){
               if(ShowActiveLevels){
                 if(callprs<Close[0]){           
                   SetTLine(true,Call_In_Money_Clr,"Call", tm0,callprs,tm1,callprs,WidthOlineLines,callvol);
                   SetText(true,Call_In_Money_Clr,tm0,callprs,"              "+DoubleToStr(callvol,0),OnlineFontSize);  
                 }               
               }else{
                 if(ShowActiveColor){
                   if(callprs<Close[0]){           
                     SetTLine(true,Call_In_Money_Clr,"Call", tm0,callprs,tm1,callprs,WidthOlineLines,callvol);
                     SetText(true,Call_In_Money_Clr,tm0,callprs,"              "+DoubleToStr(callvol,0),OnlineFontSize);  
                   }else{
                     SetTLine(true,Option_Call_Color,"Call", tm0,callprs,tm1,callprs,WidthOlineLines,callvol);
                     SetText(true,Option_Call_Color,tm0,callprs,"              "+DoubleToStr(callvol,0),OnlineFontSize);                
                   }
                 }else{
                   SetTLine(true,Put_In_Money_Clr,"Call", tm0,callprs,tm1,callprs,WidthOlineLines,callvol);
                   SetText(true,Put_In_Money_Clr,tm0,callprs,"              "+DoubleToStr(callvol,0),OnlineFontSize);               
                 }
               }
             }              
             if(putvol!=0&&putprs!=0&&tm0!=0&&tm1!=0){
               if(ShowActiveLevels){
                 if(putprs>Close[0]){
                   SetTLine(true,Put_In_Money_Clr,"Put", tm0,putprs,tm1,putprs,WidthOlineLines,putvol);
                   SetText(true,Put_In_Money_Clr,tm0+Period()*180,putprs,"              "+DoubleToStr(putvol,0),OnlineFontSize);    
                 }               
               }else{ 
                 if(ShowActiveColor){
                   if(putprs>Close[0]){
                     SetTLine(true,Put_In_Money_Clr,"Put", tm0,putprs,tm1,putprs,WidthOlineLines,putvol);
                     SetText(true,Put_In_Money_Clr,tm0+Period()*180,putprs,"              "+DoubleToStr(putvol,0),OnlineFontSize);    
                   }else{
                     SetTLine(true,Option_Put_Color,"Put", tm0,putprs,tm1,putprs,WidthOlineLines,putvol);
                     SetText(true,Option_Put_Color,tm0+Period()*180,putprs,"              "+DoubleToStr(putvol,0),OnlineFontSize);   
                   }              
                 }else{
                   SetTLine(true,Call_In_Money_Clr,"Put", tm0,putprs,tm1,putprs,WidthOlineLines,putvol);
                   SetText(true,Call_In_Money_Clr,tm0+Period()*180,putprs,"              "+DoubleToStr(putvol,0),OnlineFontSize);                 
                 }
               }
             }              
           }            
           pos=StringFind(in[i],",",1);
           tmexp = TimeToStr(((StrToInteger(StringSubstr(in[i],1,pos-1))-25569)*86400),TIME_DATE);
           in[i]=StringSubstr(in[i],pos);
           pos=StringFind(in[i],",",1);
           contrnm = StringSubstr(in[i],1,pos-1);
           in[i]=StringSubstr(in[i],pos);
           pos=StringFind(in[i],",",1);
           mode = StringSubstr(in[i],1,pos-1);
           first=false;    
           if(Lite){
             double br0 = iBarShift(Symbol(),0,tm1);
             double br1 = iBarShift(Symbol(),0,tm0);
             int nco = MathMax(br0,br1);
             for(x=0;x<nco;x++){
             int xy;
              for(xy=0;xy<15;xy++){if(online[xy][2]>=High[x]&&online[xy][3]>0){break;}}
              if(online[xy][2]!=0){resist[x]=online[xy][2];}
              for(xy=0;xy<15;xy++){if(online[xy][0]>=High[x]&&online[xy][0]<resist[x]){break;}}
              if(online[xy][1]!=0){resstop[x]=online[xy][0];}else{resstop[x]=resist[x];}
              for(xy=14;xy>=0;xy--){if(online[xy][0]<=Low[x]&&online[xy][1]>0){break;}}
              if(online[xy][1]!=0){support[x]=online[xy][0];}
              for(xy=14;xy>=0;xy--){if(online[xy][2]<=Low[x]&&online[xy][2]>support[x]){break;}}
              if(online[xy][2]!=0){supstop[x]=online[xy][2];}else{supstop[x]=support[x];}
             }
           }                 
      if(!ShowHistory){if(filecount>0){filecount=0;return;}}
      ArrayCopy(in,copy,0,0,WHOLE_ARRAY);
    }else{razm++;}//îíëàéí äàííûå  
    if(ShowHistory){// ïëþñ èñòîðèÿ
      for(i=razm;i>0;i--){
          tm0=StrToInteger(StringSubstr(in[i],0,10));
          tm1=StrToInteger(StringSubstr(in[i-1],0,10));  
          if (tm1==0){tm1=date[filecount];}
          in[i]=StringSubstr(in[i],10);
          for(x=0;x<15;x++){
             pos=StringFind(in[i],",",1);
             callprs =nd(StrToDouble(StringSubstr(in[i],1,pos)));
             online[x][0]=callprs;
             in[i]=StringSubstr(in[i],pos);          
             pos=StringFind(in[i],",",1);
             callvol =nd(StrToDouble(StringSubstr(in[i],1,pos)));
             online[x][1]=callvol;
             in[i]=StringSubstr(in[i],pos);            
             pos=StringFind(in[i],",",1);
             putprs =nd(StrToDouble(StringSubstr(in[i],1,pos)));
             online[x][2]=putprs;
             in[i]=StringSubstr(in[i],pos);            
             pos=StringFind(in[i],",",1);
             putvol =nd(StrToDouble(StringSubstr(in[i],1,pos)));
             online[x][3]=putvol;
             in[i]=StringSubstr(in[i],pos); 
             if(Pro){
             if(nearest){
               if(x>near1&&x<near2){//åñëè áëèçæàéøèå
                 if(callvol!=0&&callprs!=0&&tm0!=0&&tm1!=0){// ïðîâåðêà íà "íîëü"  
                   if(VolumeFilter<callvol){          
                     SetTLine(geraze,Option_Call_Color,"Call", tm0,callprs,tm1,callprs,WidthHistoryLines,callvol);
                     if(ShowHistoryVolumes){SetText(geraze,Option_Call_Color,tm1,callprs,"              "+DoubleToStr(callvol,0),HistoryFontSize);} 
                   }
                 }              
                 if(putvol!=0&&putprs!=0&&tm0!=0&&tm1!=0){ 
                   if(VolumeFilter<putvol){
                     //if(ShowActiveColor){
                     SetTLine(geraze,Option_Put_Color,"Put", tm0,putprs,tm1,putprs,WidthHistoryLines,putvol);
                     if(ShowHistoryVolumes){SetText(geraze,Option_Put_Color,tm1,putprs,"              "+DoubleToStr(putvol,0),HistoryFontSize);}  
                   }   
                 } 
               }    
             }else{//åñëè âñå            
                if(callvol!=0&&callprs!=0&&tm0!=0&&tm1!=0){
                   if(VolumeFilter<callvol){  
                      if(ShowHistActLevels){  
                         if(callprs<iLow(Symbol(),0,iBarShift(Symbol(),0,tm1))||callprs<iLow(Symbol(),0,iBarShift(Symbol(),0,tm0))){      
                           SetTLine(geraze,Call_In_Money_Clr,"Call", tm0,callprs,tm1,callprs,WidthHistoryLines,callvol);
                           if(ShowHistoryVolumes){SetText(geraze,Call_In_Money_Clr,tm1,callprs,"              "+DoubleToStr(callvol,0),HistoryFontSize);} 
                         }
                      }else{
                        if(ShowActiveColor){
                          if(callprs<iLow(Symbol(),0,iBarShift(Symbol(),0,tm1))||callprs<iLow(Symbol(),0,iBarShift(Symbol(),0,tm0))){      
                            SetTLine(geraze,Call_In_Money_Clr,"Call", tm0,callprs,tm1,callprs,WidthHistoryLines,callvol);
                            if(ShowHistoryVolumes){SetText(geraze,Call_In_Money_Clr,tm1,callprs,"              "+DoubleToStr(callvol,0),HistoryFontSize);} 
                          }else{
                            SetTLine(geraze,Option_Call_Color,"Call", tm0,callprs,tm1,callprs,WidthHistoryLines,callvol);
                            if(ShowHistoryVolumes){SetText(geraze,Option_Call_Color,tm1,callprs,"              "+DoubleToStr(callvol,0),HistoryFontSize);}                           
                          }                        
                        }else{
                        SetTLine(geraze,Put_In_Money_Clr,"Call", tm0,callprs,tm1,callprs,WidthHistoryLines,callvol);
                        if(ShowHistoryVolumes){SetText(geraze,Put_In_Money_Clr,tm1,callprs,"              "+DoubleToStr(callvol,0),HistoryFontSize);} 
                        }                      
                      }
                   }  
                }              
                if(putvol!=0&&putprs!=0&&tm0!=0&&tm1!=0){ 
                   if(VolumeFilter<putvol){
                      if(ShowHistActLevels){
                        if(putprs>iHigh(Symbol(),0,iBarShift(Symbol(),0,tm1))||putprs>iHigh(Symbol(),0,iBarShift(Symbol(),0,tm0))){ 
                          SetTLine(geraze,Put_In_Money_Clr,"Put", tm0,putprs,tm1,putprs,WidthHistoryLines,putvol);
                          if(ShowHistoryVolumes){SetText(geraze,Put_In_Money_Clr,tm1,putprs,"              "+DoubleToStr(putvol,0),HistoryFontSize);}  
                        }                     
                      }else{
                        if(ShowActiveColor){
                          if(putprs>iHigh(Symbol(),0,iBarShift(Symbol(),0,tm1))||putprs>iHigh(Symbol(),0,iBarShift(Symbol(),0,tm0))){
                            SetTLine(geraze,Put_In_Money_Clr,"Put", tm0,putprs,tm1,putprs,WidthHistoryLines,putvol);
                            if(ShowHistoryVolumes){SetText(geraze,Put_In_Money_Clr,tm1,putprs,"              "+DoubleToStr(putvol,0),HistoryFontSize);}                          
                          }else{
                            SetTLine(geraze,Option_Put_Color,"Put", tm0,putprs,tm1,putprs,WidthHistoryLines,putvol);
                            if(ShowHistoryVolumes){SetText(geraze,Option_Put_Color,tm1,putprs,"              "+DoubleToStr(putvol,0),HistoryFontSize);}
                          }
                        }else{
                          SetTLine(geraze,Call_In_Money_Clr,"Put", tm0,putprs,tm1,putprs,WidthHistoryLines,putvol);
                          if(ShowHistoryVolumes){SetText(geraze,Call_In_Money_Clr,tm1,putprs,"              "+DoubleToStr(putvol,0),HistoryFontSize);}                        
                        }
                      }
                   }     
                }                 
             }//if(nearest){else   
             }//if(Pro)
          }  
          if(Lite){
             nco = iBarShift(Symbol(),0,tm1-timesdvig());
             int nca = iBarShift(Symbol(),0,tm0-timesdvig());
             for(x=nca;x<nco;x++){
                for(xy=0;xy<15;xy++){if(online[xy][2]>=High[x]&&online[xy][3]>0){break;}}
                if(online[xy][2]!=0){resist[x]=online[xy][2];}
                for(xy=0;xy<15;xy++){if(online[xy][0]>=High[x]&&online[xy][0]<resist[x]){break;}}
                if(online[xy][1]!=0){resstop[x]=online[xy][0];}else{resstop[x]=resist[x];}
                for(xy=14;xy>=0;xy--){if(online[xy][0]<=Low[x]&&online[xy][1]>0){break;}}
                if(online[xy][1]!=0){support[x]=online[xy][0];}
                for(xy=14;xy>=0;xy--){if(online[xy][2]<=Low[x]&&online[xy][2]>support[x]){break;}}
                if(online[xy][2]!=0){supstop[x]=online[xy][2];}else{supstop[x]=support[x];}
             }
          }                                     
       }
    }
    if(filecount<maxday){filecount++;}//else{filecount=0;}
    if(filecount<1){geraze = true;}else{geraze = false;}
//+------------------------------------------------------------------+
    if(mode != "Demo"){mode = "Online";}
    string copyrite="OptionsLevels&VolumesXR © "+mode+" V3 ";
    string exp = "Expiration date = " + tmexp;
    string cnm = "Contract name = " + contrnm;
    SetLabel("cpo",copyrite,DimGray,1,1,3,9);
    SetLabel("exp",exp,DimGray,1,15,3,9);
    SetLabel("cnm",cnm,DimGray,1,27,3,9);
//+------------------------------------------------------------------+      
return;}
//+------------------------------------------------------------------+
int timesdvig(){
ArrayResize(tz,43);
ArrayInitialize(tz,0);
GetTimeZoneInformation(tz);
int srvho=TimeHour(TimeCurrent());
int sysho=TimeHour(TimeLocal());
int sdv=tz[0]/60;
int grn=sysho+sdv;
if(grn==24){grn=0;}
int res=srvho-(grn+1);
return((res*3600)*(-1));
}
//+------------------------------------------------------------------+
bool newday(){if(TimeHour(TimeCurrent())+(timesdvig()/3600)>=0){return(true);}else{return(false);}}
//+------------------------------------------------------------------+
void recalcdate(){days = DepthHistoryInDays;
  ArrayResize(date,100);
  ArrayInitialize(date,0);
  int x=0;
  int time_0=TimeHour(TimeCurrent())+(timesdvig()/3600);
  if(time_0<0){days++;}
  for(int i=0;i<=days;i++){
    if(i==0){if(time_0<0){i=1;}}
    if(TimeDayOfWeek(StrToTime(TimeToStr(TimeCurrent()-(86400*i),TIME_DATE)))!=0&&
       TimeDayOfWeek(StrToTime(TimeToStr(TimeCurrent()-(86400*i),TIME_DATE)))!=6){
      date[x]=StrToTime(TimeToStr(TimeCurrent()-(86400*i),TIME_DATE));
      x++;
    }else{days++;}  
  }
  ArrayResize(date,x);
return;
}
//+------------------------------------------------------------------+ 
void delgr(){
   for(int i=ObjectsTotal();i>=0;i--){
     if("txt"==StringSubstr(ObjectName(i),0,3)){ObjectDelete(ObjectName(i));}
     if("option"==StringSubstr(ObjectName(i),0,6)){ObjectDelete(ObjectName(i));}
     if("onl"==StringSubstr(ObjectName(i),0,3)){ObjectDelete(ObjectName(i));}
     if("online"==StringSubstr(ObjectName(i),0,6)){ObjectDelete(ObjectName(i));}
     ObjectDelete("cpo");
   }
   geraze = true;
return;
}   
//+------------------------------------------------------------------+ 
void delonl(){
  for(int i=ObjectsTotal();i>=0;i--){
    if("onl"==StringSubstr(ObjectName(i),0,3)){ObjectDelete(ObjectName(i));}
    if("online"==StringSubstr(ObjectName(i),0,6)){ObjectDelete(ObjectName(i));}
  }
return;
}
//+------------------------------------------------------------------+
string SymbolControl(){string in[100];string sy="404";int hd;
   hd=FileOpen(symbols,FILE_CSV|FILE_READ,";"); 
   if(hd<0){return(sy);}
   sy="";
   for(int i=0;i<100;i++){
     in[i]=FileReadString(hd);
     if(FileIsEnding(hd)){break;}
   }  
   ArrayResize(in,i);
   FileClose(hd);
   for(int x=0;x<=i;x++){
     if(StringFind(in[x],Symbol(),0)>=0){
       int count=StringFind(in[x],",",0);
       sy=StringSubstr(in[x],0,count);
     }  
   }  
return(sy);
}
//+------------------------------------------------------------------+
double nd(double in){return(NormalizeDouble(in,Digits));}
//+------------------------------------------------------------------+
void SetLabel(string nm, string tx, color cl, int xd, int yd, int cr=0, int fs=9) {//if(Lite){return;}
  if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_LABEL, 0, 0,0);
  ObjectSetText(nm, tx,fs,"Times new roman", cl);
  ObjectSet(nm, OBJPROP_COLOR    , cl);
  ObjectSet(nm, OBJPROP_XDISTANCE, xd);
  ObjectSet(nm, OBJPROP_YDISTANCE, yd);
  ObjectSet(nm, OBJPROP_CORNER   , cr);
  ObjectSet(nm, OBJPROP_FONTSIZE , fs);
  ObjectSet(nm, OBJPROP_BACK , false);
}
//+------------------------------------------------------------------+   
void SetText(bool eraze,color cl,int t1,double p1,string tx="",int razm=8){string nm;//if(Lite){return;}
  if(!eraze){
    nm="txt"+tx+DoubleToStr(p1,Digits);
    if(ObjectFind(nm)<0){
      ObjectCreate(nm, OBJ_TEXT, 0, 0,0, 0,0);
      ObjectSet(nm, OBJPROP_TIME1 , t1-timesdvig());
      ObjectSet(nm, OBJPROP_PRICE1, p1);
      ObjectSetText(nm,tx,razm,FontName,cl);
      ObjectSet(nm, OBJPROP_BACK , false);
    }    
  }else{
    nm="onl"+tx+DoubleToStr(p1,Digits);
    ObjectCreate(nm, OBJ_TEXT, 0, 0,0, 0,0);
    ObjectSet(nm, OBJPROP_TIME1 , t1-timesdvig());
    ObjectSet(nm, OBJPROP_PRICE1, p1);
    ObjectSetText(nm,tx,razm,FontName,cl);
    ObjectSet(nm, OBJPROP_BACK , false);  
  }  

return;
}
//+------------------------------------------------------------------+
void SetTLine(bool eraze,
              color cl, 
              string nm="",
              datetime t1=0, 
              double p1=0, 
              datetime t2=0, 
              double p2=0,
              int wd=1,
              int vol=0) {string nmm;//if(Lite){return;}
  if(!eraze){nmm="option";}else{nmm="online";}            
  nm = nmm + nm +
     " Prise="+DoubleToStr(p1,4)+
     " Volume="+vol+
     " Time"+TimeToStr(t2-timesdvig(),TIME_DATE|TIME_MINUTES);
  if (t1<=0) t1=Time[10];
  if (p1<=0) p1=Low[10];
  if (t2<=0) t2=Time[0];
  if (p2<=0) p2=Bid;
  if(!eraze){
    if(ObjectFind(nm)<0){ObjectCreate(nm, OBJ_TREND, 0, 0,0, 0,0);}
  }else{  
    ObjectCreate(nm, OBJ_TREND, 0, 0,0, 0,0);
  }  
  ObjectSet(nm, OBJPROP_TIME1 , t1-timesdvig());
  ObjectSet(nm, OBJPROP_PRICE1, p1);
  ObjectSet(nm, OBJPROP_TIME2 , t2-timesdvig());
  ObjectSet(nm, OBJPROP_PRICE2, p2);
  ObjectSet(nm, OBJPROP_COLOR , cl);
  ObjectSet(nm, OBJPROP_RAY   , false);
  ObjectSet(nm, OBJPROP_STYLE , 0);
  ObjectSet(nm, OBJPROP_WIDTH , wd);
  ObjectSet(nm, OBJPROP_BACK , false);
}
//+------------------------------------------------------------------+
bool ReadFile(string fn,int tm){int i, hd; 
   ArrayResize(in,1000);
   hd=FileOpen(fn,FILE_CSV|FILE_READ,";"); 
   if(hd<0){return(false);}
    string res=FileReadString(hd);
    if(res=="404"){
      FileClose(hd);
      return(false);
    }   
   FileSeek(hd,SEEK_SET,0); 
   for(i=0;i<1000;i++){
     res=FileReadString(hd);
     if(StringSubstr(res,0,2)=="12"){in[i]=res;}else{break;}
     if(FileIsEnding(hd)){break;}
   }  
   ArrayResize(in,i);
   FileClose(hd);
   return(true);
} 
//+------------------------------------------------------------------+
int isfile(string fn){
  int hd = FileOpen(fn,FILE_CSV|FILE_READ,";");
  if( hd>0){
    string res=FileReadString(hd);
    if(res=="404"){
      FileClose(hd);
      return(404);
    }  
    FileClose(hd);
    return(0);
  }else{return(GetLastError());}
}
int GetWndColor(string sy)
   { 
     int hWnd = WindowHandle(sy, Period());
     int hDC = GetWindowDC(hWnd);
     int rect[4];
     GetWindowRect(hWnd, rect);
     int wW = rect[2] - rect[0];         // øèðèíà îêíà
     int wH = rect[3] - rect[1];         // âûñîòà îêíà
     
     int col = GetPixel(hDC, 2, 2);
     if(col==-1)                         // ëåâûé âåðõíèé óãîë íå âèäåí
     {
       col = GetPixel(hDC, wW-3, wH-3); 
       if(col==-1)                       // ïðàâûé íèæíèé óãîë íå âèäåí
       col = GetPixel(hDC, 2, wH-3); 
       if(col==-1)                       // ëåâûé íèæíèé óãîë íå âèäåí
       col = GetPixel(hDC, wW-3, 2);     
       if(col==-1)                       // ïðàâûé âåðõíèé óãîë íå âèäåí
       {
         ReleaseDC(hWnd, hDC);
         return(Win_color);
       }
      }
     ReleaseDC(hWnd, hDC);
     return(col);
   }
//+------------------------------------------------------------------+ 

Comments