#40 Custom Graph - Formula parsing error (parenthesis)

open
nobody
None
5
6 days ago
2012-03-09
Anonymous
No

The following formula seems correct, however it's not parsed correctly (at least trying to create a Custom Graph with it), it expects a right parenthesis when parsing the last subexpression (without lag).

Formula:
((((lag(close,-2)-min(low,14,-2))/(max(high,14,-2)-min(low,14,-2)))*100)+(((lag(close,-1)-min(low,14,-1))/(max(high,14,-1)-min(low,14,-1)))*100)+(((close-min(low,14))/(max(high,14)-min(low,14)))*100))/3

(
(((lag(close,-2)-min(low,14,-2))/(max(high,14,-2)-min(low,14,-2)))*100)+
(((lag(close,-1)-min(low,14,-1))/(max(high,14,-1)-min(low,14,-1)))*100)+
(((close-min(low,14))/(max(high,14)-min(low,14)))*100)
)/3

Discussion

  • Mark Hummel
    Mark Hummel
    2012-03-10

    There is a syntax error in that equation. Add Operations need to be in groups of two, and while you've grouped them correctly for lag(close..) - min etc, the top level adds aren't:

    ie. instead of (A + B) + C, you've got A + B + C. Here's the expression rewritten which parses:

    ((((lag(close,-2)-min(low,14,-2))/(max(high,14,-2)-min(low,14,-2)))*100)+(((lag(close,-1)-min(low,14,-1))/(max(high,14,-1)-min(low,14,-1)))*100))+(((close-min(low,14))/(max(high,14)-min(low,14)))*100)/3

     
  • Mark Hummel
    Mark Hummel
    2012-03-18

    • status: open --> pending
     
  • Oops, I posted that logged off, I didn't know about the parenthesis rule, I'll check the docs and make sure it's stated there (and next time read it first :) ).

    Thanks,
    Guillermo

     
    • status: pending --> open
     
  • Mark Hummel
    Mark Hummel
    2012-03-29

    It's not actually mentioned in the manual. I've updated the manual so it now mentions that restriction. Why is restricted like that? I can only think it's because it made writing the parser easier.
    We may want to look into how hard it would be to fix.