diff options
| author | Georg Brandl <georg@python.org> | 2021-01-18 21:24:00 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2021-01-18 22:08:36 +0100 |
| commit | 2a3d3a7d5b9c60dedf6638d876161d9563faebcf (patch) | |
| tree | 809c0b4a686db98f5954afa1944404cd9652c6b2 /tests/lexers/mql | |
| parent | f0445be718da83541ea3401aad882f3937147263 (diff) | |
| download | pygments-git-examplefiles.tar.gz | |
Move test_examplefiles to new tests/lexers scheme.examplefiles
Diffstat (limited to 'tests/lexers/mql')
| -rw-r--r-- | tests/lexers/mql/example.txt | 959 | ||||
| -rw-r--r-- | tests/lexers/mql/example2.txt | 1762 |
2 files changed, 2721 insertions, 0 deletions
diff --git a/tests/lexers/mql/example.txt b/tests/lexers/mql/example.txt new file mode 100644 index 00000000..651db08a --- /dev/null +++ b/tests/lexers/mql/example.txt @@ -0,0 +1,959 @@ +---input--- +//+------------------------------------------------------------------+ +//| Array.mqh | +//| Copyright 2009-2013, MetaQuotes Software Corp. | +//| http://www.mql4.com | +//+------------------------------------------------------------------+ +#include <Object.mqh> +//+------------------------------------------------------------------+ +//| Class CArray | +//| Purpose: Base class of dynamic arrays. | +//| Derives from class CObject. | +//+------------------------------------------------------------------+ +class CArray : public CObject + { +protected: + int m_step_resize; // increment size of the array + int m_data_total; // number of elements + int m_data_max; // maximmum size of the array without memory reallocation + int m_sort_mode; // mode of array sorting + +public: + CArray(void); + ~CArray(void); + //--- methods of access to protected data + int Step(void) const { return(m_step_resize); } + bool Step(const int step); + int Total(void) const { return(m_data_total); } + int Available(void) const { return(m_data_max-m_data_total); } + int Max(void) const { return(m_data_max); } + bool IsSorted(const int mode=0) const { return(m_sort_mode==mode); } + int SortMode(void) const { return(m_sort_mode); } + //--- cleaning method + void Clear(void) { m_data_total=0; } + //--- methods for working with files + virtual bool Save(const int file_handle); + virtual bool Load(const int file_handle); + //--- sorting method + void Sort(const int mode=0); + +protected: + virtual void QuickSort(int beg,int end,const int mode=0) { } + }; +//+------------------------------------------------------------------+ +//| Constructor | +//+------------------------------------------------------------------+ +CArray::CArray(void) : m_step_resize(16), + m_data_total(0), + m_data_max(0), + m_sort_mode(-1) + { + } +//+------------------------------------------------------------------+ +//| Destructor | +//+------------------------------------------------------------------+ +CArray::~CArray(void) + { + } +//+------------------------------------------------------------------+ +//| Method Set for variable m_step_resize | +//+------------------------------------------------------------------+ +bool CArray::Step(const int step) + { +//--- check + if(step>0) + { + m_step_resize=step; + return(true); + } +//--- failure + return(false); + } +//+------------------------------------------------------------------+ +//| Sorting an array in ascending order | +//+------------------------------------------------------------------+ +void CArray::Sort(const int mode) + { +//--- check + if(IsSorted(mode)) + return; + m_sort_mode=mode; + if(m_data_total<=1) + return; +//--- sort + QuickSort(0,m_data_total-1,mode); + } +//+------------------------------------------------------------------+ +//| Writing header of array to file | +//+------------------------------------------------------------------+ +bool CArray::Save(const int file_handle) + { +//--- check handle + if(file_handle!=INVALID_HANDLE) + { + //--- write start marker - 0xFFFFFFFFFFFFFFFF + if(FileWriteLong(file_handle,-1)==sizeof(long)) + { + //--- write array type + if(FileWriteInteger(file_handle,Type(),INT_VALUE)==INT_VALUE) + return(true); + } + } +//--- failure + return(false); + } +//+------------------------------------------------------------------+ +//| Reading header of array from file | +//+------------------------------------------------------------------+ +bool CArray::Load(const int file_handle) + { +//--- check handle + if(file_handle!=INVALID_HANDLE) + { + //--- read and check start marker - 0xFFFFFFFFFFFFFFFF + if(FileReadLong(file_handle)==-1) + { + //--- read and check array type + if(FileReadInteger(file_handle,INT_VALUE)==Type()) + return(true); + } + } +//--- failure + return(false); + } +//+------------------------------------------------------------------+ + +---tokens--- +'//+------------------------------------------------------------------+\n' Comment.Single + +'//| Array.mqh |\n' Comment.Single + +'//| Copyright 2009-2013, MetaQuotes Software Corp. |\n' Comment.Single + +'//| http://www.mql4.com |\n' Comment.Single + +'//+------------------------------------------------------------------+\n' Comment.Single + +'#' Comment.Preproc +'include' Comment.Preproc +' ' Text +'<Object.mqh>' Comment.PreprocFile +'\n' Comment.Preproc + +'//+------------------------------------------------------------------+\n' Comment.Single + +'//| Class CArray |\n' Comment.Single + +'//| Purpose: Base class of dynamic arrays. |\n' Comment.Single + +'//| Derives from class CObject. |\n' Comment.Single + +'//+------------------------------------------------------------------+\n' Comment.Single + +'class' Keyword +' ' Text +'CArray' Name.Class +' ' Text +':' Operator +' ' Text +'public' Keyword +' ' Text +'CObject' Name +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +'protected' Keyword +':' Operator +'\n' Text + +' ' Text +'int' Keyword.Type +' ' Text +'m_step_resize' Name +';' Punctuation +' ' Text +'// increment size of the array\n' Comment.Single + +' ' Text +'int' Keyword.Type +' ' Text +'m_data_total' Name +';' Punctuation +' ' Text +'// number of elements\n' Comment.Single + +' ' Text +'int' Keyword.Type +' ' Text +'m_data_max' Name +';' Punctuation +' ' Text +'// maximmum size of the array without memory reallocation\n' Comment.Single + +' ' Text +'int' Keyword.Type +' ' Text +'m_sort_mode' Name +';' Punctuation +' ' Text +'// mode of array sorting\n' Comment.Single + +'\n' Text + +'public' Keyword +':' Operator +'\n' Text + +' ' Text +'CArray' Name +'(' Punctuation +'void' Keyword.Type +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'~' Operator +'CArray' Name +'(' Punctuation +'void' Keyword.Type +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'//--- methods of access to protected data\n' Comment.Single + +' ' Text +'int' Keyword.Type +' ' Text +'Step' Name.Function +'(' Punctuation +'void' Keyword.Type +')' Punctuation +' ' Text +'const' Keyword +' ' Text +'{' Punctuation +' ' Text +'return' Keyword +'(' Punctuation +'m_step_resize' Name +')' Punctuation +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'bool' Keyword.Type +' ' Text +'Step' Name.Function +'(' Punctuation +'const' Keyword +' ' Text +'int' Keyword.Type +' ' Text +'step' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'int' Keyword.Type +' ' Text +'Total' Name.Function +'(' Punctuation +'void' Keyword.Type +')' Punctuation +' ' Text +'const' Keyword +' ' Text +'{' Punctuation +' ' Text +'return' Keyword +'(' Punctuation +'m_data_total' Name +')' Punctuation +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'int' Keyword.Type +' ' Text +'Available' Name.Function +'(' Punctuation +'void' Keyword.Type +')' Punctuation +' ' Text +'const' Keyword +' ' Text +'{' Punctuation +' ' Text +'return' Keyword +'(' Punctuation +'m_data_max' Name +'-' Operator +'m_data_total' Name +')' Punctuation +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'int' Keyword.Type +' ' Text +'Max' Name.Function +'(' Punctuation +'void' Keyword.Type +')' Punctuation +' ' Text +'const' Keyword +' ' Text +'{' Punctuation +' ' Text +'return' Keyword +'(' Punctuation +'m_data_max' Name +')' Punctuation +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'bool' Keyword.Type +' ' Text +'IsSorted' Name.Function +'(' Punctuation +'const' Keyword +' ' Text +'int' Keyword.Type +' ' Text +'mode' Name +'=' Operator +'0' Literal.Number.Integer +')' Punctuation +' ' Text +'const' Keyword +' ' Text +'{' Punctuation +' ' Text +'return' Keyword +'(' Punctuation +'m_sort_mode' Name +'=' Operator +'=' Operator +'mode' Name +')' Punctuation +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'int' Keyword.Type +' ' Text +'SortMode' Name.Function +'(' Punctuation +'void' Keyword.Type +')' Punctuation +' ' Text +'const' Keyword +' ' Text +'{' Punctuation +' ' Text +'return' Keyword +'(' Punctuation +'m_sort_mode' Name +')' Punctuation +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'//--- cleaning method\n' Comment.Single + +' ' Text +'void' Keyword.Type +' ' Text +'Clear' Name.Function +'(' Punctuation +'void' Keyword.Type +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'m_data_total' Name +'=' Operator +'0' Literal.Number.Integer +';' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'//--- methods for working with files\n' Comment.Single + +' ' Text +'virtual' Keyword +' ' Text +'bool' Keyword.Type +' ' Text +'Save' Name +'(' Punctuation +'const' Keyword +' ' Text +'int' Keyword.Type +' ' Text +'file_handle' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'virtual' Keyword +' ' Text +'bool' Keyword.Type +' ' Text +'Load' Name +'(' Punctuation +'const' Keyword +' ' Text +'int' Keyword.Type +' ' Text +'file_handle' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'//--- sorting method\n' Comment.Single + +' ' Text +'void' Keyword.Type +' ' Text +'Sort' Name.Function +'(' Punctuation +'const' Keyword +' ' Text +'int' Keyword.Type +' ' Text +'mode' Name +'=' Operator +'0' Literal.Number.Integer +')' Punctuation +';' Punctuation +'\n' Text + +'\n' Text + +'protected' Keyword +':' Operator +'\n' Text + +' ' Text +'virtual' Keyword +' ' Text +'void' Keyword.Type +' ' Text +'QuickSort' Name +'(' Punctuation +'int' Keyword.Type +' ' Text +'beg' Name +',' Punctuation +'int' Keyword.Type +' ' Text +'end' Name +',' Punctuation +'const' Keyword +' ' Text +'int' Keyword.Type +' ' Text +'mode' Name +'=' Operator +'0' Literal.Number.Integer +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +';' Punctuation +'\n' Text + +'//+------------------------------------------------------------------+\n' Comment.Single + +'//| Constructor |\n' Comment.Single + +'//+------------------------------------------------------------------+\n' Comment.Single + +'CArray' Name +':' Operator +':' Operator +'CArray' Name +'(' Punctuation +'void' Keyword.Type +')' Punctuation +' ' Text +':' Operator +' ' Text +'m_step_resize' Name +'(' Punctuation +'16' Literal.Number.Integer +')' Punctuation +',' Punctuation +'\n' Text + +' ' Text +'m_data_total' Name +'(' Punctuation +'0' Literal.Number.Integer +')' Punctuation +',' Punctuation +'\n' Text + +' ' Text +'m_data_max' Name +'(' Punctuation +'0' Literal.Number.Integer +')' Punctuation +',' Punctuation +'\n' Text + +' ' Text +'m_sort_mode' Name +'(' Punctuation +'-1' Literal.Number.Integer +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +'//+------------------------------------------------------------------+\n' Comment.Single + +'//| Destructor |\n' Comment.Single + +'//+------------------------------------------------------------------+\n' Comment.Single + +'CArray' Name +':' Operator +':' Operator +'~' Operator +'CArray' Name +'(' Punctuation +'void' Keyword.Type +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +'//+------------------------------------------------------------------+\n' Comment.Single + +'//| Method Set for variable m_step_resize |\n' Comment.Single + +'//+------------------------------------------------------------------+\n' Comment.Single + +'bool' Keyword.Type +' ' Text +'CArray' Name +':' Operator +':' Operator +'Step' Name +'(' Punctuation +'const' Keyword +' ' Text +'int' Keyword.Type +' ' Text +'step' Name +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +'//--- check\n' Comment.Single + +' ' Text +'if' Keyword +'(' Punctuation +'step' Name +'>' Operator +'0' Literal.Number.Integer +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'m_step_resize' Name +'=' Operator +'step' Name +';' Punctuation +'\n' Text + +' ' Text +'return' Keyword +'(' Punctuation +'true' Name.Builtin +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +'//--- failure\n' Comment.Single + +' ' Text +'return' Keyword +'(' Punctuation +'false' Name.Builtin +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +'//+------------------------------------------------------------------+\n' Comment.Single + +'//| Sorting an array in ascending order |\n' Comment.Single + +'//+------------------------------------------------------------------+\n' Comment.Single + +'void' Keyword.Type +' ' Text +'CArray' Name +':' Operator +':' Operator +'Sort' Name +'(' Punctuation +'const' Keyword +' ' Text +'int' Keyword.Type +' ' Text +'mode' Name +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +'//--- check\n' Comment.Single + +' ' Text +'if' Keyword +'(' Punctuation +'IsSorted' Name +'(' Punctuation +'mode' Name +')' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'return' Keyword +';' Punctuation +'\n' Text + +' ' Text +'m_sort_mode' Name +'=' Operator +'mode' Name +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'m_data_total' Name +'<' Operator +'=' Operator +'1' Literal.Number.Integer +')' Punctuation +'\n' Text + +' ' Text +'return' Keyword +';' Punctuation +'\n' Text + +'//--- sort\n' Comment.Single + +' ' Text +'QuickSort' Name +'(' Punctuation +'0' Literal.Number.Integer +',' Punctuation +'m_data_total' Name +'-1' Literal.Number.Integer +',' Punctuation +'mode' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +'//+------------------------------------------------------------------+\n' Comment.Single + +'//| Writing header of array to file |\n' Comment.Single + +'//+------------------------------------------------------------------+\n' Comment.Single + +'bool' Keyword.Type +' ' Text +'CArray' Name +':' Operator +':' Operator +'Save' Name +'(' Punctuation +'const' Keyword +' ' Text +'int' Keyword.Type +' ' Text +'file_handle' Name +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +'//--- check handle\n' Comment.Single + +' ' Text +'if' Keyword +'(' Punctuation +'file_handle' Name +'!' Operator +'=' Operator +'INVALID_HANDLE' Name.Constant +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'//--- write start marker - 0xFFFFFFFFFFFFFFFF\n' Comment.Single + +' ' Text +'if' Keyword +'(' Punctuation +'FileWriteLong' Name.Function +'(' Punctuation +'file_handle' Name +',' Punctuation +'-1' Literal.Number.Integer +')' Punctuation +'=' Operator +'=' Operator +'sizeof' Keyword +'(' Punctuation +'long' Keyword.Type +')' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'//--- write array type\n' Comment.Single + +' ' Text +'if' Keyword +'(' Punctuation +'FileWriteInteger' Name.Function +'(' Punctuation +'file_handle' Name +',' Punctuation +'Type' Name +'(' Punctuation +')' Punctuation +',' Punctuation +'INT_VALUE' Name +')' Punctuation +'=' Operator +'=' Operator +'INT_VALUE' Name +')' Punctuation +'\n' Text + +' ' Text +'return' Keyword +'(' Punctuation +'true' Name.Builtin +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +'//--- failure\n' Comment.Single + +' ' Text +'return' Keyword +'(' Punctuation +'false' Name.Builtin +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +'//+------------------------------------------------------------------+\n' Comment.Single + +'//| Reading header of array from file |\n' Comment.Single + +'//+------------------------------------------------------------------+\n' Comment.Single + +'bool' Keyword.Type +' ' Text +'CArray' Name +':' Operator +':' Operator +'Load' Name +'(' Punctuation +'const' Keyword +' ' Text +'int' Keyword.Type +' ' Text +'file_handle' Name +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +'//--- check handle\n' Comment.Single + +' ' Text +'if' Keyword +'(' Punctuation +'file_handle' Name +'!' Operator +'=' Operator +'INVALID_HANDLE' Name.Constant +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'//--- read and check start marker - 0xFFFFFFFFFFFFFFFF\n' Comment.Single + +' ' Text +'if' Keyword +'(' Punctuation +'FileReadLong' Name.Function +'(' Punctuation +'file_handle' Name +')' Punctuation +'=' Operator +'=' Operator +'-1' Literal.Number.Integer +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'//--- read and check array type\n' Comment.Single + +' ' Text +'if' Keyword +'(' Punctuation +'FileReadInteger' Name.Function +'(' Punctuation +'file_handle' Name +',' Punctuation +'INT_VALUE' Name +')' Punctuation +'=' Operator +'=' Operator +'Type' Name +'(' Punctuation +')' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'return' Keyword +'(' Punctuation +'true' Name.Builtin +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +'//--- failure\n' Comment.Single + +' ' Text +'return' Keyword +'(' Punctuation +'false' Name.Builtin +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +'//+------------------------------------------------------------------+\n' Comment.Single diff --git a/tests/lexers/mql/example2.txt b/tests/lexers/mql/example2.txt new file mode 100644 index 00000000..c1ded432 --- /dev/null +++ b/tests/lexers/mql/example2.txt @@ -0,0 +1,1762 @@ +---input--- +//+------------------------------------------------------------------+ +//| PeriodConverter.mq4 | +//| Copyright 2006-2014, MetaQuotes Software Corp. | +//| http://www.metaquotes.net | +//+------------------------------------------------------------------+ +#property copyright "2006-2014, MetaQuotes Software Corp." +#property link "http://www.mql4.com" +#property description "Period Converter to updated format of history base" +#property strict +#property show_inputs +#include <WinUser32.mqh> + +input int InpPeriodMultiplier=3; // Period multiplier factor +int ExtHandle=-1; +//+------------------------------------------------------------------+ +//| script program start function | +//+------------------------------------------------------------------+ +void OnStart() + { + datetime time0; + ulong last_fpos=0; + long last_volume=0; + int i,start_pos,periodseconds; + int hwnd=0,cnt=0; +//---- History header + int file_version=401; + string c_copyright; + string c_symbol=Symbol(); + int i_period=Period()*InpPeriodMultiplier; + int i_digits=Digits; + int i_unused[13]; + MqlRates rate; +//--- + ExtHandle=FileOpenHistory(c_symbol+(string)i_period+".hst",FILE_BIN|FILE_WRITE|FILE_SHARE_WRITE|FILE_SHARE_READ|FILE_ANSI); + if(ExtHandle<0) + return; + c_copyright="(C)opyright 2003, MetaQuotes Software Corp."; + ArrayInitialize(i_unused,0); +//--- write history file header + FileWriteInteger(ExtHandle,file_version,LONG_VALUE); + FileWriteString(ExtHandle,c_copyright,64); + FileWriteString(ExtHandle,c_symbol,12); + FileWriteInteger(ExtHandle,i_period,LONG_VALUE); + FileWriteInteger(ExtHandle,i_digits,LONG_VALUE); + FileWriteInteger(ExtHandle,0,LONG_VALUE); + FileWriteInteger(ExtHandle,0,LONG_VALUE); + FileWriteArray(ExtHandle,i_unused,0,13); +//--- write history file + periodseconds=i_period*60; + start_pos=Bars-1; + rate.open=Open[start_pos]; + rate.low=Low[start_pos]; + rate.high=High[start_pos]; + rate.tick_volume=(long)Volume[start_pos]; + rate.spread=0; + rate.real_volume=0; + //--- normalize open time + rate.time=Time[start_pos]/periodseconds; + rate.time*=periodseconds; + for(i=start_pos-1; i>=0; i--) + { + if(IsStopped()) + break; + time0=Time[i]; + //--- history may be updated + if(i==0) + { + //--- modify index if history was updated + if(RefreshRates()) + i=iBarShift(NULL,0,time0); + } + //--- + if(time0>=rate.time+periodseconds || i==0) + { + if(i==0 && time0<rate.time+periodseconds) + { + rate.tick_volume+=(long)Volume[0]; + if(rate.low>Low[0]) + rate.low=Low[0]; + if(rate.high<High[0]) + rate.high=High[0]; + rate.close=Close[0]; + } + last_fpos=FileTell(ExtHandle); + last_volume=(long)Volume[i]; + FileWriteStruct(ExtHandle,rate); + cnt++; + if(time0>=rate.time+periodseconds) + { + rate.time=time0/periodseconds; + rate.time*=periodseconds; + rate.open=Open[i]; + rate.low=Low[i]; + rate.high=High[i]; + rate.close=Close[i]; + rate.tick_volume=last_volume; + } + } + else + { + rate.tick_volume+=(long)Volume[i]; + if(rate.low>Low[i]) + rate.low=Low[i]; + if(rate.high<High[i]) + rate.high=High[i]; + rate.close=Close[i]; + } + } + FileFlush(ExtHandle); + Print(cnt," record(s) written"); +//--- collect incoming ticks + datetime last_time=LocalTime()-5; + while(!IsStopped()) + { + datetime cur_time=LocalTime(); + //--- check for new rates + if(RefreshRates()) + { + time0=Time[0]; + FileSeek(ExtHandle,last_fpos,SEEK_SET); + //--- is there current bar? + if(time0<rate.time+periodseconds) + { + rate.tick_volume+=(long)Volume[0]-last_volume; + last_volume=(long)Volume[0]; + if(rate.low>Low[0]) + rate.low=Low[0]; + if(rate.high<High[0]) + rate.high=High[0]; + rate.close=Close[0]; + } + else + { + //--- no, there is new bar + rate.tick_volume+=(long)Volume[1]-last_volume; + if(rate.low>Low[1]) + rate.low=Low[1]; + if(rate.high<High[1]) + rate.high=High[1]; + //--- write previous bar remains + FileWriteStruct(ExtHandle,rate); + last_fpos=FileTell(ExtHandle); + //---- + rate.time=time0/periodseconds; + rate.time*=periodseconds; + rate.open=Open[0]; + rate.low=Low[0]; + rate.high=High[0]; + rate.close=Close[0]; + rate.tick_volume=(long)Volume[0]; + last_volume=rate.tick_volume; + } + //---- + FileWriteStruct(ExtHandle,rate); + FileFlush(ExtHandle); + //--- + if(hwnd==0) + { + hwnd=WindowHandle(Symbol(),i_period); + if(hwnd!=0) + Print("Chart window detected"); + } + //--- refresh window not frequently than 1 time in 2 seconds + if(hwnd!=0 && cur_time-last_time>=2) + { + PostMessageA(hwnd,WM_COMMAND,33324,0); + last_time=cur_time; + } + } + Sleep(50); + } +//--- + } +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +void OnDeinit(const int reason) + { +//--- + if(ExtHandle>=0) + { + FileClose(ExtHandle); + ExtHandle=-1; + } +//--- + } +//+------------------------------------------------------------------+ + +---tokens--- +'//+------------------------------------------------------------------+\n' Comment.Single + +'//| PeriodConverter.mq4 |\n' Comment.Single + +'//| Copyright 2006-2014, MetaQuotes Software Corp. |\n' Comment.Single + +'//| http://www.metaquotes.net |\n' Comment.Single + +'//+------------------------------------------------------------------+\n' Comment.Single + +'#' Comment.Preproc +'property copyright "2006-2014, MetaQuotes Software Corp."' Comment.Preproc +'\n' Comment.Preproc + +'#' Comment.Preproc +'property link "http:' Comment.Preproc +'//www.mql4.com"\n' Comment.Single + +'#' Comment.Preproc +'property description "Period Converter to updated format of history base"' Comment.Preproc +'\n' Comment.Preproc + +'#' Comment.Preproc +'property strict' Comment.Preproc +'\n' Comment.Preproc + +'#' Comment.Preproc +'property show_inputs' Comment.Preproc +'\n' Comment.Preproc + +'#' Comment.Preproc +'include' Comment.Preproc +' ' Text +'<WinUser32.mqh>' Comment.PreprocFile +'\n' Comment.Preproc + +'\n' Text + +'input' Keyword +' ' Text +'int' Keyword.Type +' ' Text +'InpPeriodMultiplier' Name +'=' Operator +'3' Literal.Number.Integer +';' Punctuation +' ' Text +'// Period multiplier factor\n' Comment.Single + +'int' Keyword.Type +' ' Text +'ExtHandle' Name +'=' Operator +'-1' Literal.Number.Integer +';' Punctuation +'\n' Text + +'//+------------------------------------------------------------------+\n' Comment.Single + +'//| script program start function |\n' Comment.Single + +'//+------------------------------------------------------------------+\n' Comment.Single + +'void' Keyword.Type +' ' Text +'OnStart' Name.Function +'(' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'datetime' Keyword.Type +' ' Text +'time0' Name +';' Punctuation +'\n' Text + +' ' Text +'ulong' Keyword.Type +' ' Text +'last_fpos' Name +'=' Operator +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'long' Keyword.Type +' ' Text +'last_volume' Name +'=' Operator +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'int' Keyword.Type +' ' Text +'i' Name +',' Punctuation +'start_pos' Name +',' Punctuation +'periodseconds' Name +';' Punctuation +'\n' Text + +' ' Text +'int' Keyword.Type +' ' Text +'hwnd' Name +'=' Operator +'0' Literal.Number.Integer +',' Punctuation +'cnt' Name +'=' Operator +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +'//---- History header\n' Comment.Single + +' ' Text +'int' Keyword.Type +' ' Text +'file_version' Name +'=' Operator +'401' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'string' Keyword.Type +' ' Text +'c_copyright' Name +';' Punctuation +'\n' Text + +' ' Text +'string' Keyword.Type +' ' Text +'c_symbol' Name +'=' Operator +'Symbol' Name.Function +'(' Punctuation +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'int' Keyword.Type +' ' Text +'i_period' Name +'=' Operator +'Period' Name.Function +'(' Punctuation +')' Punctuation +'*' Operator +'InpPeriodMultiplier' Name +';' Punctuation +'\n' Text + +' ' Text +'int' Keyword.Type +' ' Text +'i_digits' Name +'=' Operator +'Digits' Keyword +';' Punctuation +'\n' Text + +' ' Text +'int' Keyword.Type +' ' Text +'i_unused' Name +'[' Punctuation +'13' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'MqlRates' Name +' ' Text +'rate' Name +';' Punctuation +'\n' Text + +'//--- \n' Comment.Single + +' ' Text +'ExtHandle' Name +'=' Operator +'FileOpenHistory' Name.Function +'(' Punctuation +'c_symbol' Name +'+' Operator +'(' Punctuation +'string' Keyword.Type +')' Punctuation +'i_period' Name +'+' Operator +'"' Literal.String +'.hst' Literal.String +'"' Literal.String +',' Punctuation +'FILE_BIN' Name.Constant +'|' Operator +'FILE_WRITE' Name.Constant +'|' Operator +'FILE_SHARE_WRITE' Name.Constant +'|' Operator +'FILE_SHARE_READ' Name.Constant +'|' Operator +'FILE_ANSI' Name.Constant +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'ExtHandle' Name +'<' Operator +'0' Literal.Number.Integer +')' Punctuation +'\n' Text + +' ' Text +'return' Keyword +';' Punctuation +'\n' Text + +' ' Text +'c_copyright' Name +'=' Operator +'"' Literal.String +'(C)opyright 2003, MetaQuotes Software Corp.' Literal.String +'"' Literal.String +';' Punctuation +'\n' Text + +' ' Text +'ArrayInitialize' Name.Function +'(' Punctuation +'i_unused' Name +',' Punctuation +'0' Literal.Number.Integer +')' Punctuation +';' Punctuation +'\n' Text + +'//--- write history file header\n' Comment.Single + +' ' Text +'FileWriteInteger' Name.Function +'(' Punctuation +'ExtHandle' Name +',' Punctuation +'file_version' Name +',' Punctuation +'LONG_VALUE' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'FileWriteString' Name.Function +'(' Punctuation +'ExtHandle' Name +',' Punctuation +'c_copyright' Name +',' Punctuation +'64' Literal.Number.Integer +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'FileWriteString' Name.Function +'(' Punctuation +'ExtHandle' Name +',' Punctuation +'c_symbol' Name +',' Punctuation +'12' Literal.Number.Integer +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'FileWriteInteger' Name.Function +'(' Punctuation +'ExtHandle' Name +',' Punctuation +'i_period' Name +',' Punctuation +'LONG_VALUE' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'FileWriteInteger' Name.Function +'(' Punctuation +'ExtHandle' Name +',' Punctuation +'i_digits' Name +',' Punctuation +'LONG_VALUE' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'FileWriteInteger' Name.Function +'(' Punctuation +'ExtHandle' Name +',' Punctuation +'0' Literal.Number.Integer +',' Punctuation +'LONG_VALUE' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'FileWriteInteger' Name.Function +'(' Punctuation +'ExtHandle' Name +',' Punctuation +'0' Literal.Number.Integer +',' Punctuation +'LONG_VALUE' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'FileWriteArray' Name.Function +'(' Punctuation +'ExtHandle' Name +',' Punctuation +'i_unused' Name +',' Punctuation +'0' Literal.Number.Integer +',' Punctuation +'13' Literal.Number.Integer +')' Punctuation +';' Punctuation +'\n' Text + +'//--- write history file\n' Comment.Single + +' ' Text +'periodseconds' Name +'=' Operator +'i_period' Name +'*' Operator +'60' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'start_pos' Name +'=' Operator +'Bars' Keyword +'-1' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'open' Name +'=' Operator +'Open' Keyword +'[' Punctuation +'start_pos' Name +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'low' Name +'=' Operator +'Low' Keyword +'[' Punctuation +'start_pos' Name +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'high' Name +'=' Operator +'High' Keyword +'[' Punctuation +'start_pos' Name +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'tick_volume' Name +'=' Operator +'(' Punctuation +'long' Keyword.Type +')' Punctuation +'Volume' Keyword +'[' Punctuation +'start_pos' Name +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'spread' Name +'=' Operator +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'real_volume' Name +'=' Operator +'0' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'//--- normalize open time\n' Comment.Single + +' ' Text +'rate' Name +'.' Punctuation +'time' Name +'=' Operator +'Time' Keyword +'[' Punctuation +'start_pos' Name +']' Punctuation +'/' Operator +'periodseconds' Name +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'time' Name +'*' Operator +'=' Operator +'periodseconds' Name +';' Punctuation +'\n' Text + +' ' Text +'for' Keyword +'(' Punctuation +'i' Name +'=' Operator +'start_pos' Name +'-1' Literal.Number.Integer +';' Punctuation +' ' Text +'i' Name +'>' Operator +'=' Operator +'0' Literal.Number.Integer +';' Punctuation +' ' Text +'i' Name +'-' Operator +'-' Operator +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'IsStopped' Name.Function +'(' Punctuation +')' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'break' Keyword +';' Punctuation +'\n' Text + +' ' Text +'time0' Name +'=' Operator +'Time' Keyword +'[' Punctuation +'i' Name +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'//--- history may be updated\n' Comment.Single + +' ' Text +'if' Keyword +'(' Punctuation +'i' Name +'=' Operator +'=' Operator +'0' Literal.Number.Integer +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'//--- modify index if history was updated\n' Comment.Single + +' ' Text +'if' Keyword +'(' Punctuation +'RefreshRates' Name.Function +'(' Punctuation +')' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'i' Name +'=' Operator +'iBarShift' Name.Function +'(' Punctuation +'NULL' Name.Constant +',' Punctuation +'0' Literal.Number.Integer +',' Punctuation +'time0' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'//---\n' Comment.Single + +' ' Text +'if' Keyword +'(' Punctuation +'time0' Name +'>' Operator +'=' Operator +'rate' Name +'.' Punctuation +'time' Name +'+' Operator +'periodseconds' Name +' ' Text +'|' Operator +'|' Operator +' ' Text +'i' Name +'=' Operator +'=' Operator +'0' Literal.Number.Integer +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'i' Name +'=' Operator +'=' Operator +'0' Literal.Number.Integer +' ' Text +'&' Operator +'&' Operator +' ' Text +'time0' Name +'<' Operator +'rate' Name +'.' Punctuation +'time' Name +'+' Operator +'periodseconds' Name +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'tick_volume' Name +'+' Operator +'=' Operator +'(' Punctuation +'long' Keyword.Type +')' Punctuation +'Volume' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'rate' Name +'.' Punctuation +'low' Name +'>' Operator +'Low' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'low' Name +'=' Operator +'Low' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'rate' Name +'.' Punctuation +'high' Name +'<' Operator +'High' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'high' Name +'=' Operator +'High' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'close' Name +'=' Operator +'Close' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'last_fpos' Name +'=' Operator +'FileTell' Name.Function +'(' Punctuation +'ExtHandle' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'last_volume' Name +'=' Operator +'(' Punctuation +'long' Keyword.Type +')' Punctuation +'Volume' Keyword +'[' Punctuation +'i' Name +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'FileWriteStruct' Name.Function +'(' Punctuation +'ExtHandle' Name +',' Punctuation +'rate' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'cnt' Name +'+' Operator +'+' Operator +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'time0' Name +'>' Operator +'=' Operator +'rate' Name +'.' Punctuation +'time' Name +'+' Operator +'periodseconds' Name +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'time' Name +'=' Operator +'time0' Name +'/' Operator +'periodseconds' Name +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'time' Name +'*' Operator +'=' Operator +'periodseconds' Name +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'open' Name +'=' Operator +'Open' Keyword +'[' Punctuation +'i' Name +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'low' Name +'=' Operator +'Low' Keyword +'[' Punctuation +'i' Name +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'high' Name +'=' Operator +'High' Keyword +'[' Punctuation +'i' Name +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'close' Name +'=' Operator +'Close' Keyword +'[' Punctuation +'i' Name +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'tick_volume' Name +'=' Operator +'last_volume' Name +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'else' Keyword +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'tick_volume' Name +'+' Operator +'=' Operator +'(' Punctuation +'long' Keyword.Type +')' Punctuation +'Volume' Keyword +'[' Punctuation +'i' Name +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'rate' Name +'.' Punctuation +'low' Name +'>' Operator +'Low' Keyword +'[' Punctuation +'i' Name +']' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'low' Name +'=' Operator +'Low' Keyword +'[' Punctuation +'i' Name +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'rate' Name +'.' Punctuation +'high' Name +'<' Operator +'High' Keyword +'[' Punctuation +'i' Name +']' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'high' Name +'=' Operator +'High' Keyword +'[' Punctuation +'i' Name +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'close' Name +'=' Operator +'Close' Keyword +'[' Punctuation +'i' Name +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +' \n ' Text +'FileFlush' Name.Function +'(' Punctuation +'ExtHandle' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'Print' Name.Function +'(' Punctuation +'cnt' Name +',' Punctuation +'"' Literal.String +' record(s) written' Literal.String +'"' Literal.String +')' Punctuation +';' Punctuation +'\n' Text + +'//--- collect incoming ticks\n' Comment.Single + +' ' Text +'datetime' Keyword.Type +' ' Text +'last_time' Name +'=' Operator +'LocalTime' Name +'(' Punctuation +')' Punctuation +'-5' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'while' Keyword +'(' Punctuation +'!' Operator +'IsStopped' Name.Function +'(' Punctuation +')' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'datetime' Keyword.Type +' ' Text +'cur_time' Name +'=' Operator +'LocalTime' Name +'(' Punctuation +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'//--- check for new rates\n' Comment.Single + +' ' Text +'if' Keyword +'(' Punctuation +'RefreshRates' Name.Function +'(' Punctuation +')' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'time0' Name +'=' Operator +'Time' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'FileSeek' Name.Function +'(' Punctuation +'ExtHandle' Name +',' Punctuation +'last_fpos' Name +',' Punctuation +'SEEK_SET' Name.Constant +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'//--- is there current bar?\n' Comment.Single + +' ' Text +'if' Keyword +'(' Punctuation +'time0' Name +'<' Operator +'rate' Name +'.' Punctuation +'time' Name +'+' Operator +'periodseconds' Name +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'tick_volume' Name +'+' Operator +'=' Operator +'(' Punctuation +'long' Keyword.Type +')' Punctuation +'Volume' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +'-' Operator +'last_volume' Name +';' Punctuation +'\n' Text + +' ' Text +'last_volume' Name +'=' Operator +'(' Punctuation +'long' Keyword.Type +')' Punctuation +'Volume' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +';' Punctuation +' \n ' Text +'if' Keyword +'(' Punctuation +'rate' Name +'.' Punctuation +'low' Name +'>' Operator +'Low' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'low' Name +'=' Operator +'Low' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'rate' Name +'.' Punctuation +'high' Name +'<' Operator +'High' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'high' Name +'=' Operator +'High' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'close' Name +'=' Operator +'Close' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'else' Keyword +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'//--- no, there is new bar\n' Comment.Single + +' ' Text +'rate' Name +'.' Punctuation +'tick_volume' Name +'+' Operator +'=' Operator +'(' Punctuation +'long' Keyword.Type +')' Punctuation +'Volume' Keyword +'[' Punctuation +'1' Literal.Number.Integer +']' Punctuation +'-' Operator +'last_volume' Name +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'rate' Name +'.' Punctuation +'low' Name +'>' Operator +'Low' Keyword +'[' Punctuation +'1' Literal.Number.Integer +']' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'low' Name +'=' Operator +'Low' Keyword +'[' Punctuation +'1' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'rate' Name +'.' Punctuation +'high' Name +'<' Operator +'High' Keyword +'[' Punctuation +'1' Literal.Number.Integer +']' Punctuation +')' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'high' Name +'=' Operator +'High' Keyword +'[' Punctuation +'1' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'//--- write previous bar remains\n' Comment.Single + +' ' Text +'FileWriteStruct' Name.Function +'(' Punctuation +'ExtHandle' Name +',' Punctuation +'rate' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'last_fpos' Name +'=' Operator +'FileTell' Name.Function +'(' Punctuation +'ExtHandle' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'//----\n' Comment.Single + +' ' Text +'rate' Name +'.' Punctuation +'time' Name +'=' Operator +'time0' Name +'/' Operator +'periodseconds' Name +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'time' Name +'*' Operator +'=' Operator +'periodseconds' Name +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'open' Name +'=' Operator +'Open' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'low' Name +'=' Operator +'Low' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'high' Name +'=' Operator +'High' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'close' Name +'=' Operator +'Close' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'rate' Name +'.' Punctuation +'tick_volume' Name +'=' Operator +'(' Punctuation +'long' Keyword.Type +')' Punctuation +'Volume' Keyword +'[' Punctuation +'0' Literal.Number.Integer +']' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'last_volume' Name +'=' Operator +'rate' Name +'.' Punctuation +'tick_volume' Name +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'//----\n' Comment.Single + +' ' Text +'FileWriteStruct' Name.Function +'(' Punctuation +'ExtHandle' Name +',' Punctuation +'rate' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'FileFlush' Name.Function +'(' Punctuation +'ExtHandle' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'//---\n' Comment.Single + +' ' Text +'if' Keyword +'(' Punctuation +'hwnd' Name +'=' Operator +'=' Operator +'0' Literal.Number.Integer +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'hwnd' Name +'=' Operator +'WindowHandle' Name.Function +'(' Punctuation +'Symbol' Name.Function +'(' Punctuation +')' Punctuation +',' Punctuation +'i_period' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'if' Keyword +'(' Punctuation +'hwnd' Name +'!' Operator +'=' Operator +'0' Literal.Number.Integer +')' Punctuation +'\n' Text + +' ' Text +'Print' Name.Function +'(' Punctuation +'"' Literal.String +'Chart window detected' Literal.String +'"' Literal.String +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'//--- refresh window not frequently than 1 time in 2 seconds\n' Comment.Single + +' ' Text +'if' Keyword +'(' Punctuation +'hwnd' Name +'!' Operator +'=' Operator +'0' Literal.Number.Integer +' ' Text +'&' Operator +'&' Operator +' ' Text +'cur_time' Name +'-' Operator +'last_time' Name +'>' Operator +'=' Operator +'2' Literal.Number.Integer +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'PostMessageA' Name +'(' Punctuation +'hwnd' Name +',' Punctuation +'WM_COMMAND' Name +',' Punctuation +'33324' Literal.Number.Integer +',' Punctuation +'0' Literal.Number.Integer +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'last_time' Name +'=' Operator +'cur_time' Name +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +' ' Text +'Sleep' Name.Function +'(' Punctuation +'50' Literal.Number.Integer +')' Punctuation +';' Punctuation +' \n ' Text +'}' Punctuation +' \n' Text + +'//---\n' Comment.Single + +' ' Text +'}' Punctuation +'\n' Text + +'//+------------------------------------------------------------------+\n' Comment.Single + +'//| |\n' Comment.Single + +'//+------------------------------------------------------------------+\n' Comment.Single + +'void' Keyword.Type +' ' Text +'OnDeinit' Name.Function +'(' Punctuation +'const' Keyword +' ' Text +'int' Keyword.Type +' ' Text +'reason' Name +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +'//---\n' Comment.Single + +' ' Text +'if' Keyword +'(' Punctuation +'ExtHandle' Name +'>' Operator +'=' Operator +'0' Literal.Number.Integer +')' Punctuation +'\n' Text + +' ' Text +'{' Punctuation +'\n' Text + +' ' Text +'FileClose' Name.Function +'(' Punctuation +'ExtHandle' Name +')' Punctuation +';' Punctuation +'\n' Text + +' ' Text +'ExtHandle' Name +'=' Operator +'-1' Literal.Number.Integer +';' Punctuation +'\n' Text + +' ' Text +'}' Punctuation +'\n' Text + +'//---\n' Comment.Single + +' ' Text +'}' Punctuation +'\n' Text + +'//+------------------------------------------------------------------+\n' Comment.Single |
