Project help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need a routine that will step through a text file of consistent structure
and, based on the content of each line, construct and save another text file.
Outline of the project is as follows:

1. Prompt for location and name of input text file by displaying directory
structure from a default location.
2. Prompt for location of new file with default location tree navigation
shown.
3. New file name to be same as original but with suffix "C"
4. Step through input file line by line
5. At each occurrence of "-------" do the following:
a. Write all the text inside the curly braces preceded by an incrementing
number starting at 1.
b. Construct a new line based on the content of each following line before
the word "THEN" based on the following rules:

"CLOSE" = "close"
"LOW" = "low"
"OPEN" = "open"
"HIGH" = high"
"OF 'X' DAYS AGO" = "(-'X')"
"OF TODAY" = "(0)"
"OF YESTERDAY" = "(-1)"
Operator as is
Each line to be concatenated on a single new line by "&&"
The last two lines before the next "----" to produce "T = +13" on 3rd line
& "S = -13" on 4th line
Each new 'record' in the new file to be separated by a similar line of
"--------------"

Thus the content of the first group of lines between successive "-------"
lines in the specimen input file below would produce the following in the new
file:

"1. {File:ZH610.txt Index:5 Index Date:10001616 PL:73.91% PS:26.09%
Trades:23 CL:2}
close(-7) > close(-5) && close(-5) > close(-6) && close(-6) > close(-8)
T = +13
S = -13"

It's the file handling and looping logic I'm having problems with. I guess
this a complete project description sufficient to do the job - any help (or
the completed project code :-))) ) appreciated.

The format of the input file is shown between the chevrons below

MODEL LOGIC
----------------------------------------------------------------------------------------------------------------------------------
{File:ZH610.txt Index:5 Index Date:10001616 PL:73.91% PS:26.09%
Trades:23 CL:2}

IF CLOSE OF 7 DAYS AGO > CLOSE OF 5 DAYS AGO
AND CLOSE OF 5 DAYS AGO > CLOSE OF 6 DAYS AGO
AND CLOSE OF 6 DAYS AGO > CLOSE OF 8 DAYS AGO
THEN BUY TOMORROW ON THE OPEN WITH
PROFIT TARGET AT ENTRY PRICE + 13 POINTS
AND STOP LOSS AT ENTRY PRICE - 13 POINTS
----------------------------------------------------------------------------------------------------------------------------------

{File:ZH610.txt Index:6 Index Date:10001615 PL:84.62% PS:15.38%
Trades:13 CL:1}

IF CLOSE OF YESTERDAY > CLOSE OF TODAY
AND CLOSE OF TODAY > CLOSE OF 3 DAYS AGO
AND CLOSE OF 3 DAYS AGO > CLOSE OF 2 DAYS AGO
AND CLOSE OF 2 DAYS AGO > CLOSE OF 4 DAYS AGO
THEN BUY TOMORROW ON THE OPEN WITH
PROFIT TARGET AT ENTRY PRICE + 13 POINTS
AND STOP LOSS AT ENTRY PRICE - 13 POINTS
----------------------------------------------------------------------------------------------------------------------------------

{File:ZH610.txt Index:7 Index Date:10001606 PL:81.82% PS:18.18%
Trades:22 CL:1}

IF CLOSE OF 5 DAYS AGO > CLOSE OF 4 DAYS AGO
AND CLOSE OF 4 DAYS AGO > CLOSE OF 6 DAYS AGO
AND CLOSE OF 6 DAYS AGO > CLOSE OF 7 DAYS AGO
AND CLOSE OF 7 DAYS AGO > CLOSE OF 8 DAYS AGO
AND CLOSE OF 8 DAYS AGO > CLOSE OF 9 DAYS AGO
THEN BUY TOMORROW ON THE OPEN WITH
PROFIT TARGET AT ENTRY PRICE + 13 POINTS
AND STOP LOSS AT ENTRY PRICE - 13 POINTS[/QUOTE][/QUOTE][/QUOTE]
 
Thats a lot of description you have there. Any chance you could narrow your
request down to a specific question or questions, more of us would be able
to help you then.

chrisj


PeterPr said:
I need a routine that will step through a text file of consistent structure
and, based on the content of each line, construct and save another text
file.
Outline of the project is as follows:

1. Prompt for location and name of input text file by displaying directory
structure from a default location.
2. Prompt for location of new file with default location tree navigation
shown.
3. New file name to be same as original but with suffix "C"
4. Step through input file line by line
5. At each occurrence of "-------" do the following:
a. Write all the text inside the curly braces preceded by an incrementing
number starting at 1.
b. Construct a new line based on the content of each following line before
the word "THEN" based on the following rules:

"CLOSE" = "close"
"LOW" = "low"
"OPEN" = "open"
"HIGH" = high"
"OF 'X' DAYS AGO" = "(-'X')"
"OF TODAY" = "(0)"
"OF YESTERDAY" = "(-1)"
Operator as is
Each line to be concatenated on a single new line by "&&"
The last two lines before the next "----" to produce "T = +13" on 3rd
line
& "S = -13" on 4th line
Each new 'record' in the new file to be separated by a similar line of
"--------------"

Thus the content of the first group of lines between successive "-------"
lines in the specimen input file below would produce the following in the
new
file:

"1. {File:ZH610.txt Index:5 Index Date:10001616 PL:73.91% PS:26.09%
Trades:23 CL:2}
close(-7) > close(-5) && close(-5) > close(-6) && close(-6) > close(-8)
T = +13
S = -13"

It's the file handling and looping logic I'm having problems with. I guess
this a complete project description sufficient to do the job - any help
(or
the completed project code :-))) ) appreciated.

The format of the input file is shown between the chevrons below


MODEL LOGIC
----------------------------------------------------------------------------------------------------------------------------------
{File:ZH610.txt Index:5 Index Date:10001616 PL:73.91% PS:26.09%
Trades:23 CL:2}

IF CLOSE OF 7 DAYS AGO > CLOSE OF 5 DAYS AGO
AND CLOSE OF 5 DAYS AGO > CLOSE OF 6 DAYS AGO
AND CLOSE OF 6 DAYS AGO > CLOSE OF 8 DAYS AGO
THEN BUY TOMORROW ON THE OPEN WITH
PROFIT TARGET AT ENTRY PRICE + 13 POINTS
AND STOP LOSS AT ENTRY PRICE - 13 POINTS
----------------------------------------------------------------------------------------------------------------------------------

{File:ZH610.txt Index:6 Index Date:10001615 PL:84.62% PS:15.38%
Trades:13 CL:1}

IF CLOSE OF YESTERDAY > CLOSE OF TODAY
AND CLOSE OF TODAY > CLOSE OF 3 DAYS AGO
AND CLOSE OF 3 DAYS AGO > CLOSE OF 2 DAYS AGO
AND CLOSE OF 2 DAYS AGO > CLOSE OF 4 DAYS AGO
THEN BUY TOMORROW ON THE OPEN WITH
PROFIT TARGET AT ENTRY PRICE + 13 POINTS
AND STOP LOSS AT ENTRY PRICE - 13 POINTS
----------------------------------------------------------------------------------------------------------------------------------

{File:ZH610.txt Index:7 Index Date:10001606 PL:81.82% PS:18.18%
Trades:22 CL:1}

IF CLOSE OF 5 DAYS AGO > CLOSE OF 4 DAYS AGO
AND CLOSE OF 4 DAYS AGO > CLOSE OF 6 DAYS AGO
AND CLOSE OF 6 DAYS AGO > CLOSE OF 7 DAYS AGO
AND CLOSE OF 7 DAYS AGO > CLOSE OF 8 DAYS AGO
AND CLOSE OF 8 DAYS AGO > CLOSE OF 9 DAYS AGO
THEN BUY TOMORROW ON THE OPEN WITH
PROFIT TARGET AT ENTRY PRICE + 13 POINTS
AND STOP LOSS AT ENTRY PRICE - 13 POINTS
[/QUOTE][/QUOTE]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top