saving {time, O,H,L,C}

 

Hi Guys,

I want to save the data {time,Open,Low,Close}, each item individuialy in a binary file, I have this code:

#include <stdlib.mqh>
int handle_low, handle_high, handle_close, handle_open, handle_time;
bool once;
int init(){
    handle_time=FileOpen("time_h1.bin", FILE_BIN|FILE_WRITE|FILE_READ);
    if(handle_time<1)
      Comment("File could not be opened");
      
   handle_open=FileOpen("open_h1.bin", FILE_BIN|FILE_WRITE|FILE_READ);
    if(handle_open<1)
      Comment("File could not be opened");
      
    handle_high=FileOpen("high_h1.bin", FILE_BIN|FILE_WRITE|FILE_READ);
    if(handle_high<1)
      Comment("File could not be opened");
      
    handle_low=FileOpen("low_h1.bin", FILE_BIN|FILE_WRITE|FILE_READ);
    if(handle_low<1)
      Comment("File could not be opened");
      
    handle_close=FileOpen("close_h1.bin", FILE_BIN|FILE_WRITE|FILE_READ);
    if(handle_close<1)
      Comment("File could not be opened");
   once = true;
   return(0);
  }

int deinit(){
   
   return(0);
  }

int start(){
      int i;
      for(i=Bars-1;i>0 && once;i--){
         FileWriteInteger(handle_time,Time[i],SHORT_VALUE);
         FileWriteDouble(handle_open,Open[i],DOUBLE_VALUE);
         FileWriteDouble(handle_high,High[i],DOUBLE_VALUE);
         FileWriteDouble(handle_low,Low[i],DOUBLE_VALUE);
         FileWriteDouble(handle_close,Close[i],DOUBLE_VALUE);
     }
     Print(Bars," done");
     once =false;
     return (0);
     }

question 1: I dont think that FileWriteInteger is writing it corrent, do you see any problem?

question 2: do you have a function that I could use to select only data from the London and NY sections? like:

bool LondonNYSection(int time){
      rslt = false;
      if(MathMod(time, ?????)==0)
         rslt = true;
      return (rslt);
      }

bests regards!