You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
True, but since the OP did not provide any skeleton code, I gave the advice that I believe will fulfill the requirements the best based on my own experience. Using, pure arrays can seem to be the quickest solution due to the use of the ArraySort, but he will soon reach a point where pure arrays will become rather messy and limiting. So, i suggested an array of structure because it will be the next best thing before having to suggest the use of Classes.
and very good advice it is.
I was just adding a bit of information about ArraySort - it was not meant to be critical in any way.
As yet, I have had no reason to sort a struct array, but I guess it wouldn't be too difficult.
Usually the only thing that I need to do is add or remove an element of a struct array when a new trade is opened, or one closed.
An example of my function to remove is
but after reading a recent post by WHRoeder, it seems that this could be simplified to
Does that seem right to you? as I haven't got around to testing it yet.
Any comments and possible improvements will be welcome.
Thanks
and very good advice it is.
I was just adding a bit of information about ArraySort - it was not meant to be critical in any way.
As yet, I have had no reason to sort a struct array, but I guess it wouldn't be too difficult.
Usually the only thing that I need to do is add or remove an element of a struct array when a new trade is opened, or one closed.
An example of my function to remove is
but after reading a recent post by WHRoeder, it seems that this could be simplified to
Does that seem right to you? as I haven't got around to testing it yet.
Any comments and possible improvements will be welcome.
Thanks
I don't usually do it that way because I find that Resizing and Reshuffling array elements is rather inefficient due too high RAM and CPU. Instead I try to use some kind of indexing depending on the requirement I may have. Sometimes I may just use a simple "Head" and "Tail" system, while other times I may use a full indexing system, where only the index array is managed and sorted. It really depends on the exact need.
I was going to ask about the ArraySort function.... because If I do set up an array as outlined... then I would have to sort it....
I'm beginning to think that static variables are the way to go.... but then again... FMIC... you are telling me that it becomes a processing issue.... My EA is processed to the max....
Fok...
Sorry.... other way around...
FMIC - What do you mean when you say a "Head" or "Tail" system....
Let's not complicate things just yet. Since you have no experience with "arrays", try to start simple and slowly move onto more complex things. Start with using just a simple array of ticket numbers for orders, and then slowly add more data to other arrays or if you get to understand structures, then use an array of the structure.
However, just as future reference; "head" and "tail" are just a means of keeping track of list of things and being able to add or remove items from either the beginning or the end of that list. In a simple array, you normally can only add or remove an item on one end only, without having to reshuffle all the items again.
Ok... let's not complicate things.... FMIC... I've sent you some mail.... Hopefully I won't have to get into this but once my EA is running smoothly then.... getting to know Arrays will be on top of my list.... purely from a programming point of view...
But then again.... do I waste my time learning about Arrays... or do I spend my time working out how to create a good website.... and how to manage it... how to market it...
It's all a flipp'n pain in the arse...
Anyways...
But then again.... do I waste my time learning about Arrays...
I very much doubt that it would be a waste of time.
Say you want to print some onformation on the chart with heading labels
By using an array
That took me a few minutes to write the code to place 15 heading labels.
Now, of course, you can create the 15 objects individually by creating 1 and then copy and paste 14 times and modifying the names and text.
I can assure you that it will take a lot longer.
Hands up all those that have copied and pasted blocks of code and never missed modifying something that leads to errors!
You with your hand up, you're a liar!
But then again.... do I waste my time learning about Arrays... or do I spend my time working out how to create a good website.... and how to manage it... how to market it...
Website? What are you talking about? Probably, you just joking around!
Anyway, Arrays is one of the most basic programing techniques in almost every language, so LEARN IT!!!!
Thanx guys...
I'm on it...
Array[x] = array[x+1] will work if the struct does not have any strings or dynamic arrays.
If you do add a string, add a copy constructor and assignment operator to your structure. Make it responsible for itself, so array[x] = array[x+1] still works.
As yet, I have had no reason to sort a struct array, but I guess it wouldn't be too difficult.