![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
I see. @Alain Verleyen Since Dominik pointed out with his very first comment that the original question is not an error, but a known issue, a limitation, the whole convo got off-topic :)
@Dominik Egert I'd love to use a struct array as it was my plan, since a professional programmer recommended to do so, and I love to experiment with solutions that I am not familiar with (yet) - the bigger the sense of accomplishment gets.
I'm still searching for the proper way to do the task, however, I didn't really get this question of yours:
"The main problem is, when you want to sort an array with structures, which member to use for the sorting?" - As I said, I thought I can sort the array by the ENUM_TIMEFRAMES values, as this is the first dimension. Why isn't it possible? Or is it a bad idea as well?
EDIT: sorting by the timestamp might be a better idea? The goal is to verify wether if an object exists at the examined point in time, for the current timeframe or not. /EDIT
If I want to sort it with a custom sort function, as you suggested, what would be the proper expression to sort it?
Without such knowledge, it seems easier for me to create mqlite requests at this point.
I see. @Alain Verleyen Since Dominik pointed out with his very first comment that the original question is not an error, but a known issue, a limitation, the whole convo got off-topic :)
@Dominik Egert I'd love to use a struct array as it was my plan, since a professional programmer recommended to do so, and I love to experiment with solutions that I am not familiar with (yet) - the bigger the sense of accomplishment gets.
I'm still searching for the proper way to do the task, however, I didn't really get this question of yours:
"The main problem is, when you want to sort an array with structures, which member to use for the sorting?" - As I said, I thought I can sort the array by the ENUM_TIMEFRAMES values, as this is the first dimension. Why isn't it possible? Or is it a bad idea as well?
If I want to sort it with a custom sort function, as you suggested, what would be the proper expression to sort it?
Without such knowledge, it seems easier for me to create mqlite requests at this point.
I see. @Alain Verleyen Since Dominik pointed out with his very first comment that the original question is not an error, but a known issue, a limitation, the whole convo got off-topic :)
@Dominik Egert I'd love to use a struct array as it was my plan, since a professional programmer recommended to do so, and I love to experiment with solutions that I am not familiar with (yet) - the bigger the sense of accomplishment gets.
I'm still searching for the proper way to do the task, however, I didn't really get this question of yours:
"The main problem is, when you want to sort an array with structures, which member to use for the sorting?" - As I said, I thought I can sort the array by the ENUM_TIMEFRAMES values, as this is the first dimension. Why isn't it possible? Or is it a bad idea as well?
EDIT: sorting by the timestamp might be a better idea? The goal is to verify wether if an object exists at the examined point in time, for the current timeframe or not. /EDIT
If I want to sort it with a custom sort function, as you suggested, what would be the proper expression to sort it?
Without such knowledge, it seems easier for me to create mqlite requests at this point.
As I said before, I am not a professional coder. I used to code basic MQL4 and MQL5 programs for myself for a few years now. I used arrays to access indicators, mostly, I know it is a sort of container to store data of same type effectively. I know it may have multiple dimensions, and now I know that I said something stupid about a structure and the dimensions of the array. This is the first time I use a struct. As I gain experience in coding, more and more complex tasks I can solve. I saw lists in R studio, and now I think that a struct works quite the same (or pretty similar in my understanding) way, but I haven't used it before in MQL. This might be the concept you mentioned? What do you mean how arrays work? The commands you mean, or the memory addressing, or what? What else do I need? The thing is, there is no language independent "general" coding school (online). I've enrolled to a MQL4 course on Udemy, did the same thing for a python course, also on Udemy, but these provide only to commands to work with these objects with some test tasks.
I was trying to figure out how can I put struct data into an array by myself, as the documentation says it IS possible, it also tells that doing so creates an array with one dimension, with every element being a "list" of the struct, but does not provide info on how to sort it or how to do any basic operations with it. I tried as I thought it might work, but I failed, since it does not work as it should be, or as a less experienced coder would expect, so I stuck there, and there is no documentation, no relevant pages exist on the web (at least I haven't find any). How could I proceed then if I can't research the topic?
I posted the question here because I thought some experts might point out what the solution might be, what I'm doing wrong, you tried, but I didn't get it. I didn't see a proper expression how can one compare eg. a string with another, or a date with another, with simple arithmetic operations, that's why I had no idea how to create a sorting function what you suggested in one of your early comments.
Sorry for blabbering. I'm just a bit desperate now, because I'm being refused for being unexperienced, and getting further away from the solution, after this much talk. That's why I said I'll stick to the sqlite approach, I could create working queries, inserts and replace requests, since it is well documented.
If you post code that compiles, with your attempt to use arrays and struct, we will help.
I don't have any. That's why I posted my question here, in hope of getting some sort of guidance or help without having the solution already :) I have code that compiles for sqlte approach.
If you post code that compiles, with your attempt to use arrays and struct, we will help.
When I tried to use arrays and struct, I got a complier error, posted in the beginning. But as Dominik pointed out it was not an error, and I couldn't figure out how to sort it with the suggested ways.
I don't have any. That's why I posted my question here, in hope of getting some sort of guidance or help without having the solution already :) I have code that compiles for sqlte approach.
As I said before, I am not a professional coder. I used to code basic MQL4 and MQL5 programs for myself for a few years now. I used arrays to access indicators, mostly, I know it is a sort of container to store data of same type effectively. I know it may have multiple dimensions, and now I know that I said something stupid about a structure and the dimensions of the array. This is the first time I use a struct. As I gain experience in coding, more and more complex tasks I can solve. I saw lists in R studio, and now I think that a struct works quite the same (or pretty similar in my understanding) way, but I haven't used it before in MQL. This might be the concept you mentioned? What do you mean how arrays work? The commands you mean, or the memory addressing, or what? What else do I need? The thing is, there is no language independent "general" coding school (online). I've enrolled to a MQL4 course on Udemy, did the same thing for a python course, also on Udemy, but these provide only to commands to work with these objects with some test tasks.
I was trying to figure out how can I put struct data into an array by myself, as the documentation says it IS possible, it also tells that doing so creates an array with one dimension, with every element being a "list" of the struct, but does not provide info on how to sort it or how to do any basic operations with it. I tried as I thought it might work, but I failed, since it does not work as it should be, or as a less experienced coder would expect, so I stuck there, and there is no documentation, no relevant pages exist on the web (at least I haven't find any). How could I proceed then if I can't research the topic?
I posted the question here because I thought some experts might point out what the solution might be, what I'm doing wrong, you tried, but I didn't get it. I didn't see a proper expression how can one compare eg. a string with another, or a date with another, with simple arithmetic operations, that's why I had no idea how to create a sorting function what you suggested in one of your early comments.
Sorry for blabbering. I'm just a bit desperate now, because I'm being refused for being unexperienced, and getting further away from the solution, after this much talk. That's why I said I'll stick to the sqlite approach, I could create working queries, inserts and replace requests, since it is well documented.
Thank you very much for the detailed explanation. I also checked the 3 links you provided - for the first one, I knew most of it, therefore I did not check back there to realize a structure is considered a variable but as a complex one, but I did check its docs page, to get familiar with the syntax and such, when I was studying its properties. The second one was more or less known for me, but the third one, was quite a deep dive, its more of a complex topic for me at this time.
Last night I was added the complete funcionality with the database approach. I'm currently adding a feature to add masses os records to test performance drop.
I'll review the suggested pages in the near future, if/when I'll decide to change the code to the array approach, if the change is justified by a significant drop in performance, however, I know that would be the best practice, or a more elegant way to solve this problem.
Thank you very much for your guidance. I'll come back to you soon with the outcome.