Help with reading from a file

Questions about MultiCharts and user contributed studies.
Jesh
Posts: 41
Joined: 04 Jan 2011
Has thanked: 12 times
Been thanked: 4 times

Help with reading from a file

Postby Jesh » 15 Sep 2011

Hi,

I’m looking for help regarding how to write code to open a file in the format below and parsing the text then writing the data to another file:

File to read from: C:\Strategy\marker.txt

Text in file: 10:58:15 1185.00 @ESZ11 SELL SIGNAL

Can anybody provide some assistance to how I can read from the file above?

I have found some information in the following thread http://www.multicharts.com/discussion/v ... f=5&t=8880 but I’m not sure if I need to configure the ADE and EL collections in MC 7 or if these are now included.

Thanks,

Bobby

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Help with reading from a file

Postby Henry MultiСharts » 16 Sep 2011

Hello Bobby.
You need to write a custom Dll to work with files.
We can write it for you as a custom paid project.
Please contact us directly if you are interested in custom programming.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: Help with reading from a file

Postby bowlesj3 » 16 Sep 2011

There is info on reading from files in this thread. I created a modified document from damageboy's ELcollections info showing how to read from files with a few extra examples.

viewtopic.php?=&p=8189

to split out your text the EL string functions can do it if they are of consistent format.

None maybe as fast as a dll but easier to put together. It would be hard to sell MC if all buyers needed to know C programming. I have been programming 30 years and I do not know C.

There is a good example of an ELcollections read in the zip file in here.
viewtopic.php?f=1&t=6919&p=29724&hilit=listc#p29724

viewtopic.php?f=1&t=6901&hilit=listc

Jesh
Posts: 41
Joined: 04 Jan 2011
Has thanked: 12 times
Been thanked: 4 times

Re: Help with reading from a file

Postby Jesh » 28 Sep 2011

Thanks for your help bowlesj3. I can now read from the file.

Currently I delete the file after I have read from it and then when my code tries to read it again there are errors because the file does not exist. What I'm trying to do is:

1) check if the file exists
2) if the file does exist then read the content (done)
3) delete the file (done)

Is there a way to check the file exists before reading from it and if it does then execute some code?

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: Help with reading from a file

Postby bowlesj3 » 28 Sep 2011

Yes, but I have not used it. In the EL collections there is a command for it. I extracted the documentation below. I guess you have the EL collections set up now so it should be able to just execute it. I find the EL collections documentation is very useful to reread every 6+ months. It is surprising how new (almost exciting) it seems if you wait 6 to 12 months before you sit down over a relaxing coffee and just plow through it all again.
Value1 = ELC.PathExists(FilePath);
Returns true if the specified file path exists. FilePath can be either a file or a directory. For example, the following code prints a message if a symbol file exists:

if ELC.PathExists(“C:\Temp\Symbols.txt”) then Print(“Found symbol file”);

The following code prints a message if the specified directory exists:

if ELC.PathExists(“C:\Temp\Data”) then Print(“Data directory found”);

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: Help with reading from a file

Postby bowlesj3 » 29 Sep 2011

I find this daily routine handy at times.

I found the above command quickly because I use a reminder system in my calendar. I put things I want to remember in my calendar to popup some time in the future (all sorts of things). I see a few of them once a day and I will bump them ahead to where I might want a reminder again or just put them out far enough that I do not get too overloaded with reminders. It is a daily routine. So I created a popup of useful commands for EL coding and I added a few things from a 2nd or 3rd read of the EL collections. I can search these popup reminders and sure enough using "exists" I found this popup and went in and found the command. In other words I thought I might use it in the future and I wanted to be aware of it or I wanted a place where I could search for it. If I did not do this I probably would not have been able to answer the question so fast. Sometimes I will read though the list of useful commands looking for something and I get a review of all these useful commands. So far I think I have gone back to use 25% of them.

Jesh
Posts: 41
Joined: 04 Jan 2011
Has thanked: 12 times
Been thanked: 4 times

Re: Help with reading from a file

Postby Jesh » 29 Sep 2011

Thanks bowlesj3.

With your help I've got the code working, now I can read the file, process the data and after processing the data I delete the file.


Return to “MultiCharts”