Rules framework

 

So my current project has become quite, uh, webbed... In a bad way. I'm finding it problematic to define trade rules in a consistent and consolidated way, and if I step away for too long I find it hard to identify sometimes why a trade was opened or close, although my logging is pretty good.

Is there any shared code out there, which could work as a rule definition framework? My initial idea was something like a bunch of rules such as this:

   Rule[r] = "DIRECTION:short|BOL:price<lower(20,2)|MA:5<60"; // this example would allow a short trade, upon price coming outside the bollinger, and MA5 crossing below MA60....

Obviously these rules are extremely simple, and only fantasy would limit the complexity here, but at least it would keep the rules in one place away from the complexity of implementation.

One could even envisage a yaml based ruleset which would be independent of the execution platform... Blue sky thinking here, but curious what people think.