Standard indicators override?! - page 5

 
Here is the new version of the Satori indicator (only the indices for currencies Currency1 and Currency1 have been added)
//+------------------------------------------------------------------+
//|                                           RedrawIndicators-2.mq4 |
//|                                                           Satori |
//|                             http://www.metaquotes.ru/forum/7790/ |
//+------------------------------------------------------------------+
#property copyright "Satori"
#property link      "http://www.metaquotes.ru/forum/7790/"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Yellow
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
extern int       BarsCount=20;   //кол-во считаемых баров, если 0 - то все
extern string    Currency1="EURUSD";
extern string    Currency2="GBPUSD";

int handle,handle2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexLabel(0,Currency1);

   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexLabel(1,Currency2);

   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer3);

   handle= FileOpen("TestFile.csv",FILE_CSV|FILE_WRITE,';');
   handle2= FileOpen("TestFile2.csv",FILE_CSV|FILE_WRITE,';');
  if(handle<1 || handle2<1 )
   {
    Print("Файл не обнаружен, последняя ошибка ", GetLastError());
    return(false);
   }
   else
   {
   FileWrite (handle,"index",Symbol(),"","index1",Currency1,"","index2",Currency2);
   FileWrite (handle2,"index",Symbol(),"  ",Currency1,"  ",Currency2);
   }

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   FileClose(handle);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int i;
   double test1,test2;
   datetime tt1,tt2,TimeMain;
   BarsCount=MathMin(Bars,(MathMin(iBars(Currency1,Period()),iBars(Currency2,Period()))));
   for (i=0;i<BarsCount-counted_bars;i++)
      {
       TimeMain=Time[i];
       ExtMapBuffer1[i]=iTime(Currency1,Period(),iBarShift(Currency1,Period(),TimeMain));
       ExtMapBuffer2[i]=iTime(Currency2,Period(),iBarShift(Currency2,Period(),TimeMain));
       ExtMapBuffer3[i]=(ExtMapBuffer1[i]-ExtMapBuffer2[i]);
       tt1=Time[i]-ExtMapBuffer1[i];
       tt2=Time[i]-ExtMapBuffer2[i];
       if (ExtMapBuffer3[i]!=0 || tt1!=0 || tt2!=0) 
         {
         if (FileWrite (handle,
         i,TimeToStr(Time[i]),"",iBarShift(Currency1,Period(),ExtMapBuffer1[i]),TimeToStr(ExtMapBuffer1[i]),"",iBarShift(Currency2,Period(),ExtMapBuffer2[i]),TimeToStr(ExtMapBuffer2[i])
          )<=0) Print("нифига не пишет!!");
         }
        FileFlush(handle);
        if ((iTime(Symbol(),Period(),i)!=iTime(Currency1,Period(),i) ||
           Time[i]!=iTime(Currency1,Period(),i) ||
           iTime(Currency1,Period(),i)!=iTime(Currency2,Period(),i)
           ) && i>0)
        {
         if (FileWrite (handle2,i,
         TimeToStr(Time[i])," ",TimeToStr(iTime(Currency1,Period(),i))," ",TimeToStr(iTime(Currency2,Period(),i))
       )<=0) Print("нифига не пишет!!");

        }
      }//----
   return(0);
  }
//+------------------------------------------------------------------+
 
Opened a new account to check in MIG. Started the indicator, then took it off the chart, checked the created charts - not a single error (files are empty). Now I will check the archive of quotes by MIG for GBPJPY H4, EURUSD H4, GBPUSD H4 (for the purity of the experiment I used currencies from previous checks)
 
I found a strange thing, GBPJPY history is empty (EURUSD H4 and GBPUSD H4 history is in place), probably because of missing data in TestFile.csv and TestFile.csv2 files. At the same time GBPJPY H4 chart itself is displayed correctly. I have suspected that
1) time-series appeared to be cached (that is why the chart is displayed)
2) the data centre address (before the terminal was connected to Alpari demo account via data centre)

. So I removed the data centre address and switched to Alpari demo account, the switch was successful, data centre is disconnected. Switched back to the MIG demo account - connection to the server was successful, but the MarketWatch data did not change. Forced to update GBPJPY H4 (on the chart) , history bounced.
But last quote time is still 10-43 on all pairs. I have a build 199.



Now I will try to run Redraw2 indicator


I looked at MarketWatch - it has the same time 10:43 everywhere.
 
Hmm... Turns out it was connected via the data centre anyway. Now it's OK and MarketWatch is showing the correct data. Now trying to get a deeper history.
 
Updated, the quotes are very interesting in places

 
If this graph is from MIG, they have such tricks. Seen it a couple of times this year already. I have on my EURUSD history from MIG a dojic 08.09.2004 with High ~ 1.7493.
 
Yes, it's MIG :)
 
Just in case, I reloaded the terminal before starting the indicator (to exclude time-series caching). The errors appeared again after the index number 1000.



Now I will make the third variant to dot all the dots.
 
Here is the third version
//+------------------------------------------------------------------+
//|                                           RedrawIndicators-2.mq4 |
//|                                                           Satori |
//|                             http://www.metaquotes.ru/forum/7790/ |
//+------------------------------------------------------------------+
#property copyright "Satori"
#property link      "http://www.metaquotes.ru/forum/7790/"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Yellow
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
extern int       BarsCount=20;   //кол-во считаемых баров, если 0 - то все
extern string    Currency1="EURUSD";
extern string    Currency2="GBPUSD";

int handle,handle2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexLabel(0,Currency1);

   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexLabel(1,Currency2);

   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer3);

   handle= FileOpen("TestFile3.csv",FILE_CSV|FILE_WRITE,';');
   handle2= FileOpen("TestFile3-2.csv",FILE_CSV|FILE_WRITE,';');
  if(handle<1 || handle2<1 )
   {
    Print("Файл не обнаружен, последняя ошибка ", GetLastError());
    return(false);
   }
   else
   {
   FileWrite (handle,"index",Symbol(),"iBarShift1","index1","Time[index1-1]",Currency1,"Time[index1+1]","iBarShift2","index2","Time[index2-1]",Currency2,"Time[index2+1]");
   FileWrite (handle2,"index",Symbol(),"  ",Currency1,"  ",Currency2);
   }

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   FileClose(handle);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int i;
   double test1,test2;
   double Bar1,Bar2;
   int iBarShift1,iBarShift2;
   datetime tt1,tt2,TimeMain;
   BarsCount=MathMin(Bars,(MathMin(iBars(Currency1,Period()),iBars(Currency2,Period()))));
   for (i=0;i<BarsCount-counted_bars;i++)
      {
       TimeMain=Time[i];
       iBarShift1=iBarShift(Currency1,Period(),TimeMain);
       iBarShift2=iBarShift(Currency2,Period(),TimeMain);
       ExtMapBuffer1[i]=iTime(Currency1,Period(),iBarShift1);
       ExtMapBuffer2[i]=iTime(Currency2,Period(),iBarShift2);
       ExtMapBuffer3[i]=(ExtMapBuffer1[i]-ExtMapBuffer2[i]);
       tt1=Time[i]-ExtMapBuffer1[i];
       tt2=Time[i]-ExtMapBuffer2[i];
       
       if (ExtMapBuffer3[i]!=0 || tt1!=0 || tt2!=0) 
         {
         Bar1=iBarShift(Currency1,Period(),ExtMapBuffer1[i]);
         Bar2=iBarShift(Currency2,Period(),ExtMapBuffer2[i]);
         if (FileWrite (handle,
         i,TimeToStr(Time[i]),iBarShift1,Bar1,TimeToStr(iTime(Currency1,Period(),Bar1-1)),TimeToStr(ExtMapBuffer1[i]),TimeToStr(iTime(Currency1,Period(),Bar1+1)),iBarShift1,Bar2,TimeToStr(iTime(Currency2,Period(),Bar2-1)),TimeToStr(ExtMapBuffer2[i]),TimeToStr(iTime(Currency2,Period(),Bar2+1))
          )<=0) Print("нифига не пишет!!");
         }
        FileFlush(handle);
        if ((iTime(Symbol(),Period(),i)!=iTime(Currency1,Period(),i) ||
           Time[i]!=iTime(Currency1,Period(),i) ||
           iTime(Currency1,Period(),i)!=iTime(Currency2,Period(),i)
           ) && i>0)
        {
         if (FileWrite (handle2,i,
         TimeToStr(Time[i])," ",TimeToStr(iTime(Currency1,Period(),i))," ",TimeToStr(iTime(Currency2,Period(),i))
       )<=0) Print("нифига не пишет!!");

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



 
The third version did not give a definitive answer, we will have to check Time[] on the 4-hour timeframe for each instrument to see if there are any extra seconds. If no seconds are found, then there is a terminal error.