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

Re: File Append function issues



PureBytes Links

Trading Reference Links

At 09:12 PM 10/30/2005, Paul wrote:

>Hi All,
>
>I am trying to figure out the file append function.
>
>I am trying to create a metastock ascii file with the following format
><date>, <time>, <open>, <high>, <low>, <close>, <volume>
><yyyymmdd>, <HH:MM>, <open>, <high>, <low>, <close>, <upticks + downticks>
>
>and I want it to export to the "C:\TSdata\" directory
>
>and I want the file name to be
><symbol>_lastbaronchartDATE_lastbaronchartTME.csv
>
>I have included what I have done below but it does not verify. Would someone mind having a look at the code and see where I maybe going wrong.

Hi Paul,

One thing I noticed right away is that you are using the name of the file from the first bar onward, but you aren't defining it until the last bar on the chart. This is bound to cause trouble.

You should change your test where you set the name from 

If LastBarOnChart then Name = ....

to

If CurrentBar = 1 then Name = ....

then you will have the name defined in advance for the entire series.

HTH,
Mike Gossland



>Thanks
>Paul
>
>{ <><><> START CODE <><><>}
>Inputs: DIR("c:\TSdata\"), Decimalz(2);
>
>Vars: Name(String);
>
>If LastBaronChart then Name = (Symbol + NumToStr(1900+year(date),0) +
> NumToStr(month(date),0) +
> NumToStr(FracPortion(date/100)*100,0) + "_" +
>
> NumToStr(IntPortion(TIME/100),0) +
> NumToStr(FracPortion(TIME/100)*100,0));
>
>
>If currentbar >= 1 then FileAppend(DIR+name +".csv",
> NumToStr(1900+year(date),0) +
> NumToStr(month(date),0) +
> NumToStr(FracPortion(date/100)*100,0) + "," +
>
> NumToStr(IntPortion(TIME/100),0) + ":" +
> NumToStr(FracPortion(TIME/100)*100,0) + "," +
>
> NumToStr(Open,Decimalz) + "," +
> NumToStr(High,Decimalz) + "," +
> NumToStr(Low,Decimalz) + "," +
> NumToStr(Close,Decimalz) + "," +
> NumToStr(Upticks + Downticks,0) + "," + newline );
>
>if c<> c then plot1(1," ");
>
>{<><><> END CODE <><><>}