Что находится по определенному смещению в файле .hst

 

Здравствуйте, подскажите, пожалуйста, по какому смещению находится начало имени инструмента, периода, начального бара, конечного бара в файле .hst


Пытаюсь записать на C# экспортируемые котировки, но не получается ...

                c_symbol=Instrument.FullName;
                i_period=BarsPeriod.Value*ExtPeriodMultiplier;
                Log("i_period: "+i_period, NinjaTrader.Cbi.LogLevel.Information);
                //----
                // Set the stringformat parameter for decimal places to suit the instrument.
                // This ensures that trailing zeros are always displayed - maybe an easier way to do this?
                double temp1 = TickSize - (int)TickSize;// get fractional part of TickSize
                decimals = temp1.ToString(); // make it into a string
                int tickLength = decimals.Length; // get the number of characters in the string
                switch (tickLength) // set format depending on length of string
                {
                  case 1: decimals = "f0"; // eg YM 1t = 1 point
                          i_digits = 0;
                  break;
                  case 3: decimals = "f1"; // eg ER2 1t = 0.1 point
                          i_digits = 1;                       
                  break;
                  case 4: decimals = "f2"; // eg NQ 1t = 0.25 point
                          i_digits = 2;                       
                  break;
                  case 5: decimals = "f3"; // eg 1t = 0.001 point
                          i_digits = 3;                       
                  break;
                  case 6: decimals = "f4"; // eg 6E 1t = 0.0001 point
                          i_digits = 4;                                               
                  break;
                  case 7: decimals = "f5"; // eg 1t = 0.00001 point
                          i_digits = 5;                       
                  break;
                  default: decimals = ""; // default is no fixed decimal format
                          i_digits = 0;
                  break;
                  // more options can be added if neccessary......
                }
                //Log("i_digits: "+i_digits, NinjaTrader.Cbi.LogLevel.Information);
                using (FileStream stream = new FileStream("E:\\Terminal_Alpari\\history\\Alpari-Demo\\"+c_symbol+i_period+".hst", FileMode.Create)){
                  //Log("FileStream: "+stream, NinjaTrader.Cbi.LogLevel.Information);                   
                  using (BinaryWriter writer = new BinaryWriter(stream))
                    {
                      //---- Write history file header   
                      c_copyright="(C)opyright 2003, MetaQuotes Software Corp.               ";

                      writer.Write(version);
                      writer.Write(c_copyright);               
                      writer.Write("6E          ");               
                      writer.Write(i_period);                   
                      writer.Write(i_digits);
                      //writer.Write(0);
                      //writer.Write(0);
                      writer.Write("                         ");                        
                      //writer.Close();
                    }
                }

 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void SaveTitleHst(int iHandle,string iTools,int iFrame,int iDigits){
        if(iHandle < 0) return(-1);
//---- write history file header
   int    version=400;
   string c_copyright="(C)opyright 2003, MetaQuotes Software Corp.";
   int    HstUnused[13];
        FileWriteInteger(iHandle, version, LONG_VALUE);
        FileWriteString(iHandle, c_copyright, 64);
        FileWriteString(iHandle, iTools, 12);
        FileWriteInteger(iHandle, iFrame, LONG_VALUE);
        FileWriteInteger(iHandle, iDigits, LONG_VALUE);
        FileWriteInteger(iHandle, 0, LONG_VALUE);       //timesign
        FileWriteInteger(iHandle, 0, LONG_VALUE);       //last_sync
        FileWriteArray(iHandle, HstUnused, 0, 13);
        FileFlush(iHandle);
        return;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void SaveTicketHst(int iHandle,int iTimeValue,double iOpenValue,double iLowValue,double iHighValue,double iCloseValue,double iVolumeValue){
        if(iHandle < 0) return(-1);
        FileWriteInteger(iHandle, iTimeValue, LONG_VALUE);
        FileWriteDouble(iHandle, iOpenValue, DOUBLE_VALUE);
        FileWriteDouble(iHandle, iLowValue, DOUBLE_VALUE);
        FileWriteDouble(iHandle, iHighValue, DOUBLE_VALUE);
        FileWriteDouble(iHandle, iCloseValue, DOUBLE_VALUE);
        FileWriteDouble(iHandle, iVolumeValue, DOUBLE_VALUE);
        FileFlush(iHandle);
        return;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int LoadTitleHst(int iHandle,string& iTools,int& iFrame,int& iDigits){
        if(iHandle < 0) return(-1);
//---- write history file header
        int             version=400;
        string  c_copyright="(C)opyright 2003, MetaQuotes Software Corp.";
        int             i_unused[13];
        int             i_value;
        version         =FileReadInteger(iHandle, LONG_VALUE);
        c_copyright     =FileReadString(iHandle,  64);
        iTools          =FileReadString(iHandle, 12);
        iFrame          =FileReadInteger(iHandle, LONG_VALUE);
        iDigits         =FileReadInteger(iHandle, LONG_VALUE);
        i_value         =FileReadInteger(iHandle, LONG_VALUE);       //timesign
        i_value         =FileReadInteger(iHandle, LONG_VALUE);       //last_sync
        FileReadArray(iHandle, i_unused, 0, 13);
        return(1);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int LoadTicketHst(int iHandle,int& iTimeValue,double& iOpenValue,double& iLowValue,double& iHighValue,double& iCloseValue,double& iVolumeValue){
        if(iHandle < 0) return(-1);
//      if (FileIsEnding(iHandle)==true) return(-1);
        iTimeValue      =FileReadInteger(iHandle, LONG_VALUE);
        iOpenValue      =FileReadDouble(iHandle, DOUBLE_VALUE);
        iLowValue       =FileReadDouble(iHandle, DOUBLE_VALUE);
        iHighValue      =FileReadDouble(iHandle, DOUBLE_VALUE);
        iCloseValue     =FileReadDouble(iHandle, DOUBLE_VALUE);
        iVolumeValue=FileReadDouble(iHandle, DOUBLE_VALUE);
        if (FileIsEnding(iHandle)==true) return(-1);
        return(1);
}
 
chief1973:

Здравствуйте, подскажите, пожалуйста, по какому смещению находится начало имени инструмента, периода, начального бара, конечного бара в файле .hst

В справку МТ4 заглянуть не судьба?
 

forte928, спасибо, но мне не совсем это нужно

Мне нужно реализовать то, что ты написал на C#, но там нет стандартных встроенный функций типа FileWriteString, поэтому возникают ошибки - мне нужны значения смещений в байтах от начала файла, по которым находится название инструмента, ТФ, первый бар и пр., чтобы расчитать эти смещения у себя в коде С#

Причина обращения: