how to open offline chart

 

hi

i m trying to open offline chart here is my code

 

#import "user32.dll"
  int PostMessageA(       int hWnd, int Msg, int wParam, int lParam );
  int SendMessageA(       int hWnd, int Msg, int wParam, int lParam );
  int GetAncestor(        int hWnd, int gaFlags );
  int GetLastActivePopup( int hWnd );
  int GetDlgItem(         int hDlg, int nIDDlgItem );
#import

#import "kernel32.dll"
  int  FindFirstFileA(    string Path, int& Answer[] );
  bool FindNextFileA(     int handle,  int& Answer[] );
  bool FindClose(         int handle );
#import

#define WM_COMMAND 0x0111
#define WM_KEYDOWN 0x0100
#define VK_DOWN      0x28
#define BM_CLICK   0x00F5
#define GA_ROOT         2
#define PAUSE         100

string BuffToString( int& Buffer[] ) 
{
  string Str = "";
  int    Pos = 11;

  while ( Pos < 75 ) {
     while ( Buffer[Pos] != 0 ) {
             Str          = Str + CharToStr( Buffer[Pos] & 0xFF );
             Buffer[Pos] /= 0x100;
     }
     Pos++;
  }

  return( Str );
}

int GetChartPos( string FileName )
{
  int Buffer[79];
  int Pos    = 0;
  int handle = FindFirstFileA( TerminalPath() + "\history\\"  + AccountServer() + "\\*.hst", Buffer );

  if ( BuffToString( Buffer ) != FileName ) {
       Pos++;

       while ( FindNextFileA( handle, Buffer ) ) {
               if ( BuffToString( Buffer ) == FileName )
                    break;
               Pos++;
       }
  }
  if ( handle > 0 )
       FindClose( handle );
  return( Pos );
}

int OpenOfflineList()
{
  int hwnd = WindowHandle( Symbol(), Period() );

  hwnd     = GetAncestor( hwnd, GA_ROOT );
  SendMessageA( hwnd, WM_COMMAND, 33053, 0 );
  Sleep( PAUSE );
  hwnd     = GetLastActivePopup( hwnd );
  return( hwnd );
}

void OpenOfflineChartbyNum( int ChartPos )
{
  int hwnd1 = OpenOfflineList();
  int hwnd2 = GetDlgItem( hwnd1, 1 );

  hwnd1     = GetDlgItem( hwnd1, 0x487 );
  while ( ChartPos >= 0 ) {
    SendMessageA( hwnd1, WM_KEYDOWN, VK_DOWN, 0 );
    ChartPos--;
  }
  Sleep( PAUSE );
  SendMessageA( hwnd2, BM_CLICK, 0, 0 );
  return;
}

void OpenOfflineChart( string Symb, int period )
{
  OpenOfflineChartbyNum( GetChartPos( Symb + period + ".hst" ) );
  return;
}

int init()
{
  OpenOfflineChart( "AUDUSD", 120 );
  return;
}
this code open offline chart window not open offline chart
 
zahidmahmood:

hi

i m trying to open offline chart here is my code

 

Interesting code. Does it have any advantage in comparison to ChartOpen()?

 
Ovo Cz:

Interesting code. Does it have any advantage in comparison to ChartOpen()?

yes sure i m making pair changer to change pair offline charts