NexusFi: Find Your Edge


Home Menu

 





ElCollection: Want to understand


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one StratOpt with 6 posts (2 thanks)
    2. looks_two arjfca with 5 posts (2 thanks)
    3. looks_3 ABCTG with 2 posts (1 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 9,252 views
    2. thumb_up 5 thanks given
    3. group 3 followers
    1. forum 13 posts
    2. attach_file 0 attachments




 
Search this Thread

ElCollection: Want to understand

  #1 (permalink)
 arjfca 
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
Posts: 263 since Sep 2010
Thanks Given: 440
Thanks Received: 91

Hello

I did post a similar question on Multicharts forum, but no answerd yet.
MultiCharts: Trading Software for Automated Trading and [AUTOLINK]Backtesting[/AUTOLINK] ? View topic - Elcollection: Going through CSV file// Want to understand...

I read many time the ElCollection manual, but no success yet.

My goal is to read string by string a file that contain a collection of strings

A string Look like
HTML Code:
5,132.226120,132.379180,41549.9083333333,41549.9868055556,2124031,1,0,False,False

Variable FileName contain the Path\Filename
Variable TL_String to contain an individual string read from the file

I need to get to this kind of code
 
Code
ID = Unidentified Function(filename)
for Index = 1 to ListC.Count(ID) begin
	TL_String = ListC.Get(ID, Index);
	// do something with TL_String
end;

Any help appreciated
Martin


HTML Code:
5,132.226120,132.379180,41549.9083333333,41549.9868055556,2124031,1,0,False,False
38,133.690000,133.690000,41578.5416666667,41579.2916666667,2124031,1,2,False,True
51,139.249120,139.249120,41614.0416666667,41615.0416666667,2124031,1,0,False,False
54,141.060430,141.066520,41616.7500000000,41618.0000000000,2124031,1,0,False,False
1,130.810000,572.277778,41487.0000000000,41487.0000000000,32768,1,0,False,False
2,130.085000,69.090278,41487.0000000000,41487.0000000000,32768,1,0,False,False
3,131.785000,572.277778,41490.7500000000,41490.7500000000,16711680,3,0,False,False
4,131.130000,69.090278,41490.7500000000,41490.7500000000,16711680,3,0,False,False
6,128.725000,572.277778,41497.7500000000,41497.7500000000,16711680,3,0,False,False
7,128.120000,69.090278,41497.7500000000,41497.7500000000,16711680,3,0,False,False

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
NexusFi Journal Challenge - April 2024
Feedback and Announcements
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Are there any eval firms that allow you to sink to your …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
37 thanks
GFIs1 1 DAX trade per day journal
22 thanks
NexusFi site changelog and issues/problem reporting
22 thanks
The Program
20 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623


Martin,

from this post it's not really clear what the problem is. From the MC post it appears you are having problems with how to create and name the list. This is something you have to do before you can work with it.
From the code piece you posted it appears that you want to read every line into its own list and store all those lists within a collection of lists.

I could better help you if I you could elaborate what exactly you want to achieve in the end. Meaning in what structure you need the strings later. Maybe what you are trying to do could be accomplished easier.

If you are sure you are on the right track a synopsis of what to do would be something like this:

1. Create a new (or shared) collection of lists.
2. Create a new list and read the first line of your file into this list.
3. Store the list within your collection. This should be done by a key you can easily re-access.
4. Create a new list and read the second line into this list.
5. Store this list within your collection.

Of course 2. to 5. should be done within a loop.

After that you can loop up each list by its key from the collection, call it and read the individual list values.

Again I am not sure that you need something like this and for understanding EL Collections I would strongly advise to start with something simple. Collections of Lists and Maps are more complex, but easily to manage once you have a solid ELC understanding.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
  #4 (permalink)
StratOpt
AR Kansas
 
Posts: 13 since Dec 2013
Thanks Given: 0
Thanks Received: 7

It sounds like you need to look into using the StreamReader class instead of the ELC for this type of project

If you outline a desired example then we might be able to give an example code set as a solution to that problem

Reply With Quote
  #5 (permalink)
 arjfca 
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
Posts: 263 since Sep 2010
Thanks Given: 440
Thanks Received: 91


ABCTG View Post
Martin,

from this post it's not really clear what the problem is. From the MC post it appears you are having problems with how to create and name the list. This is something you have to do before you can work with it.
From the code piece you posted it appears that you want to read every line into its own list and store all those lists within a collection of lists.

I could better help you if I you could elaborate what exactly you want to achieve in the end. Meaning in what structure you need the strings later. Maybe what you are trying to do could be accomplished easier.

If you are sure you are on the right track a synopsis of what to do would be something like this:

1. Create a new (or shared) collection of lists.
2. Create a new list and read the first line of your file into this list.
3. Store the list within your collection. This should be done by a key you can easily re-access.
4. Create a new list and read the second line into this list.
5. Store this list within your collection.

Of course 2. to 5. should be done within a loop.

After that you can loop up each list by its key from the collection, call it and read the individual list values.

Again I am not sure that you need something like this and for understanding EL Collections I would strongly advise to start with something simple. Collections of Lists and Maps are more complex, but easily to manage once you have a solid ELC understanding.

Regards,
ABCTG


Hello Chris

To be honest.... I don't understand too much about ElCollection... I just don't get it.

File creation: Explanation of what I have already done,

A file is created. This file is created by capturing info on trend line that are draw on a chart. The goal is to reproduce these trend line to the same instrument but wit a lower scale. I draw trend line that represent bid support / resistance or supply / demand level. I draw them on a 4H and daily charts. Actually, I redraw them manually, I want it to be done by the code

File creation:
Each time a new Trend line is read, MC capture, The price, the date/time / color / size / style
Mc create a CSV string whit these data
Each string is terminated with the "NewLine" command
String are then entered in the file using the FileAppend command

At the end, I got a Text file named under the instrument that was used to capture trend line. Each Text file is specific to an instrument.


Explanation of what I want to achieve
I want to connect (create an ID) and open the text file

I need to read and put in variable named "TL_String" the first string ( inscription) of the text file

This TL_String will be process... (This work is done) and trend line is draw on a chart

Loop until all the string has been read in the file


To do these steps, I think that I need ElCollection

I need to learn
- how to "connect" create an ID (the path\name is under a variable name "FileName"
- How to read one string at the time and loop until all string has been read
- How to close the file if needed.

Hope it better explain what I want to achieve

Martin:

N.B.
Once finished, I will publish the code to reproduce the trend line over different chart using different scale.

While working on this , I created a tool that enable me to execute a function using a click of the mouse. Click on the upper corner, capture all trend line A click on the lower corner, will execute the function to reproduce the trend line. This enable me to control some function on MC using mouse click.. It could easily be modify the to enable me to have more clickable region that may act like command button. This section has been add to an indicator that I use on all charts

Started this thread Reply With Quote
  #6 (permalink)
StratOpt
AR Kansas
 
Posts: 13 since Dec 2013
Thanks Given: 0
Thanks Received: 7

One trendline per file ?

You only need the starting and ending data to create a trendline in TS. Is that what your files will contain ?

Reply With Quote
  #7 (permalink)
 arjfca 
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
Posts: 263 since Sep 2010
Thanks Given: 440
Thanks Received: 91


StratOpt View Post
One trendline per file ?

You only need the starting and ending data to create a trendline in TS. Is that what your files will contain ?

No
A file contain one string per trend line
No limit on trend lines ( string)

Martin

Started this thread Reply With Quote
  #8 (permalink)
StratOpt
AR Kansas
 
Posts: 13 since Dec 2013
Thanks Given: 0
Thanks Received: 7

Ok, the only data required to build the trendlines in TS is as follows

startDate, startTime, price, endDate, endTime, endPrice

You can cycle through a comma delimited file and build a series of trendlines using the StreamReader class and a TokenList

Let me get through this trading day and I will try to provide you a core example of such over the weekend.

Reply With Quote
  #9 (permalink)
StratOpt
AR Kansas
 
Posts: 13 since Dec 2013
Thanks Given: 0
Thanks Received: 7

Since this only takes a few minutes I completed an example EasyLanguage indicator before I broke for lunch. You can expand on it to provide user defined colors and styles as well as any other operation applicable to a TrendLine.

 
Code
using elsystem;
using elsystem.io;
using tsdata.common;

inputs:
    Drive ( "C" ) ,
    FileLocation ( ":\" ),
    Unique ( "BuildTL" ),
    Extension ( ".txt" ) ;
variables: 
    string FileName ( "" ) ,
    string getLine ( "" )  ,   
    int Index ( 0 ),   
    TokenList TL( null ),		
    StreamReader sr ( null );

once begin
     FileName = Drive + FileLocation + Unique + Extension ;
     sr = StreamReader.Create( FileName ) ;
     
     while sr.EndOfStream <> true
     begin
         getLine = sr.ReadLine();
		
         if InStr( getLine, "," ) > 0 then
         begin
            TL = TokenList.Create( getLine ) ;				
            Index = TL_New( StrToNum( TL[0] ), StrToNum( TL[1] ), StrToNum( TL[2] ),
                            StrToNum( TL[3] ), StrToNum( TL[4] ), StrToNum( TL[5] ) );             
         end ;                   
     end ;

     sr.Close();
end ;

File format would be as follows. startDate, startTime,startPrice,endDate,endTime,endPrice

1131217,0900,1774.25,1131217,1500,1800.25
1131218,0900,1776.25,1131218,1500,1801.25
1131219,0900,1798.75,1131219,1500,1801.75

Reply With Quote
Thanked by:
  #10 (permalink)
 arjfca 
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
Posts: 263 since Sep 2010
Thanks Given: 440
Thanks Received: 91



StratOpt View Post
Since this only takes a few minutes I completed an example EasyLanguage indicator before I broke for lunch. You can expand on it to provide user defined colors and styles as well as any other operation applicable to a TrendLine.

 
Code
using elsystem;
using elsystem.io;
using tsdata.common;

inputs:
    Drive ( "C" ) ,
    FileLocation ( ":\" ),
    Unique ( "BuildTL" ),
    Extension ( ".txt" ) ;
variables: 
    string FileName ( "" ) ,
    string getLine ( "" )  ,   
    int Index ( 0 ),   
    TokenList TL( null ),		
    StreamReader sr ( null );

once begin
     FileName = Drive + FileLocation + Unique + Extension ;
     sr = StreamReader.Create( FileName ) ;
     
     while sr.EndOfStream <> true
     begin
         getLine = sr.ReadLine();
		
         if InStr( getLine, "," ) > 0 then
         begin
            TL = TokenList.Create( getLine ) ;				
            Index = TL_New( StrToNum( TL[0] ), StrToNum( TL[1] ), StrToNum( TL[2] ),
                            StrToNum( TL[3] ), StrToNum( TL[4] ), StrToNum( TL[5] ) );             
         end ;                   
     end ;

     sr.Close();
end ;

File format would be as follows. startDate, startTime,startPrice,endDate,endTime,endPrice

1131217,0900,1774.25,1131217,1500,1800.25
1131218,0900,1776.25,1131218,1500,1801.25
1131219,0900,1798.75,1131219,1500,1801.75

Thank you StratOp

Question: Where do I get the StreamReader?

Martin

Started this thread Reply With Quote
Thanked by:




Last Updated on December 22, 2013


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts