ElCollection: Want to understand - futures io
futures io futures trading



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 7,020 views
    2. thumb_up 5 thanks given
    3. group 3 followers
    1. forum 13 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

ElCollection: Want to understand

(login for full post details)
  #1 (permalink)
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
 
Posts: 263 since Sep 2010
Thanks: 440 given, 91 received

Hello

I did post a similar question on Multicharts forum, but no answerd yet.
MultiCharts: Trading Software for Automated Trading and Backtesting ? 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

Journal Challenge February 2021 results (so far):
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(152 thanks from 29 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(110 thanks from 31 posts)
looks_3Wisdom is Emptinessby Mtype
(68 thanks from 25 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(31 thanks from 15 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
 
 
(login for full post details)
  #3 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 received


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
 
(login for full post details)
  #4 (permalink)
AR Kansas
 
 
Posts: 13 since Dec 2013
Thanks: 0 given, 7 received

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
 
(login for full post details)
  #5 (permalink)
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
 
Posts: 263 since Sep 2010
Thanks: 440 given, 91 received


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
 
(login for full post details)
  #6 (permalink)
AR Kansas
 
 
Posts: 13 since Dec 2013
Thanks: 0 given, 7 received

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
 
(login for full post details)
  #7 (permalink)
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
 
Posts: 263 since Sep 2010
Thanks: 440 given, 91 received


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
 
(login for full post details)
  #8 (permalink)
AR Kansas
 
 
Posts: 13 since Dec 2013
Thanks: 0 given, 7 received

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
 
(login for full post details)
  #9 (permalink)
AR Kansas
 
 
Posts: 13 since Dec 2013
Thanks: 0 given, 7 received

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
The following user says Thank You to StratOpt for this post:
 
(login for full post details)
  #10 (permalink)
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
 
Posts: 263 since Sep 2010
Thanks: 440 given, 91 received



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
The following user says Thank You to arjfca for this post:
 
(login for full post details)
  #11 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 received

Martin,
this will only work in Tradestation as the code uses Object Oriented EasyLanguage. Something MC can't work with.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #12 (permalink)
AR Kansas
 
 
Posts: 13 since Dec 2013
Thanks: 0 given, 7 received

This is a TradeStation programming forum.

elsystem.io is where you will find the StreamReader and tsdata.common is what contains the TokenList.

MultiCharts.net is best option for doing such things in that platform

Reply With Quote
 
(login for full post details)
  #13 (permalink)
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
 
Posts: 263 since Sep 2010
Thanks: 440 given, 91 received

Just to say that I finally succeed to use ElCollection. I got a better understanding of it now.

1- The initial goal was to capture from a a chart the present trend line. Store the characteristics of them in a file

2- Redraw the trend lines on another workspace using the stored data.

While creating the tool, I created a switch button concept using mouse click event

A click on the upper corner will capture trend line
A click on the lower corner will redraw using a file of the same instrument


To prevent fatal error using Elcollection, some verification has been done

First thing first: Check if the file do exist using : Value1 = ELC.PathExists(FilePath);

Always make sure that there is at least one inscription in the file. To do so, at the creation if no trend line present, I write "EOF" in the file. If "EOF" is detected as the first string value then don't try to read further and exit.

Count the the number of line in the file using: Count = ListS.Count(TL_String_ID) ;
Make sure that we don't try to read a line above the count number

On each event: a voice message is heard
Trend line are captured
Trend line are draw
No file Exist
No Trend line to draw
etc.

A Special thanks to ABC. FuryTrader, JohnB

Happy Xmas
All the best for the New Year to come

Martin

Started this thread Reply With Quote
The following user says Thank You to arjfca for this post:
 
(login for full post details)
  #14 (permalink)
AR Kansas
 
 
Posts: 13 since Dec 2013
Thanks: 0 given, 7 received

Were you wanting to do this in TradeStation or in MultiCharts ? If in MultiCharts then why post the query within the TradeStation programming forum ? I am new here so might be confused as to how the structure of questioning and forum structure goes.

I am well familiar with ELCollections. I actually have the source code for it given to me by the creator of the DLL many years ago. As you may know the creator of the ELC is now on the programming team at TradeStation and the ELC is an integral part of the TradeStation platform.

Regardless, glad to hear you have a solution because in the end that is all that matters.

Reply With Quote
The following user says Thank You to StratOpt for this post:


futures io Trading Community Platforms and Indicators EasyLanguage Programming > ElCollection: Want to understand


Last Updated on December 22, 2013


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1500 prizes from Topstep!

February
 

Identifying Setups & Targets Using Profile Charts w/Trevor & Tradovate

Feb 25
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts