String fast question

Posted By: maxwellreturn

String fast question - 07/20/19 21:29

Hi all, sorry for my dumb question laugh
how can i get a string from a variable for use it in the text editor. For example:
Code
string x = "SMA";
vars MA = series(x(priceClose(), 100));


PS. without using "#define x SMA", only with string var.
Thanks
Posted By: AndrewAMD

Re: String fast question - 07/20/19 22:22

Your choices are:
* Use a macro
* Use a function pointer
* Have the string as an argument for a wrapper function.

Take your pick.
Posted By: maxwellreturn

Re: String fast question - 07/21/19 06:23

hi andrew thanks for your answer, can you give me examples for every choice?
Posted By: AndrewAMD

Re: String fast question - 07/21/19 15:49

There is an excellent example of how to do this. Read this blog article by jcl:
https://financial-hacker.com/trend-and-exploiting-it/

The function filter() is redefined many times in a large scale test, using batch scripting. Definitely give it a look.
Posted By: maxwellreturn

Re: String fast question - 07/21/19 16:56

thank you andrew this is an elegant solution. i think with this you refere to your third choice, the "wrapper function". Can i ask you for the second choice how can i pratically do it?
© 2024 lite-C Forums