This is a TS indicator that creates and update ascii data file in real time as new data appears on the TS chart. Dynamic Trader then reads and charts these ascii file real time.
- Code: Select all
{This file is source code for the Easy Language interface to DT. }
Vars: Directory("C:\DTTSDATA"),Interval(" "),FileName(""),x(0),wParm(0),ThisVolume(0),Count( 0),LastDate(0),LastTime(0),fname("");
definedllfunc:"C:\dttsdata\DTTS.DLL",int,"SendData ",float,lpstr,lpstr,lpstr,float,float,float,float, float,float,float,float;
ThisVolume = Ticks;
if barnumber = 1 then
begin
if DataCompression = 0 then Interval = NumToStr(Highest(upticks + downticks,5),0);
if DataCompression = 1 then Interval = NumToStr(BarInterval,0);
if DataCompression = 2 then Interval = "Daily";
if DataCompression = 3 then Interval = "Weekly";
if DataCompression = 4 then Interval = "Monthly";
fname = MidStr(getsymbolname,+0,3)+ MidStr(getsymbolname,+5,7) + "_"+Interval+"."; {name & extension only}
if DataCompression = 0 then fname = fname + "dtt";
if DataCompression = 1 then fname = fname + "dti";
if DataCompression = 2 then fname = fname + "dtd";
if DataCompression = 3 then fname = fname + "dtw";
if DataCompression = 4 then fname = fname + "dtm";
FileName = Directory + fname;
Input: cf(4);
FileDelete(FileName);
FileAppend(FileName,"cf= " + NumToStr(cf,0) + newline);
if DataCompression = 0 then FileAppend(FileName,"ticks= " + Interval + NewLine);
if DataCompression = 1 then FileAppend(FileName,"min= " + Interval + NewLine);
if DataCompression > 1 then FileAppend(FileName, LeftStr(Interval,1) + NewLine);
FileAppend(FileName,"DATE TIME OPEN HIGH LOW CLOSE VOLUME" + NEWLINE);
for x = MaxBarsBack downto 1
begin
ThisVolume = iff(DataCompression =0,Upticks[x] + DownTicks[x],Ticks[x]);
fileappend(FileName,numtostr(date[x],0) + " " + numtostr(time[x],0) + " " +
numtostr(open[x],4) + " " + numtostr(high[x],4) + " " + numtostr(low[x],4) + " " + numtostr(close[x],4) + " " +
numtostr(ThisVolume,0) + newline);
LastDate = Date; {Date & Time of last whole bar stored in file}
LastTime = Time;
end;
end;
wParm=BarStatus(1); {NOTE: Does not return 0 for opening tick as specified in docs!}
if wParm = 2 then
begin {Last Tick Of Bar, print new line}
fileappend(FileName,numtostr(date,0) + " " + numtostr(time,0) + " " +
numtostr(open,cf) + " " + numtostr(high,cf) + " " + numtostr(low,cf) + " " + numtostr(close,cf) + " " +
numtostr(ThisVolume,0) + newline);
end;
if LastBarOnChart then
begin
if (wParm<>2 or (date <> LastDate) or (time <> LastTime)) then {we're not duplicating last bar in file}
value1 = SendData(wParm,MidStr(getsymbolname,InStr(getsymbo lname,":")+1,20),Interval,fname,Date,Time,Open,Hig h,Low,Close,ThisVolume,OpenInt);
end;
Thanks,
Noyp22