Info on how to use ListC.Readfile(ID, Filemname)

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Info on how to use ListC.Readfile(ID, Filemname)

Postby arjfca » 06 Jul 2011

Hello

Extract from ElCollections Documents:
ListC.Readfile(ID,Filename);
Read a comma delimited text files into the List specified by ID. The data is represented as a list of list, where each column in the text file is represented as a sub list.

Nearly a Chinese text equivalent for me :)

I succeeded to read the file using :ListS.ReadFile(ID, ,"f:\temp\TestData\CSVData.Txt"); The file value is stored in a string variable.

The goal is to have each coma separated information in a separated variable.
Could I use ListC.Readfile(IC,Filename) to read a coma separated file for that? If so, how can I can I do it. I just don't get it.

EX:

Code: Select all

Var:
MyBigString = ("True,EUR.USD,Buy Stop,37000,1.4367,Stop Loss, 1.4345"),
[b]
ListC.ReadFile(ID, ,"f:\temp\TestData\CSVData.Txt");

// Process to be done here
//
//String separation process, result should be = to these value for the given string

//OrderString(0) = True
//OrderString(1) = Eur.Usd
//OrderString(2) = Buy Stop
//OrderString(3) = 37000
//OrderString(4) = 1.4367
//OrderString(5) = Stop Loss
//OrderString(6) = 1.4345

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Info on how to use ListC.Readfile(ID, Filemname)

Postby arjfca » 06 Jul 2011

Just found a post from member bowlesj3 where he explain how to use it.

Many thanks again John

viewtopic.php?t=6908&start=0&postdays=0 ... highlight=

Martin

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Info on how to use ListC.Readfile(ID, Filemname).. Resol

Postby arjfca » 06 Jul 2011

Here is my finish result.

With The proposed code by John, BowlesJ3 and the information given by TJ I'm now able to
- Read a text file
- Place all information from the text file in an appropriate Variable

With the original code, I was able to read string only. Numbers in the string caused a failure in the routine. To resolved it, In my text file, I added a characters in front of any numbers to mystify the code. From the new string i them removed the added characters to get a clean numbers value

Original text file value
True,EUR.USD,Buy Stop,3700,1.4367,Stop Loss,1.4345

New Text File Value ( " ! " was added in front of numbers
True,EUR.USD,Buy Stop,!3700,!1.4367,Stop Loss,!1.4345

To test it:
1) create a text file containing the new text value. My actual one is called CXVData.txt
2) replace the file adress by yours in this line
Value1 = ListC.ReadFile(ListC_ID,"f:\temp\TestData\CSVData.Txt");

Code: Select all

Variable:
TargetTime (0),
Delay (500),
MyBigString ("True,EUR.USD,Buy Stop,37000,1.4367,Stop Loss, 1.4345,!"),
String2 (""),
StoreValue (0),
MyStringLoc (1),
Price (1.4635),
TextFile (""),

ListC_ID(0),
DataReadyString (""),
DataReady (False),
QTYString (""),
QTY (0),
MarketName (""),
OrdersToDo (""),
OrderEntryPriceString (""),
OrderEntryPrice (0),
OrderStopToDo (""),
OrderStoLossPriceString (""),
OrderStopLossPrice (0),

LISTDataReadyString_ID (0),
ListQTY_ID (0),
ListMarketName_ID (0),
ListOrdersToDo_ID (0),
ListOrderEntryPrice_ID (0),
ListOrderStopToDo_ID (0),
ListOrderStoLossPrice_ID (0),

ValidData (False);


Array: OrdersLine[7]("");

//----------------------------------------------------------------------------------------------
// Code Start here

//("True,EUR.USD,Buy Stop,37000,1.4367,Stop Loss, 1.4345,!"),

//Read the CSVData and separate the value
Listc_ID =ListC.New;

Value1 = ListC.ReadFile(ListC_ID,"f:\temp\TestData\CSVData.Txt");

LISTDataReadyString_ID = ListC.Get(ListC_ID,1);
ListMarketName_ID = ListC.Get(ListC_ID,2);
ListOrdersToDo_ID = ListC.Get(ListC_ID,3);
ListQTY_ID = ListC.Get(ListC_ID,4);
ListOrderEntryPrice_ID = ListC.Get(ListC_ID,5);
ListOrderStopToDo_ID = ListC.Get(ListC_ID,6);
ListOrderStoLossPrice_ID = ListC.Get(ListC_ID,7);

//Get the data now
DataReadyString = ListS.Get(LISTDataReadyString_ID ,1);
MarketName = ListS.Get(ListMarketName_ID ,1);
OrdersToDo = ListS.Get(ListOrdersToDo_ID ,1);
QTYString = ListS.Get(ListQTY_ID ,1);
OrderEntryPriceString = ListS.Get(ListOrderEntryPrice_ID ,1);
OrderStopToDo =ListS.Get(ListOrderStopToDo_ID ,1);
OrderStoLossPriceString =ListS.Get(ListOrderStoLossPrice_ID ,1);

// Replace String in the proper format for the needed one
QTY = StrtoNum(midstr(QtyString,2,StrLen(QTYString)-1));
OrderEntryPrice = StrtoNum(midstr(OrderEntryPriceString,2,StrLen(OrderEntryPriceString)-1));
OrderStopLossPrice = StrtoNum(midstr(OrderStoLossPriceString,2,StrLen(OrderStoLossPriceString)-1));
If instr(DataReadyString, "True") >= 1 then DataReady = True else DataReady = False;

If barnumber = 1 then print (
DataReady," ",
MarKetName," ",
OrdersToDo, " ",
Qty:0:0, " ",
OrderEntryPrice:4:4, " ",
OrderStopToDo, " ",
OrderStopLossPrice:4:4);
I'm not an expert with ListC.readfile and others ElCollections DLL. bowlesJ3 is the one. I just copied and adapted is work

Martin

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Info on how to use ListC.Readfile(ID, Filemname).. Resol

Postby TJ » 06 Jul 2011

Here is my finish result.
...
Martin
Thanks for sharing.
Much appreciated.

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

Re: Info on how to use ListC.Readfile(ID, Filemname)

Postby bowlesj3 » 06 Jul 2011

I just copied and adapted his work
Actually this is exactly what I do with these commands. I go back and use a prior script which I figured out months earlier to create a new one (maybe have to make it a bit more complex at times). To be an expert you really have to use something almost every day so you can do it from memory. The list of lists and map commands get interesting. I am pretty sure I created examples of both of those.

LarryR
Posts: 5
Joined: 24 Nov 2013

Re: Info on how to use ListC.Readfile(ID, Filemname)

Postby LarryR » 28 Nov 2013

How can similar code be used to exit all open positions 15min before an economic event that may appear on the list?

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

Re: Info on how to use ListC.Readfile(ID, Filemname)

Postby bowlesj3 » 01 Dec 2013

At the top of the forum where users submit scripts they have created you will find one for economic events. I am not that familiar with it since I review the economic events manually and create a file that is picked up by ELcolllections and used to place vertical lines on the screen. However if you study the EL collections and the sample code for it and study this economic thread you may be able to come up with some ideas for using data coming in via ELcollections to do what you want.


Return to “MultiCharts”