external Winsock Text Stream OR DDE live ticks to MT4 ?

 

hello all,



there's a way to put EXTERNAL winsock text stream

or

DDE to update charts on MT4 real time ?



thanks.

 

Write the data to hst file, and keep the hst file updated, load the hst into an offline chart, and force an update when needed.

Search for "period converter optimized" for all the code hints to accomplish that.

 

thanks again !


could i access file operations from a c# or c++ program using a kind metatrade api ?

for example i would like to do this command to write HST from a c# application:


int WriteHistoryHeader()
{
string c_copyright;
int i_digits = Digits;
int i_unused[13] = {0};
int version = 400;

if (FileHandle < 0) return (-1);
c_copyright = "(C)opyright 2003, MetaQuotes Software Corp.";
FileWriteInteger(FileHandle, version, LONG_VALUE);
FileWriteString(FileHandle, c_copyright, 64);
FileWriteString(FileHandle, Symbol(), 12);
FileWriteInteger(FileHandle, NewPeriod, LONG_VALUE);
FileWriteInteger(FileHandle, i_digits, LONG_VALUE);
FileWriteInteger(FileHandle, 0, LONG_VALUE); //timesign
FileWriteInteger(FileHandle, 0, LONG_VALUE); //last_sync
FileWriteArray(FileHandle, i_unused, 0, ArraySize(i_unused));
return (0);
}

 

could i access file operations from a c# or c++ program

of course

using a kind metatrade api ?

use C stdio or C++ stream oeprations to read/write files.

 
phy:

of course

use C stdio or C++ stream oeprations to read/write files.

hello,


i mean, it's ok to write csv's in c#. but the hst files ?


it seems to be encrypted.

 

hst are not encrypted. They are binary files. You just have to know the format.

Header - which you show above.

then bar after bar after bar in the body of the file, again, using the proper format:

integer bartime LONG_VALUE

double open DOUBLE_VALUE

double high DOUBLE_VALUE

double low DOUBLE_VALUE

double close DOUBLE_VALUE

double volume DOUBLE_VALUE

integer bartime LONG_VALUE

double open DOUBLE_VALUE

double high DOUBLE_VALUE

double low DOUBLE_VALUE

double close DOUBLE_VALUE

double volume DOUBLE_VALUE

on and on

 
phy:

hst are not encrypted. They are binary files. You just have to know the format.

Header - which you show above.

then bar after bar after bar in the body of the file, again, using the proper format:

integer bartime LONG_VALUE

double open DOUBLE_VALUE

double high DOUBLE_VALUE

double low DOUBLE_VALUE

double close DOUBLE_VALUE

double volume DOUBLE_VALUE

integer bartime LONG_VALUE

double open DOUBLE_VALUE

double high DOUBLE_VALUE

double low DOUBLE_VALUE

double close DOUBLE_VALUE

double volume DOUBLE_VALUE

on and on


i've tried to write a file trough c# binarywriter class, but is seems to be wrong in some part cause it generated a bin file that don't appear on offline charts window.

different from the code in mql that works ok.


do you have a code in c++ that works on it ? so i could import it to c#.


my code in c#:

using System.IO;


FileStream fs = File.Create("C:\\Program Files\\WHC Trader 4\\history\\BroCo-Demo\\dotnet2.hst");
BinaryWriter bw = new BinaryWriter(fs);

int version = 400;
string copyright = "TripaSecaCorp";
string symbol = "dotnet2";
int newperiod =1440;
int digits = 2;
byte[] array_unused = {0};

bw.Write(version);
bw.Write(copyright);
bw.Write(symbol);
bw.Write(newperiod);
bw.Write(digits);
bw.Write(0);
bw.Write(0);
bw.Write(array_unused);


long date = DateTime.Now.ToBinary();

double open = 1, high = 2, low = 3, close = 4, volume =5;

bw.Write(date);
bw.Write(open);
bw.Write(high);
bw.Write(low);
bw.Write(close);
bw.Write(volume);

bw.Close();
fs.Close();

 

Byte alignment is important here.

Maybe use C and control the size of each write, or the equivalent in C#.

 
phy:

Byte alignment is important here.

Maybe use C and control the size of each write, or the equivalent in C#.

i didn't found an example for visual c++ that writes double, string and char as i need.


do you know any reference ?

 

use C code inside your C++ code.

http://www.cplusplus.com/reference/clibrary/cstdio/

 
ok, how can i format the date to write the bartime data ?