
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
There is no possible generic solution to this issue in MQL currently. 5 years ago, I was facing similar issue (maybe not obvious it's similar but it is related to variant type)
What you would need is a variant "type", which is hard to implement in MQL.
If you can provide an example a bit less simplified, maybe the community can help, as the best solution depends on what you are really trying to achieve.
thanks a lot
i went through your post and it was definitely way more complicated and high level than my problem. i am definitely not experienced enough to completely follow that in first glance😅.
but something picked my attention that you say it is hard to implement. so this is possible somehow.
i'm pretty sure it would be complicated and i may not have the knowledge to do it now, but if i wanted to make it happen. where should i start?
Thank you, everyone, for your responses!
I was trying to use iCustom to dynamically load multiple indicators with varying parameters, aiming for a flexible and reusable setup. I thought maybe if I could make the idea more abstract my answer would not be as straightforward as this post. I know the reason now. However, the lack of a true variant type in MQL5 makes handling different outputs very challenging. It seems this limitation is inherent to the language.
I appreciate all the help 🙏🙏🙏
thanks a lot
i went through your post and it was definitely way more complicated and high level than my problem. i am definitely not experienced enough to completely follow that in first glance😅.
but something picked my attention that you say it is hard to implement. so this is possible somehow.
i'm pretty sure it would be complicated and i may not have the knowledge to do it now, but if i wanted to make it happen. where should i start?
You should start to provide real code if you need coding help.
For the rest continue to study and acquire experience, it's what I did.
You should start to provide real code if you need coding help.
For the rest continue to study and acquire experience, it's what I did.
I read the mqlparam document, it is good for built in indicators. Still for new ones I need ICustom.
Here is an example of execution of arbitrary indicators - https://www.mql5.com/en/code/32107
The solution is to step out of the pure MQL5 and implementing an expression evaluator (also in MQL5 though).
The other way you could take requires a small explanation. All parameters of indicators can be divided into 2 main groups: strings and non-strings. This is because any numbers/dates/etc are implicitly typecasted to each other, thereas the string is completely different thing - an object. Hence you can theoretically generate a lot of predefined function prototypes with different combinations of string and non-string parameters (for example, func(N,N,S,N,S), func(N,S,N,N,N), etc., where N is a number, S is a string), and then compiler will match corresponding template. The problem here is that the number of possible combinations grow very fast. Many years ago I tried to do this for a 20-30 parameters, and compiler crashes. If, say, 5-10 parameters are sufficient for you, then you can do this.
PS. Probably, most simple approach (which just came to my mind) would be to use the AutoIndicator from the book. In this approach you'll need to StringFormat() parameters of your arbitrary indicator and pass to the AutoIndicator, which will do the rest of work for you, that is parse the string and create required indicator via MqlParams.
Here is an example of execution of arbitrary indicators - https://www.mql5.com/en/code/32107
The solution is to step out of the pure MQL5 and implementing an expression evaluator (also in MQL5 though).
The other way you could take requires a small explanation. All parameters of indicators can be divided into 2 main groups: strings and non-strings. This is because any numbers/dates/etc are implicitly typecasted to each other, thereas the string is completely different thing - an object. Hence you can theoretically generate a lot of predefined function prototypes with different combinations of string and non-string parameters (for example, func(N,N,S,N,S), func(N,S,N,N,N), etc., where N is a number, S is a string), and then compiler will match corresponding template. The problem here is that the number of possible combinations grow very fast. Many years ago I tried to do this for a 20-30 parameters, and compiler crashes. If, say, 5-10 parameters are sufficient for you, then you can do this.
PS. Probably, most simple approach (which just came to my mind) would be to use the AutoIndicator from the book. In this approach you'll need to StringFormat() parameters of your arbitrary indicator and pass to the AutoIndicator, which will do the rest of work for you, that is parse the string and create required indicator via MqlParams.
Very Interesting, i will check out the library.
thank you.
Here is an example of execution of arbitrary indicators - https://www.mql5.com/en/code/32107
The solution is to step out of the pure MQL5 and implementing an expression evaluator (also in MQL5 though).
The other way you could take requires a small explanation. All parameters of indicators can be divided into 2 main groups: strings and non-strings. This is because any numbers/dates/etc are implicitly typecasted to each other, thereas the string is completely different thing - an object. Hence you can theoretically generate a lot of predefined function prototypes with different combinations of string and non-string parameters (for example, func(N,N,S,N,S), func(N,S,N,N,N), etc., where N is a number, S is a string), and then compiler will match corresponding template. The problem here is that the number of possible combinations grow very fast. Many years ago I tried to do this for a 20-30 parameters, and compiler crashes. If, say, 5-10 parameters are sufficient for you, then you can do this.
PS. Probably, most simple approach (which just came to my mind) would be to use the AutoIndicator from the book. In this approach you'll need to StringFormat() parameters of your arbitrary indicator and pass to the AutoIndicator, which will do the rest of work for you, that is parse the string and create required indicator via MqlParams.
Thank you sir.
Today I have accuired a lot of reading material, thanks to you and Stanislav Korotky.
Thanks a lot 🙏🏻🙏🏻🙏🏻
Hello Everyone
is there in any way possible to create something that could make this possible?
to have a function or method? a structure, class, some data type or anything that could solve this problem?
Thank You in advance 🙏🙏🙏