You can make custom actions like that for sure, its just getting the runtime compilation of a written string formula is a completely different matter.
If you have a consistent structure of equation then yeah, just put a bunch of public variables, use them in the equation and you can change them whenever you want. I don't know what you're going for with the conditions thing though.