chained lists : who knows how make them in Empty4 ?

Post Reply
User avatar
scanner
Trader
Posts: 20
Joined: Mon Jul 16, 2012 2:32 am

chained lists : who knows how make them in Empty4 ?

Post by scanner »

Hi guys,

I Just heard a word with chained lists and Hashtable.

With Array, without knowing anything about Hashtable, I've already used "#define" instead of Hashtable, because use of EA don't need new string names, so easiest.

But perhaps chained lists could help , I don't find them in the Empty4 Book and I find something not clear at all for me on google.
So I've understood the principe, but would like to make it under Empty4, anyone could help ?

This is what I've got on web c# for sample and education:

===============================================
#include <stdlib.h>
typedef struct element element;
struct element
{
int val;
struct element *nxt;
};
typedef element* llist;

int main(int argc, char **argv)
{
/* try to declare 3 chained listed on three different way */
llist ma_liste1 = NULL;
element *ma_liste2 = NULL;
struct element *ma_liste3 = NULL;

return 0;
}

========================================================


If anyone knows, could he explains how make that under Empty4 ?

Thanks

Daniel
You do not have the required permissions to view the files attached to this post.
Last edited by scanner on Wed Jun 12, 2013 4:31 am, edited 1 time in total.
User avatar
scanner
Trader
Posts: 20
Joined: Mon Jul 16, 2012 2:32 am

Re: chained lists : who knows how make them in Empty4 ?

Post by scanner »

I have to add the difference between Arrays and Chaine list for who need it, I don"t know that before this afternoon..)

- in an Array, if you add or substract an element, you have to resize the size of the array, that reallocate the memory, and the elements change of position.

but, when you want a specific element, you get it directly : in an Array< string Name[500];>
<Alert("Name[201]",Name[201])>; will give us directly <"Steve">..
- in a chain list , you can add or substract any element without resize it because each of them get an individual place, anywhere, not contigue, they are just "chained" , each to the next you add.

The difference is that to get "steve", you can't get it with a direct ref [201], you have to read all the Chained list until you find him in pos 201 "Steve".

the twice as their own interest , I think in case of Ea MultiSymbol with the possibility to change the list ,
the pos of all Symbol change each time, so, we could add a chained list with name of all Symbol we could be able to load with theirs specific individuals paramaters under specifics setups..

so, this the why of my question : how can we built chained list under with Mql4.
User avatar
mjws00
Trader
Posts: 609
Joined: Fri Jan 04, 2013 10:17 pm
Location: Victoria

Re: chained lists : who knows how make them in Empty4 ?

Post by mjws00 »

I'm not sure I see what problem this solves. Arrays are a little inefficient. Multidimensional arrays can obfuscate the code somewhat. But we aren't trying to parse a million bits of data in MQL. Arrays have the advantage in this context in that they allow random access, and have built in indexing. Not to mention Empty4 has built in sorting and some other useful array functions.

Linked lists are more useful when we care about how the data is structured within memory, or on disk. Empty4, and your OS handles all this for us. Even if we change the structure in Empty4 we can't control how it allocates or deals with things, and will likely trade speed as it deals with structures it wasn't optimized for.

I've seen a lot of clever hacks and work arounds in Empty4. Never seen a clever coder approach data in this system this way. Perhaps I'm missing something, but don't see the upside.

Good luck, if there is a useful tool here I'd love to learn about it.

Mike
Reading the dark heart.
garyfritz

Re: chained lists : who knows how make them in Empty4 ?

Post by garyfritz »

Linked lists are most valuable when you need to insert a lot of elements into the middle of the list, e.g. if you want to insert them in sorted order. AND if you will usually access the elements in order, moving from element 1 to element 2 to 3 to 4...

If you don't have a lot of need to insert elements in the middle of the list, or if you will be accessing the elements in random order (e.g. Name[201]), then linked lists aren't a good answer.
User avatar
scanner
Trader
Posts: 20
Joined: Mon Jul 16, 2012 2:32 am

Re: chained lists : who knows how make them in Empty4 ?

Post by scanner »

garyfritz wrote:Linked lists are most valuable......
Yes I know that, all my EA is structured like this example , but I wonder.. :


Function who can get all prices of all kind of Heikein ashi for #TF and # Bar :
Array.txt
It is not for tick' scalping Ea.. ;) , I work on minimum H4.

and my own convension in , is ( Hk is Heiken; HkB & HkR are, Heiken Blue and Red;
HkCl, HkOp, HkHi,HkLo, you've understood..Close, open..)

But , first I'ld like to know how to make chained list, and second, I think It will be usefull to let specifix parameter for a specific fix name when the positions' reference of names are going to changed often.
In my example, I use parameter default for all situation instead off I have made specific parameter (or optimzation )for a symbol.

These parameter could be, will different depending on whether the price will be studied , inside or outside Session , with or against the Trend, the # Setup concerned, and the symbol

So , I have made a kind of a little Hashtable system for that

1) one array to precise if the SetUp get special paramreters ( name here <bool atb.SetUpOptimz[];> ) ? if not, the function which scan the condition don't run this
2) I make an Array where I insert the name of the symbol which gets special parameters. TO GET FIX " PLACE ( just 28 symbol here but could be more)
string ats.PairOptimz[]={"","","","","","","","","EURAUD","","","","","EURUSD","","","","","GBPJPY","","","","","","","","","","",""};

3) Some sequence to rebuild the name of the symbol depends on the broker's special names list data symbol with suffixe or /and prefixe. even if the broker call "VIP.EURUSD.ECN",
just have to write on my list "EURUSD".

4) first run to find if the concern symbol for this setup getspecials parameters

5) Built of the "HASTABLE" system to be able to SWITCH directly to the good place where all the parameter's variables will be changed.

the function receive :
a) the "relative" position reference of the current list where I've selected the symbols that I want to trade (they are in GlobalVariable-F3 ) : afi.SB >> N°..
b) the # of the concerned SetUp : afi.SetUp >> N° ..
c) is situation in relation of its own currencie session ( outside or inside) : afi.session >> 8 or 9
d) If the trade will be against the Trend or with the Trend.: afi.Trend >> 2 or 3

6) the the function build its "case number" in : <int avi.RefCase> in this order : afi.Trend(2-3)+afi.Session(8-9)+afi.SetUp(0 to 99) + afi.SB (0 to 27)

7) after that Switch (avi.RefCase)

{
case 0 : break; these one to get out quickly

case 39613 : this concern : 3-overTrend, 9-outsideSession, 6-#SetUp & Symbol #13 of the list ");
atd.Slope[6]=37.5; // ...etc etc... with variable specific ajustment
//EXAMPLE
in this case, the atd.slope[6] will remplace the general config default parameter for
for the setup #6 and the Symbol 13th "EURUSD" here.
<< double atd.Slope[qi.SetUp]={-1,55,105,55,55,55,55,75,55,-1}; >>
break;
default : break;
}

So it is quite " complicated" , but in fact it is running very quickly.

and as, a list of 28 is not really heavy, I just wonder if chained list could be better.. or to be able to use it for another use..

the function I use to make this " Hastable":
Include ParamSpecial.txt
You do not have the required permissions to view the files attached to this post.
User avatar
scanner
Trader
Posts: 20
Joined: Mon Jul 16, 2012 2:32 am

Ok: Question on another way >>>

Post by scanner »

Let us no speaking about the interest of chained list for the moment,
is there, here, any programmer C# who just could try , even begin, to translate this in "MQL4" term
to allow me to find a system to get the same things ?

=============================================== :? :?:
#include <stdlib.h>
typedef struct element element; // what is this translate in MQL4 or what does that means??
struct element // what is this translate in MQL4 or what does that means??
{
int val;
struct element *nxt;
};
typedef element* llist; // what is this translate in MQL4 or what does that means ??

int main(int argc, char **argv) // **arg.what is this translate in MQL4 or what does that means ??
{
/* try to declare 3 chained listed on three different way */
llist ma_liste1 = NULL; // llist : what is this translate in MQL4or what does that means ??
element *ma_liste2 = NULL;
struct element *ma_liste3 = NULL;

return 0;
}

========================================================



I have seen some code where , and in manual to, where there was the sigle &nameArray, to
get the ref of an Array instead of its content.. perhaps we could make sommething with that


Thanks to try .. who can :shock:
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: Ok: Question on another way >>>

Post by gaheitman »

scanner wrote:Let us no speaking about the interest of chained list for the moment,
is there, here, any programmer C# who just could try , even begin, to translate this in "MQL4" term
to allow me to find a system to get the same things ?

=============================================== :? :?:
#include <stdlib.h>
typedef struct element element; // what is this translate in MQL4 or what does that means??
struct element // what is this translate in MQL4 or what does that means??
{
int val;
struct element *nxt;
};
typedef element* llist; // what is this translate in MQL4 or what does that means ??

int main(int argc, char **argv) // **arg.what is this translate in MQL4 or what does that means ??
{
/* try to declare 3 chained listed on three different way */
llist ma_liste1 = NULL; // llist : what is this translate in MQL4or what does that means ??
element *ma_liste2 = NULL;
struct element *ma_liste3 = NULL;

return 0;
}

========================================================



I have seen some code where , and in manual to, where there was the sigle &nameArray, to
get the ref of an Array instead of its content.. perhaps we could make sommething with that


Thanks to try .. who can :shock:
I don't mean to not seem helpful, but what are your doing with your data that you think needs a linked list? Once we know, we can give a more meaningful response than what follows. I looked at the code you posted and it didn't really help explain (to me at least) what you were hoping to accomplish.

Now, to seem helpful... In order to create linked lists we need the ability to work with pointers to data and to dynamically allocate memory for data. MQL doesn't let us do that. The only dynamic data option we have is resizeable arrays.

You can simulate pointers by creating an index array that is the same size as your data array, and populate it with the index values. Then you can use this index array to keep track of a sorted version of your data array without actually changing the data array. You could even have multiple index arrays for different sorts (best 4hr, best daily, etc). Then, whenever you access the data array, when you want the ith element based on your sort, you use the notation MainArray[idx].

George
User avatar
scanner
Trader
Posts: 20
Joined: Mon Jul 16, 2012 2:32 am

Re: Ok: Question on another way >>>

Post by scanner »

gaheitman wrote:
scanner wrote:Let us no speaking about the interest of chained list for the moment,
Then, whenever you access the data array, when you want the ith element based on your sort, you use the notation MainArray[idx].


Ok , thanks really.

This is exactly what I've need to know. I use a lot this (MainArray[idx] ), and to allocate " fix paramaters" to a fix name " Symbol" , to be find by a "relative" Symbol list, I use my own Hastable system that I have shown in the seconde example. and thats run well and fast.

It was just curiosity and too, I was asking myself if chained could help me for other things, perhaps, I hadn't understood really how they ran.

But your explanation has precised me exactly what I thought , and what you've described here would not serve us in a better way for what we have to do.

So thanks you.
Post Reply

Return to “Coders Hangout”