[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Print to File Question



PureBytes Links

Trading Reference Links

Neal,

Here's some code that you can modify to do what you want. As its
written now, it will create an ASCII file of Date,Time,O,H,L,C and
name the file according to the symbol and time period displayed.

Below is the code. Attached is an ela.

Enjoy!

Bob Hunt
------------------------------------------------------------


{This indicator will create an ASCII file of the price data displayed
on any chart. INPUT specifies the user designated file path. The
actual name of the file is automatically determined from the symbol
and the time frame represented in the chart. For example, when this
indicator is applied to a weekly OEX chart, the file created will have
the name "oex_w.asc"   When used with an OEX 30 minute chart it will
create the filename "oex_i30.asc"

For ease of use, create a workspace specifically for the purpose of
exporting data. Set up a separate chart for each item or time frame
for which you want to export data.  For example, if trading the OEX,
you might want to set up separate OEX weekly, daily, and hourly charts
within one workspace.  Then, every time that you open this workspace,
three separate files will be automatically created containing the
exported data.

This indicator is a contribution by Bob Hunt and Cliff Scheller
        Bob Hunt <RHunt.066@xxxxxxxxxxxxxxxx>
        Cliff Scheller <cliffsch@xxxxxxx>
}

Input: Path("C:\folder\");   
vars: intvl(""),ticker(""),ftmp(""),fname(""),PS(0),Txt("");

Txt = NumToStr(PriceScale,0);
PS = StrLen(Txt) - 1;

If barnumber = 1 then begin
  if leftstr(getsymbolname,1)="$" then
ticker=midstr(getsymbolname,2,3) else ticker =
leftstr(getsymbolname,3);
  if midstr(ticker,2,1) = " " then ticker = leftstr(getsymbolname,1);
  if midstr(ticker,3,1) = " " then ticker = leftstr(getsymbolname,2);
  ticker = ticker + "_"; 
  if datacompression = 2 then ftmp = ticker + "d.asc";
  if datacompression = 3 then ftmp = ticker + "w.asc";
  if datacompression = 4 then ftmp = ticker + "m.asc";
  if datacompression = 1 then begin
    intvl = numtostr(barinterval,0);
    ftmp = ticker + "i" + intvl + ".asc";
  end;
  fname = path+ftmp;

  FileDelete(fname);
  FileAppend(fname,"Date,Time,Open,High,Low,Close"+NewLine);
end;

FileAppend(fname, NumToStr(date,0) +","+  NumToStr(Time,0) +","+
NumToStr(Open,PS) +","+ NumToStr(High,PS) +","+ NumToStr(Low,PS) +","+
NumToStr(Close,PS)+NewLine);

If LastBarOnChart then FileAppend(fname,NumToStr(date,0)+NewLine);

Plot1(0,"0");
Attachment Converted: "c:\eudora\attach\AsciiMak.ela"